Partial sums

Given an array A[0..n1]A[0 ~..~ n-1] and an index ii, the ii-th partial sum of AA is 0jiA[j]\sum_{0\le j\le i} A[j]. Here, you have to implement a data structure to efficiently compute partial sums. The operations you must consider are the creation of an array with all its values initialized to zero, the modification of a value, and the query of a partial sum.

Input

Input consists of a non-empty sequence of commands. Every command begins with a letter to identify it, followed by one or two integer-number parameters. These are the possible commands:

In general, there are much more set and get commands than reset commands. The first command is always a reset.

Output

For each get command, print the corresponding partial sum. Print the output corresponding to each reset command on a unique line, separated by spaces.

Problem information

Author: Jordi Petit

Generation: 2026-01-25T11:35:07.529Z

© Jutge.org, 2006–2026.
https://jutge.org