How to find the count of elements in a given range ( l, r ) in an array whose value is <= k where k is a given value? I have found the solutions using BIT and square root decomposition. Can anyone provide a code using segment trees? There are number of queries and in each query the value of k changes.

This question is from https://codeforces.com/blog/entry/22893

I was unable to understand. Can anyone help me?

Assume that there are no updates.