Segment tree codeforces. Get started with a free trial.