Diet >> Gym
You burn a lot of calories in a day, the extra little you burn from exercise is moot if you are scoffing down the wrong food.
However, I'm going to nitpick and say that you're wrong about the gym. Currently, I burn about 1,000 calories on each trip to the gym, every other day. That's a 500 calorie deficit that I'm adding each day. In addition, my body is using additional calories to rebuild muscle, and the additional muscle is consuming calories to maintain itself. It's kind of like compounding interest.