Here is my AC code: https://hastebin.com/ewobuzater.cpp
It uses offline BIT + sorting.
Here is the strange thing: que[200001] works perfectly fine, but if you change it to que[200000] it will segfault. However, it is zero based indexing and q is at max 200000.
Can anyone think of a case where que[200000] faces out of bound access?