339. Segments

Time limit per test: 2.25 second(s)
Memory limit: 65536 kilobytes
input: standard
output: standard



Consider a real axis and segments on it. You are to write a program that processes queries of two kinds.

Query '
+ L R
' adds a segment from point L to point R. You program should print the number of segments that are (non-strictly) inside the new one.

Query '
- L R
' removes one segment from point L to point R. If there is no such segment, ignore this query.

You may assume that no more than 1000 segments will present on the axis simultaneously.

Input
Each line of the input file contains one query. Query can be in the form '
- L R
' or '
+ L R
', where L and R are integers (-109L < R ≤ 109). There will be no more than 250 · 103 queries.

Output
Print to the output one line for each '
+ L R
' query, containing the number of segments inside the added segment.

Example(s)
sample input
sample output
+ 1 2
+ 1 2
+ 0 3
- 1 2
+ 1 2
0
1
2
1




Online Contester Team © 2002 - 2010. All rights reserved.