CODE:ZUBSPOIL ,How to get rid of TLE ,this code has no error even it ran

code is running good even with custom input code is running good but when i submit i got this time excess error please help me

Try optimizing your code that is the only way to get through TLE test cases if your code is not wrong