#K5496. Sum of Corresponding Elements in Tuples

    ID: 29869 Type: Default 1000ms 256MiB

Sum of Corresponding Elements in Tuples

Sum of Corresponding Elements in Tuples

You are given a list of tuples, where each tuple contains integers and all tuples have the same length. Your task is to compute the element-wise sum of these tuples. In other words, for each column of numbers in the input tuples, add all the numbers together and output the result as a list.

Note: If the list is empty, output an empty result.

Formally, let \(T = [t_1, t_2, \ldots, t_n]\) be a list where each tuple \(t_i = (a_{i,1}, a_{i,2}, \ldots, a_{i,m})\). You need to compute a list \(S = [s_1, s_2, \ldots, s_m]\) where \(s_j = \sum_{i=1}^{n} a_{i,j}\) for \(1 \leq j \leq m\).

inputFormat

The input is read from standard input and is formatted as follows:

  1. The first line contains a single integer \(n\) representing the number of tuples.
  2. Each of the next \(n\) lines contains space-separated integers representing a tuple. All tuples have the same number of integers.

If \(n = 0\), it means the list of tuples is empty.

outputFormat

Print a single line to standard output containing the element-wise summed tuple. Print the integers separated by a single space. If the list is empty, output an empty line.

## sample
1
1 2
1 2