#C1713. Sequence Operations

    ID: 44949 Type: Default 1000ms 256MiB

Sequence Operations

Sequence Operations

You are given an array of integers and a list of operations to perform on this array. There are two types of operations:

  1. Update Operation (U): U X Y – Update the element at index X to Y.
  2. Sum Operation (S): S X Y – Compute the sum of the subarray from index X to Y (inclusive). Formally, you need to compute \[ \sum_{i=X}^{Y} a_i \] where \(a_i\) represents the element at the \(i^{th}\) index.

All indices are 0-based. Your task is to process the operations in the given order and output the result of every sum operation. Note that update operations do not produce an output.

inputFormat

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

  • The first line contains an integer n, the size of the array.
  • The second line contains n space-separated integers representing the elements of the array.
  • The third line contains an integer m, the number of operations.
  • The following m lines each contain an operation in the format U X Y or S X Y.

outputFormat

For each sum operation, output the computed sum on a new line (via standard output, stdout). Update operations produce no output.

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

14 22

</p>