Dr. Caroline Leaf, author of Who Switched Off My Brain?, knows a thing or two about brain function. After all, she is a learning specialist.
According to Dr. Leaf, "Fluidity of memory comes literally from sufficient water in the brain. Water speeds up brain function. When the brain dehydrates, it releases cortisol, a hormone that shrinks dendrites, the tree-like branches in the brain that store information and create memory."
In other words, drinking water will keep you from acting like a dumbass (in the literal sense). So how much water should you drink? As much as possible, especially if you're thirsty. Shoot for 3 liters and go from there.
As for that soda in your hand right now, that's only dehydrating you. If you were to drink more water you'd probably be smarter than that.