I am trying to solve Electoral Rolls Revision in the IARCS archive. However, when I input testcases 8 to 10, I get an abrupt segmentation fault, which I'm unable to debug. Also testcases 4 and 5 seem damaged and testcase 10 has B == 600, which is against the given constraints of B <= 500.
Can anyone double check so that I know whether my code is faulty or not. Here is my code for record. Thanks!