#K95592. Inventory Range Query

    ID: 38897 Type: Default 1000ms 256MiB

Inventory Range Query

Inventory Range Query

You are given an inventory management system that supports two types of operations:

  • add productId quantity: Adds the given quantity of the product identified by productId to the inventory.
  • query startProductId endProductId: Returns the sum of the quantities of all products whose product IDs lie in the inclusive range [\(startProductId,\; endProductId\)].

Your task is to implement this system. For each query operation, output the total quantity in the specified range. The operations will be provided via standard input.

Note: It is guaranteed that the number of operations is manageable and product IDs in the test cases will be in a reasonable range.

inputFormat

The first line contains an integer \(n\) representing the number of operations. Each of the following \(n\) lines contains an operation in one of the following formats:

  • add productId quantity
  • query startProductId endProductId

All inputs are read from standard input.

outputFormat

For each query operation, output a single line containing the computed total quantity. All outputs should be written to standard output.

## sample
5
add 101 5
add 102 10
query 100 200
add 101 10
query 100 102
15

25

</p>