problem with fast I/O

for the question http://www.codechef.com/problems/LUCKYSTR

the same solution with fast I/O functions is giving runtime error but with cin and cout showint AC. Can any one point the reason? here is my solution
http://www.codechef.com/viewsolution/6491542