Good eating first but exercise plays a role in making you smarter.

Regular exercise can improve cognitive function.

This 2012 Canadian paper looked at a group of sedentary individuals and got the moving. 4 months of twice weekly exercise bike and intensive weight training made a difference. Cognitive function improved as well as their waist lines.