Getting WA in rotation

Can anyone please help me?? Whats wrong with the code here!

This is my accepted code in C++: http://www.codechef.com/viewsolution/4838669

And this one is the one where I was getting WA: http://www.codechef.com/viewsolution/4838736

//