I tried to solve this problem but for some reason the C++ compiler calculates power of 26 raised to 1 as 25 and I am getting wrong answer! Here is the submission link. http://codeforces.com/contest/1/submission/14859704 Any corrections to the code are appreciated. Also, if there are any internal compiler error, please let me know! I also checked the same code on Ideone.com and it works correctly there!