MY CODE GIVES ALL TLE AND 1 RIGHT ANS

Here is my code https://ide.codingblocks.com/s/267128

please refer tothis
for explanation

https://ide.codingblocks.com/s/57850