You are far smarter than you think.
Learn to get into flow, and also figure out how to get your state back faster... Once you do, it is a super power.
Simple things like leaving your editor/IDE open, create the same situation you left. I personally use music + IEMs to help me block sound and focus. -30-35 DB off the IEMs, and +70DB off my music... yeah, I don't hear anything.
I learned the editor trick recently, though I'd probably done it un-intentionally for years. I stopped, and I was wondering what the inertia I was facing was. It is only 2-3m to get setup... that's 2-3m to lose my thoughts, etc.
Good luck.
For me the best way to get into the flow is by directly getting back to where I left. If I take time to wake up, make breakfast or anything else I usually lost my ideas already and it takes me hours to get back to them.
Just writing it down, will help you remember. If not: You have the paper.
This is underrated. And, specifically...writing it down, with a pen or pencil. Typing it doesn't seem to have the same effect, even with some ritual of typing it into a fresh/separate document.
I used to use whatever cheap ballpoint was around, and I had terrible handwriting. But on a friend's recommendation I tried a fine point gel pen, the Uniball Signo DX 0.38mm. It's such a joy to write with and my handwriting is orders of magnitude more legible.
There's apparently a whole world of pens (and pen enthusiasts) out there: https://www.penaddict.com/top-5-pens
The only other software I usually have running on my work computer is a web browser.
People are always blown away by my ability to recall a story perfectly or create 2 page white boarded proofs, but inability to remember my SSN or why I entered a room.
A few years back I accepted a challenge to take a year off drinking from a family member.
I cannot tell you how much it improved my memory.
Before that I was always losing things, frustrated I couldn’t remember the names of things etc.
After about 3 months I felt like I had doubled my memory.
I wasn’t really a heavy drinker, but I would go for a few months having 1-2 beers a day.
Anyway just curious if you drink and have tried taking a break?
I need to derive things to understand them, ie music theory. I'm jealous of people who can memorize and take at face value but if I'm looking at a chord, I need to know the components that create that chord, which gets frustrating because music has a lot of rules that seem to be based on vibe and closeness. Two things can be identical but distinct based on their context.
It used to take me 2-3x as long to do homeworks or labs compared to other classmates. Same with work assignments. It often triggers an imposter syndrome type feeling.
Yet I have proof that I'm capable of solving complex problems, I understand certain things almost immediately compared to others, other things I need to study for a long time.
I tend to rarely know an answer on the spot, but I know how to determine many things, by knowing how to find the information needed.
I don't pretend to be a genius, but I have proof via a degree, others opinions of me, and material results that basically say I'm intelligent to a point.
Once I get into a flow I can retain a fairly complex system in my head but before or after that state, it's a terrible blur where I can barely focus my eyes.