410814: GYM104120 D Denji
Description
Denji is trying to kill the algorithm demon. To kill him, Denji must perform this task.
An operation can be one of the following:
- Add a number to the end of the array.
- Delete from the array the number added in operation i.
- Add X to the number added in operation i.
- Print the number of smaller elements than the number added in operation i.
Unfortunately, Denji only knows how to use chainsaws, not computers, so he asked for your help to kill the algorithm demon.
InputThe first line of input contains an integer $$$M$$$ ($$$1$$$ $$$\leq$$$ $$$M$$$ $$$\leq$$$ $$$10^5$$$).
The following m lines describe the operations. The i-th of them begins with a number $$$type$$$ ($$$type$$$ $$$\in$$$ {1,2,3,4}), which will represent the type of the operation given.
If $$$type$$$ = 1, there will be one more integer in the line: $$$A$$$ (1 $$$\leq$$$ $$$A$$$ $$$\leq$$$ $$$10^9$$$), which correspond the operation 1.
If $$$type$$$ = 2, there will be one more integer in the line: $$$B$$$ (1 $$$\leq$$$ $$$B$$$ $$$<$$$ $$$i$$$), which correspond the operation 2. It is guaranteed that the number added in operation $$$B$$$ is still in the array.
If $$$type = 3$$$, there will be two integers more in the line: $$$B$$$, $$$A$$$ (1 $$$\leq$$$ $$$B$$$ $$$<$$$ $$$i$$$; 1 $$$\leq$$$ $$$A$$$ $$$\leq$$$ $$$10^9$$$), which correspond the operation 3. It is guaranteed that the number added in operation $$$B$$$ is still in the array.
If $$$type$$$ = 4, there will be one more integer in the line: $$$B$$$ (1 $$$\leq$$$ $$$B$$$ $$$<$$$ $$$i$$$), which correspond the operation 4. It is guaranteed that the number added in operation $$$B$$$ is still in the array.
It is guaranteed that the first operation is of type 1.
OutputFor each operation 4, please print a line containing the answer.
ExamplesInput5 1 4 1 5 1 4 4 2 4 3Output
2 0Input
9 1 5 1 5 1 10 4 3 2 2 4 3 3 3 7 4 3 4 1Output
2 1 1 0