#C8928. Event Counter

    ID: 52964 Type: Default 1000ms 256MiB

Event Counter

Event Counter

Design a data structure that supports adding events and counting the number of events within a specified time interval. The data structure should support the following two operations:

  • ADD t: Add an event occurring at time \(t\).
  • COUNT s e: Count the number of events that occurred within the inclusive time interval \([s, e]\).

You will be given \(q\) queries. Process these queries in the order they are given. For every COUNT query, output the result on a new line.

inputFormat

The input begins with an integer \(q\) representing the number of queries. Each of the following \(q\) lines is a query, which can be one of the following two types:

  • ADD t: Add an event that occurs at time \(t\), where \(t\) is an integer.
  • COUNT s e: Query the number of events with timestamps in the interval from \(s\) to \(e\) (inclusive), where \(s\) and \(e\) are integers.

outputFormat

For each COUNT query, output a single integer on a new line representing the number of events that occurred within the specified interval \([s, e]\).

## sample
5
ADD 5
ADD 10
ADD 15
COUNT 5 15
COUNT 10 20
3

2

</p>