#C4503. Candy Bags Query Manager

    ID: 48049 Type: Default 1000ms 256MiB

Candy Bags Query Manager

Candy Bags Query Manager

You are given n empty candy bags numbered from 1 to n. Your task is to process q operations. There are two types of operations:

  • Type 1: 1 i v — Add v candies to the i-th bag.
  • Type 2: 2 i j — Query the total number of candies in the bags from index i to j (inclusive).

For a query operation, you need to output the sum of candies defined as \[ S = \sum_{k=i}^{j} a_k \] where \(a_k\) is the number of candies in the k-th bag.

Read from standard input and print the result for each query operation to standard output.

inputFormat

The first line contains two integers n and q — the number of candy bags and the number of operations.

The following q lines each represent an operation. Each operation is given in one of the following two formats:

  • 1 i v — Add v candies to bag i.
  • 2 i j — Output the sum of candies from bag i to bag j (inclusive).

Note: The bags are 1-indexed.

outputFormat

For each query operation (operation type 2), output the result on a new line. No output is required for addition operations.

## sample
5 4
1 3 10
2 2 4
1 2 5
2 1 3
10

15

</p>