#K65602. Sequence Query Processing

    ID: 32234 Type: Default 1000ms 256MiB

Sequence Query Processing

Sequence Query Processing

You are given a sequence of integers and tasked with processing a series of queries on this sequence. There are two types of queries:

  • Update Query: Format U i v, which updates the \(i\text{-th}\) element (1-indexed) of the sequence to the value \(v\).
  • Sum Query: Format S l r, which calculates the sum of the elements from index \(l\) to \(r\) (inclusive). In mathematical notation, compute \( \sum_{k=l}^{r} a_k \).

Process the queries in the given order and output the results for every sum query.

inputFormat

The input is provided via standard input (stdin) with the following format:

  1. An integer \(n\) representing the number of elements in the sequence.
  2. \(n\) space-separated integers denoting the initial sequence.
  3. An integer \(q\) representing the number of queries.
  4. \(q\) lines, each containing a query in one of the following two formats:
    • U i v — update query: set the \(i\text{-th}\) element of the sequence to \(v\).
    • S l r — sum query: output the sum of the elements from index \(l\) to \(r\) (inclusive).

outputFormat

For every sum query (queries starting with S), output the calculated sum on a new line to standard output (stdout).

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

14 24

</p>