First you save in front of a PC and then you go and battle the Gym and its leader. When you finish, go and clone the pokemon that grew levels. When you turn your game back on you will be in the Pokemon center BEFORE you battled the leader but if you look in your PC you will find the Cloned Pokemon. Exchange the pokemon and save when you have your raised ones in your party then you can do it again.
Note: This trick will fill up your boxes so every three times you do this trick release the extra pokemon or switch boxes.