As you know I've just solved 2020D with a solution I came up with that's more readable and probably more efficient than the one in the editorial.
So, for each step size max_d (or just fix it at 10), remember how far each operation connects. Then merge intervals with some simple greedy then use DSU to find number of connected opponents
Anyways here's my code 400436229
The solution runs in $$$O(M+10\times N\times \alpha (N))$$$ Where $$$\alpha$$$ is the inverse Ackermann function (3-4 for $$$N=10^6$$$)



