Https://www.codechef.com/viewsolution/34770932

https://www.codechef.com/viewsolution/34770932

can i know where i am going wrong please??
how can my code work for small constraints and when it comes to large constraint it cant??