Need held to understand my mistake (HDDN)

Hi,

Here is my python3 program : https://www.codechef.com/viewsolution/27510260

I tried it on some tests cases I created and it was correct each time, I would be grateful if someone give me some test case where my solution is incorrect, or just explain me where is my mistake.

Thanks

Closed as requested by user.