My code works for test cases but is wrong during submission

https://www.codechef.com/viewsolution/44884488
this is my solution kindly help me out.

On my machine, it fails on the Example Input:

echo "3
> 3
> 2 3 2
> 10 3 4
> 4
> 7 5 3 4
> 2 3 1 3
> 2
> 10 1
> 1 10"  | ./prerak_g1890-FASTFOOD.py
17
18
20
1 Like