I have a love/hate relationship with this. I love the songs that I end up writing (or simply hearing), but I hate that I can never remember them

To make this more discussion like, has anyone ever actually remembered and subsequently written/recorded a song they first heard in a dream?

I never really remember them, but most of the time the riffs stick to me, and those riffs are good.
Same problem here. This is something that happens to me on an almost nightly basis - just as you're drifting off to sleep, you start hearing this catchy tune in your head. I've gotten to the point where I immediately wake up and can still hear it, but by the next morning, it's lost. What you're supposed to do is have a small recorder next to your bed. As soon as you hear the song and can wake up, you sing, or hum, the song into the recorder. Hopefully, in the morning the snippet that you recorded gives you enough inspiration to get it back and write it down. I would do that, but my wife would think I'm nuts.
I usually remember it for a day, so I have one day to figure it out and whatnot.
I've only managed it once and it turned out pretty good.
They made me do push ups in drag

I'm gonna have a really hard time if we're both cannibals and racists.

Don't dress as a whore, he'll thump you.

I'm a firework, primed to go off
I remember it for a few hours, which is sometimes enough for me to work it out and right it down. I'm worse when I'm awake tbh, I can improvise in my head brilliantly, my fingers however...
...Stapling helium to penguins since 1949.
I usually come up with lyrics and stuff as I'm drifting up so I get up and put a memo in my phone or something, and then usually that works.

It's still annoying, especially for me who struggles to fall asleep anyway.