Here is link to my code- http://www.codechef.com/viewsolution/2174509
I guess for inputs like 9999000 10000000, the program didn't run due to the size limit of the array, as one "hey" is being printed and the next to the array declaration is not! Please do help..