#C3290. Taco Query Processor

    ID: 46701 Type: Default 1000ms 256MiB

Taco Query Processor

Taco Query Processor

You are given an array of N integers and you need to process M queries. There are two types of queries:

  • Type 1: Update query of the form 1 i x, which sets the element at position i to x.
  • Type 2: Sum query of the form 2 l r, where you need to compute the sum of the subarray from index l to r (inclusive). In mathematical notation, you need to compute $$\sum_{i=l}^{r} a_i$$ where \(a_i\) represents the element at index \(i\).

Note that the array indices in the input are 1-indexed.

inputFormat

The first line of input contains two integers N and M separated by a space, representing the number of elements in the array and the number of queries respectively.

The second line contains N space-separated integers representing the initial array.

Each of the following M lines contains a query. A query is in one of the following two formats:

  • 1 i x: Update the element at position i to value x.
  • 2 l r: Print the sum of elements from index l to r (inclusive).

outputFormat

For each query of type 2, output a single line containing the sum of the subarray from index l to r.

## sample
5 5
5 3 6 2 1
2 1 3
1 2 8
2 2 4
1 5 10
2 1 5
14

16 31

</p>