This is something I’m curious about. I was suffering from ADHD and I had a difficult time memorizing including a source code. So yet, I managed to practice with someone else’s code, and thoroughly I was learning well. Does that work for many programmers or am I the only one alone?
There are plenty of developers including myself that spend lots of time googling code even for trivial things. Copy and pasting isn’t inherently bad, but if you are copying and pasting code you should make sure you understand the code otherwise if it breaks you will struggle to fix it or it comes time to refactor you will run into bugs and/or break your program.
You should try to write it from scratch when you can because that is how you can remember it better. I have ADHD as well, what has helped me is when I come across something new, I understand it, try to optimize it if possible, and save it to a personal repo that has various source code for me to re-use or for reference.