It Is a very strange error. I have given max test cases each worst possible getting a runtime of 0.37 on ideone. The time limit is (1-2) still getting tle.One of the accepted solutions was run by me on the same test cases and my code was abt 2x faster for a test case(extreme). In the mail received from codechef my codes’ run time was given as 1.20 and status tle. The problem clearly specifies 1-2 sec.
What could be the problem? Please help me out if anybody knows the cause.I will provide the links of the codes if i get response.

Check your code for
999999000000 1000000000000

the approach you are using is taking time and that is causing you a TLE.
Solutions are available now try something else that runs faster.
If you want you can use this property—

view my solution —


Thanx laxman94 for answering. I ran my solution for the test code for your test case. Ran in 0.07 sec. even when 5 cases are given like this, it took 0.36 seconds.I have got tles before but this one baffles me.

Your code btw took 0.12 sec on ideone for the same case. <— Your code<— my code
The answer might be different. but why the tle.

If it isn,t giving the right answer then why are you trying to optimize it. First correct the solution then think of correcting it first…


And you are talking about your code hmm…
look at this when i tried fifty test cases -> <-my code was able to do in 2.74 sec.

and your code couldn’t even do it in 5 seconds, then i raised it to 15s it was able to do it in 5.34 seconds.->

And the input file these guyz are using is not something with 4-5 test cases.

About my code it took only 0.43 sec during the contest. Comparing with such a solution after checking for 2-3 inputs may sound insane according to me.


I thought when they specify the no of test cases, they are ->not<- being funny there. For test cases upto limit of five my code was feasible so i did that. Thanx a lot bro nyws!