#C11772. Student Number Operations

    ID: 41125 Type: Default 1000ms 256MiB

Student Number Operations

Student Number Operations

You are given n students with initial numbers 0, 1, 2, \(\ldots, n-1\). You need to perform a series of operations on these numbers.

Each operation is one of the following:

  • U i x: Update the number at index \(i\) to \(x\).
  • Q l r: Query and output the sum of numbers from index \(l\) to \(r\) (inclusive).

The initial array is defined as \(a_i = i\) for \(0 \leq i < n\). Process the operations in the given order.

Input/Output: Read from standard input (stdin) and write to standard output (stdout).

inputFormat

The first line contains two integers \(n\) and \(m\), the number of students and the number of operations respectively.

The next \(m\) lines each contain an operation in one of the following formats:

  • U i x : update the value at index \(i\) to \(x\).
  • Q l r : query the sum of the values from index \(l\) to \(r\) (inclusive).

outputFormat

For each query operation Q l r, output a single line containing the sum of numbers from index l to r.

## sample
10 5
Q 1 3
U 2 5
U 3 10
Q 1 3
Q 2 4
6

16 19

</p>