NZEC Error in ANKTRAIN

Can anyone please help me …
I am getting NZEC Error in ANKTRAIN problem…
my solution is implemented in Python 3.6

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

I ran your code on the following input:

10
1
2
3
4
5
6
7
8
9
10

and got six lines of output and an error on the 7th. Looking through, this would be due to t=8.

@joffan
Thank you very much.