Comments

If a selected teams fails to register or pay fees by the given deadline, that team slot would be given to the team at the top of the waiting list.

Friendly remainder: s=s+b not equal to s+=b

ratings are not updated till now..

i ran your code on codeforces compiler and it shows wrong output for the given input in the question. i will updtae this when i find the error.

is there any division 3 contest?

i should have joined the tournament