Memory usage difference in "PLZLYKME"

I submitted two solutions to this problem here . The only difference between them was the place where I declared the variables being used inside the outer while loop . It caused a difference in the memory used up by the program . Can somebody please explain why this is so , and also which method is a "better practice " (considering the fact that I am new to programming :P) ?