>>24856996 (OP)
If you eat more calories than you burn you will have a caloric surplus, that is converted in part to fat stores.
About 20% of your daily calorie requirements go to feeding your mind with nutrients which is a very high ratio for an animal. That said, studies trying to nail down extra calorie burn from thinking hard were deeply flawed and more likely just capture the extra burn from stress (chess tournaments), increased heart rate. The measurements aren’t good to begin with. Virtually all diet related research is trash because of the difficulty of actually controlling and observing the study groups. Military and prisoner cohorts are good for control but bad in other ways.