What is wrong in my code of problem RICHSTr

What is wrong in my solution for following problem

Problem : https://www.codechef.com/problems/RICHSTR

Solution : https://www.codechef.com/viewsolution/26144871