For what I've experienced, the best thing to stay focused and clear-headed on learning time is keto diet.
I can stay quiet on my chair at school all day without feeling sleepy.
At home, going to bed early, have a complete night of sleep helps a lot and if needed I would allow myself a short nap during the day.
As Starshine said, We are completely addicted to coffee and I can no longer feel the effect of caffeine during the day.
I drink approximately 6 short black a day (not strong though), including one after dinner and I fall asleep in a minute when I go to bed. My sleep is agitated though...
Anyway, I don't think that coffee helps me to focus and for memory.
I am also addicted to strong dark chocolate but I try to keep it reasonable and I don't feel like my brain works better with it. It just brings me a reassuring feeling which may be due to the small amount of sugar in it.
It is probably better to have a good diet, good sleep, allow yourself some short times off regularly and breath
Good luck with maths!