Thanks a lot for the help TSny! Doing that gives the correct answer.Sounds right. Final PE = mg(y+dy).
But I am still confused on the signs. Sorry this is going to be dumb but why not replace every dL with (-dL)?
Also, you said that this problem is a well-known example of "adiabatic invariant" in mechanics. Do you know of any book which deals with this?