#C10828. Array Query Processor

    ID: 40076 Type: Default 1000ms 256MiB

Array Query Processor

Array Query Processor

You are given an array of positive integers of length \( n \) and \( q \) queries. You need to perform two types of queries:

  • Type 1: 1 p x — Update the \( p\)-th element of the array to \( x \). Here, \( 1 \le p \le n \) and \( x \) is a positive integer.
  • Type 2: 2 l r — Compute the sum of the subarray from index \( l \) to \( r \) (inclusive). It is guaranteed that \( 1 \le l \le r \le n \).

The array is 1-indexed. For every query of the second type, the program should output the sum corresponding to the query. All formulas are provided in \( \LaTeX \) format.

The update and query operations should be processed in the order they are given.

inputFormat

The first line contains two space-separated integers \( n \) and \( q \), representing the length of the array and the number of queries, respectively.

The second line contains \( n \) space-separated positive integers, representing the elements of the array.

The following \( q \) lines each describe a query. Each query is in one of the following two formats:

  • 1 p x — Update the element at position \( p \) to \( x \).
  • 2 l r — Output the sum of the subarray from index \( l \) to \( r \).

All input is read from standard input (stdin).

outputFormat

For each query of type 2, output a single line containing the sum of the specified subarray.

All output should be written to standard output (stdout).

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

16 37

</p>