What is wrong in my code of problem RICHSTr

What is wrong in my solution for following problem

Problem : RICHSTR Problem - CodeChef

Solution : CodeChef: Practical coding for everyone