Today I've solved another Codeforces round, with very disappointing results. That was even more disappointing given the fact that the problems were very nice (and they are always both in Russian and English there - no excuse for you not to participate in the next round on Friday :)), and I was able to see the solutions quickly.
Two of my five solutions failed. The first one, for problem B, had this bug (here's a link to full solution):
Line 36 must have " " instead of " ": this is an implementation of the tie-breaker which asks us for minimal value, not maximal value.
The second one, for problem E, had this bug (here's a link to full solution):
The condition in line 70 must be " " or " instead of " ". This code iterates over two sets of segments, and needs to advance one of the pointers based on which segment ends first. I've even had the correct condition with " " in the beginning, but has found that this would shift pointer b in case of a tie. For some reason, I've decided that it's better to shift a instead to be on the safe side (now I realize it doesn't matter) - but changed the code in such a way that it will always shift pointer a!
What do you think is the best way to find such bugs during the contest or to not make them in the first place? I used to do the latter automatically, it looks like I need to improve in this area.