Needed help why the code in Python did not pass. Same code worked for C++ thing.
Problem: https://mirror.codeforces.com/contest/2070/problem/C
C++ Submission after contest: https://mirror.codeforces.com/contest/2070/submission/308176980
Python Submission within contest: https://mirror.codeforces.com/contest/2070/submission/308170127
Followup: Should I switch to C++ language.








Python does about $$$10^6$$$ operations per second. As far as I understand, this problem requires more operations to solve, so Python gets TL. c does about $$$10^8$$$ operations per second, so this solution works on it. In fact, you should relearn from Python to C as soon as possible, because Python won't get you very far.
Surprisingly, it is the sorting that slows things down. Here is a solution with a similar strategy, but only requiring binary search and no calls to sort. It runs in 600ms (https://mirror.codeforces.com/contest/2070/submission/309429259).
But, if I add in the 2 sort calls, it times out (https://mirror.codeforces.com/contest/2070/submission/309429603).