Time limit exceeded

as i wrote same code which is wrote by prateek sir but compiler gave me a time exceeded limit .so what i have to do pls reply.

check once again properly and still if doesnt work send the code on ide.codingblocks.com