#K39392. Library Book Management

    ID: 26410 Type: Default 1000ms 256MiB

Library Book Management

Library Book Management

You are given a library management system that starts with an empty collection of unique books. Each book is identified by a unique integer. The system supports two operations: Add x and TotalBooks l r.

  • Add x: Adds a book with identifier \(x\) to the collection. If the book already exists, it should not be added again.
  • TotalBooks l r: Returns the total number of unique books with identifiers in the range \(l \le x \le r\).

You will be given a sequence of queries. Process the queries in the order given, and for each TotalBooks query, output the count of unique books in the specified range.

inputFormat

The first line contains an integer (Q), the number of queries. Each of the following (Q) lines contains a query in one of the following formats:

  • Add x where \(x\) is an integer.
  • TotalBooks l r where \(l\) and \(r\) are integers (with \(l \le r\)).

It is guaranteed that all queries are valid.

outputFormat

For each TotalBooks query, output a single line containing the count of unique books in the range ([l, r]).## sample

6
Add 3
Add 5
Add 8
TotalBooks 1 5
Add 5
TotalBooks 4 8
2

2

</p>