PALIN  The Next Palindrome
A positive integer is called a palindrome if its representation in the decimal system is the same when read from left to right and from right to left. For a given positive integer K of not more than 1000000 digits, write the value of the smallest palindrome larger than K to output. Numbers are always displayed without leading zeros.
Input
The first line contains integer t, the number of test cases. Integers K are given in the next t lines.
Output
For each K, output the smallest palindrome larger than K.
Example
Input: 2 808 2133 Output: 818 2222
Warning: large Input/Output data, be careful with certain languages
hide comments
David Winiecki:
20180409 08:10:24
Don't assume every line ends in a newline. I had to add logic like "if last character of input read from this line is not a number, then remove it (decrement length), else do nothing (don't decrement length)". Took me a very long time to figure that out. Extremely frustrating. :/ 

ashutoshiiita:
20180330 18:04:55
TLE on using boost library of C++ why?? 

prabhakar2050:
20180327 13:32:57
@Piotrek Nicowski Thanks :D 

Piotrek Nicowski:
20180323 20:39:46
@prabhakar2050  For each K, output the smallest palindrome *** LARGER THAN *** K.


prabhakar2050:
20180317 20:26:29
isnt 808 a palindrome? In the test case, it isnt. but on the net it clearly mentions its a palindrome. What should i do?


techymj:
20180313 05:43:21
m new on spoj..can anyone tell me ..how I can check that on which test case my code is not accepted 

kkislay20:
20180308 12:55:47
Attention should be given that there could 1000000 digits in a number. 

manos_l98:
20180304 14:19:15
I write this program with c++ and I get abort error because I use stoull can someone tell me how to fix it? 

pigpork:
20180304 03:33:33
Can we use arrays? 

ani_mahajan:
20180228 20:06:24
Can someone tell me that what would be output if input > 1000000 . 
Added by:  adrian 
Date:  20040501 
Time limit:  2s9s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: NODEJS PERL6 