help in remember the recipe practice(easy) twstr

Please can anyone help me in finding the possible reason of my solution getting tle?
http://www.codechef.com/viewsolution/6573074