Can anyone tell me why this submission is so slow? 275858049
It's $$$\mathcal{O}(N + Q)$$$ and should be very fast, but somehow it takes 1125 ms.
Meanwhile my in-contest code that uses lots of sets and does a bunch of nonsense only takes 561 ms: 275858229