So I wanted to see if it was possible to solve this problem 160-E with a sparse segment tree 2D. I made this implementation (because I didn't find any) 386015499. Unfortunately, it passes in approx 1200 ms and 80 MB (the best it did was 1031 ms with iterative queries).
Anyways, I'm sharing the implementation 386021321 (slower but more general) in case anyone finds it useful, it allows queries and point updates in $$$O(log^2 n)$$$ with the preprocessing of all the intervals in $$$O(n \ log \ n)$$$. It is possible to make some optimizations but it should pass under 2 seconds.
UPD: I managed to get AC with some optimizations 386153449 :)








Auto comment: topic has been updated by Kener_Castillo (previous revision, new revision, compare).