I recently started practising 5-hour contests with my ICPC team. I've noticed that I get really tired after about 2.5 hours of contest. My problem-solving abilities decline significantly, my body and my head ache a bit, and I have a significant loss of motivation. I can't think straight. I feel hungry. After about 3.5 hours, I'm pretty much useless. After about 4-4.5 hours, I start feeling a bit dizzy too. I've faced issues with my stamina in contests multiple times during the past year, but recently realised how bad it really is, during the team contests. I have noticed that I don't feel this way while solving problems leisurely, but only under the time and performance pressure of a contest.
I'm fairly accustomed with the two-hour contest format on Codeforces and face almost no issues during it. I'm worried, and unsure how to train myself to get optimal performance in 5-hour contests. I plan on trying two things: running, and giving a lot of 5-hour contests.
I'm pretty unfit (not overweight, but unfit). I feel some sort of physical activity like running on a regular basis may help me improve my stamina during contests too. Not sure how effective it shall be. Also, logically, if I give enough 5-hour contests on a regular basis, my body and mind should eventually adapt, somehow, to perform optimally in them.
It would help a lot if you have any suggestions, or any ideas to help me overcome it, or if you or some friend of yours have faced similar issues in the past and have overcomed it, or are trying to overcome it. Anything.