#C14017. Cumulative Sum Column Addition

    ID: 43620 Type: Default 1000ms 256MiB

Cumulative Sum Column Addition

Cumulative Sum Column Addition

You are given a CSV input from standard input. The CSV contains a single column named A in its header, followed by one or more lines each containing an integer value.

Your task is to compute a new column B where each value is the cumulative sum of the values in column A up to that point. The result should be printed to standard output in CSV format with the header A,B followed by the computed rows.

Note: Use LaTeX formatting for any mathematical expressions if needed (e.g., the cumulative sum can be represented as \(B_i = \sum_{j=1}^{i} A_j\)).

inputFormat

The input is provided via standard input. The first line contains the header "A". Each subsequent line contains a single integer which represents a value in column A.

Example:

A
1
2
3
4
5

outputFormat

The output should be printed to standard output in CSV format. The first line must be the header "A,B". Each following line should contain the original integer from column A and its corresponding cumulative sum in column B, separated by a comma.

Example output corresponding to the input above:

A,B
1,1
2,3
3,6
4,10
5,15
## sample
A
1
2
3
4
5
A,B

1,1 2,3 3,6 4,10 5,15

</p>