I read the editorial and tried to implement the same in my code but I am getting TLE. Please help me find out the error and suggest any optimizations.(Tried my submission on my local compiler on a randomly generated test file with worst case inputs and it is taking 6 seconds to compute).
http://mirror.codeforces.com/contest/888/submission/32207497








