Given an array of integers of length N and an integer K. We have to answer N queries. Each query consist of some range [L, R]. In each query We have to decrease the value of the array elements in this range by 1 and answer how many integers in the range [j, N] is less than or equal to K (where j is the query number we are currently answering).

Note that the values that we subtract in ith query will be reflected in all the further queries also.

Constraints: K <= N<= 10^5

This question is asked during interview and it can be solved within N(logN)^2 complexity.

@l_returns @anon55659401 @aryanc403 please help!