Wonderful world - MarisaOJ: Marisa Online Judge

Wonderful world

Time limit: 1000 ms
Memory limit: 500 MB
Marisa has given you a sequence of length $n$, with $m$ operations: 1. Decrease by $x$ the numbers greater than $x$ in the interval $[l,r]$. 2. Count the occurrences of $x$ in the interval $[l,r]$. ### Input The first line contains two integers $n,m$. The second line contains $n$ integers representing the sequence $a$. The next $m$ lines each contain four integers: - `1 l r x`: Decrease by $x$ the numbers greater than $x$ in the interval $[l,r]$. - `2 l r x`: Count the occurrences of $x$ in the interval $[l,r]$. ### Output For each query, output an integer representing the answer. ### Constraints - $1 \le l \le r \le n $ - $ x, n, m, a_i \le 10^5 $ ### Example Input ``` 5 6 1 5 5 5 8 2 2 5 5 1 2 4 3 2 2 5 2 2 2 5 5 1 3 5 1 2 1 5 1 ``` Output ``` 3 3 0 3 ```