We see that there are long notes (4 beats) and short notes (1 beat) throughout the midi file given. The long notes represent the intended key and the short notes encode the flag in base 7 depending on its degree in the long note's key.
So for example, for the first measure, if we had c as the long note, and [d,e,f,c] as the short notes. This would translate to 1230.
If we have a key and a note, then the below code will get the degree of that note.
degrees = [0, 2, 4, 5, 7, 9, 11, 12]
degree = degrees.index((note - key) % 12)
After translating the midi file, we get
35325334165314424130161654514441250625262113221342661226243366520364044001356220465061044030136561452062650045543215005166210306640
which decodes to uscg{b9e87122589167966989853582e619906bb24648}
.