Next Palindrome TLE

Problem Statement: PALIN Problem - CodeChef

I used the spoj wiki guide to write the code and testing out large values is giving pretty quick results(and correct according to me). However on submission I get TLE.

My Solution: CodeChef: Practical coding for everyone

Would really appreciate some help on pointing out whats wrong, including help on how accurate the code is.