Comments

Thank you.

Can you explain the check function, please? I have been tried to understand others' code, but failed to do it.

nice solution!

Problem C

After all operations, for all x, add $$$m − appear_x$$$ to $$$count_x$$$ if $$$appear_x$$$ is not −1.

Shouldn't it be $$$m + 1 - appear_x$$$ ?!! I have been confused about it for hours!