I have deduced a logic to solve MYSARA problem. When implemented in Python3.6, the solution gave me TLE. But the same logic implemented in C, gave me AC. Please help me where the solution took more time in python.

Python is much slower than C. Even my solution did not get accepted in Python but got accepted in PyPy.

But the time limit is 5 seconds which is more than enough for given constraints. I doub’t the constraints mentioned are less when compared to the actual input file. I am seeking for help, to know faults in my logic

Python is slower than you think.For further optimizing your program, you can use modular exponentiation and count the no of set bits in (a&b).

My logic was different from it. When the same logic implemented in C ran in 0.17 seconds, why couldn’t Python do it in less than 5 seconds.

Coz, it’s obvious that if a C code runs with in 1 second, 5 seconds is enough for Python.

If at all the same solution ran faster in Python, My rank would have been so less coz, I wouldn’t have had penalty