#K14936. Distinct Elements Tracker
Distinct Elements Tracker
Distinct Elements Tracker
You are given a sequence of operations to perform on a list. The operations are defined as follows:
- 1 x: Insert the integer \(x\) into the list.
- 2 x: Remove one occurrence of the integer \(x\) from the list. If \(x\) is not present, ignore the operation.
- 3: Output the current number of distinct integers in the list.
The operations are executed sequentially. For every operation of type 3, you must output the number of distinct elements currently in the list. Formally, if we denote the number of distinct elements by \(d\), then for each query (operation 3) you should output the value of \(d\).
It is guaranteed that the input format is valid and that the operations are performed correctly.
inputFormat
The first line of input contains a single integer \(n\) --- the number of operations.
The following \(n\) lines each represent an operation. The format of an operation is one of the following:
1 x
--- Insert the integer \(x\) into the list.2 x
--- Remove one occurrence of the integer \(x\) from the list.3
--- Output the number of distinct integers currently in the list.
All operations are given via stdin.
outputFormat
For each operation of type 3, output the number of distinct integers currently in the list on a new line. The outputs should be printed to stdout.
## sample6
1 4
1 4
1 2
3
2 4
3
2
2
</p>