Python solution of ACCBIP

I tried solving ACCBIP(https://www.codechef.com/problems/ACCBIPACCBIP) in python. I used the similar approach mentioned in editorial and similar to what majority have done in their codes using c++.
Here is my solution : https://www.codechef.com/viewsolution/36861662
It would really be helpful if anyone could help me in understanding , is it python or me who is to be blamed ?

PyPy 3
PyPy 3 with fast i/o
You need just a little more optimizations.

Thank you so much.
Later I saw this solution https://www.codechef.com/viewsolution/36806976
and got to know about the optimization required. Thanks again !!