I gained the most weight when I was eating a lot of potatoes and pasta and rice (and by "a lot" I mean I'd mash six potatoes or eat a whole box of rice mix for supper) because that was the cheapest food I could think of; meanwhile I was eating vegetarian at that time and I was getting my protein mostly from yogurt/cheese products, so that my diet amounted to high carbs and high fat. As a result even though I worked out pretty strenuously twice or more a week at Kung Fu class I was still gaining weight. Switching my diet by reducing the potatoes/pasta/rice and cheeses and substituting other foods helped.