Wrong Answer in pairing question

Please check my code. I am getting WA in two test cases

Question : https://hack.codingblocks.com/app/practice/1/627/problem

Code : https://ide.codingblocks.com/s/284169

Mistake
in unite function

            par[superparent_x] = superparent_y;
            sz[superparent_y] += sz[superparent_x];
            sz[superparent_x] = 0;

you have to do this only if(superparent_x!=superparent_y)

Modified Code

i hope this helps
if yes hit a like and don’t forgot to mark doubt as resolved :grinning:
if you have more doubts regarding this feel free to ask