#K89127. Array Processor

    ID: 37462 Type: Default 1000ms 256MiB

Array Processor

Array Processor

You are given an array of n integers. Your task is to perform q queries on the array. There are two types of queries:

  • Update Query: Change the value at a specific index.
  • Range Sum Query: Calculate the sum of a subarray from index l to r (both inclusive). Mathematically, for a query of the second type, you need to output \(\sum_{i=l}^{r}{a_i}\).

All indices are 1-indexed. Make sure your solution reads input from stdin and writes the output to stdout.

inputFormat

The input is given via stdin in the following format:

  1. The first line contains two integers n and q, representing the number of elements in the array and the number of queries, respectively.
  2. The second line contains n space-separated integers, representing the array.
  3. The following q lines each contain three integers op l r where op indicates the type of query. If op = 1, then update the element at index l to the new value r. If op = 2, then output the sum of elements from index l to r.

outputFormat

For each query of type 2, output the corresponding sum on a new line to stdout. If there are no sum queries, output nothing.

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

21 24

</p>