During Codeforces Round 966 Div.3, I was writing a solution to problem B. During the contest, I had come up with this code: https://ide.usaco.guide/O4IVEpEkaUruFQ_sq5c.
However, it gave me a "YES" for the fourth subcase in the sample test case. I searched everywhere in the code for what might be giving an answer like this, but I found nothing.
To fix this, I tried what seemed like a completely arbitrary thing: create a vector of the bus seatings beforehand, then figure out if the seating is valid. To my complete surprise, this worked, as can be seen in this submission: https://codeforces.me/contest/2000/submission/276167020.
I still can't identify what the major difference between the two codes is, so I was wondering if anybody could help me find the error.