Problem:


Spreadsheet

  Your task is to perform a simple table calculation.

  Write a program which reads the number of rows r, columns c and a table of r &times; c elements, and prints a new table, which includes the total sum for each row and column. 

Input

  In the first line, two integers r and c are given. Next, the table is given by r lines, each of which consists of c integers separated by space characters.

Output

  Print the new table of (r+1) &times; (c+1) elements. Put a single space character between adjacent elements. For each row, print the sum of it's elements in the last column. For each column, print the sum of it's elements in the last row. Print the total sum of the elements at the bottom right corner of the table.

Constraints

 1 ≤ r, c ≤ 100

 0 ≤ an element of the table ≤ 100

Sample Input

4 5
1 1 3 4 5
2 2 2 4 5
3 3 0 1 1
2 3 4 4 6

Sample Output

1 1 3 4 5 14
2 2 2 4 5 15
3 3 0 1 1 8
2 3 4 4 6 19
8 9 9 13 17 56



Sample input:
4 5
1 1 3 4 5
2 2 2 4 5
3 3 0 1 1
2 3 4 4 6


Sample output:
1 1 3 4 5 14
2 2 2 4 5 15
3 3 0 1 1 8
2 3 4 4 6 19
8 9 9 13 17 56

Submission status: Runtime Error

Solution code:
r, c = [int(i) for i in input().split]

data = []
sum_row = [0] * (c + 1)

for ri in range(r):
    data.append([int(i) for i in input().split()])
    data[ri].append(sum(data[ri]))
    print(" ".join([str(d) for d in data[ri]]))
    for ci in range(c * 1):
        sum_row[ci] += data[ri][ci]

print(" ".join([str(s) for s in sum_row]))

from pprint import pprint
pprint(data)
pprint(sum_row)

Submission status: Runtime Error

Solution code:
r, c = [int(i) for i in input().split()]

data = []
sum_row = [0] * (c + 1)

for ri in range(r):
    data.append([int(i) for i in input().split()])
    data[ri].append(sum(data[ri]))
    print(" ".join(data[ri]))
    for ci in range(c + 1):
        sum_row[ci] += data[ri][ci]

print(" ".join([str(s) for s in sum_row]))

Submission status: Runtime Error

Solution code:
r, c = [int(i) for i in input().split()]

data = []
sum_row = [0] * (c + 1)

for ri in range(r):
    data.append([int(i) for i in input().sprit()])
    data[ri].append(sum(data[ri]))
    print(" ".join([str(d) for d in data[ri]]))
    for ci in range(c + 1):
        sum_row[ci] += data[ri][ci]
        
print(" ".join([str(s) for s in sum_row]))

Submission status: Runtime Error

Solution code:
r, c = [int(i) for i in input().split()]

data = []
sum_row = [0] * (c + 1)

for ri in range(r):
    data[ri].append([int(i) for i in input().split()])
    data[ri].append(sum(data[ri]))
    print(" ".join([str(d) for d in data[ri]]))
    for ci in range(c + 1):
        sum_row[ci] += data[ri][ci]
print(" ".join([str(s) for s in sum_row]))

Submission status: Runtime Error

Solution code:
r, c = [int(i) for i in input().split()]

data = []
sum_row = [0] * (c + 1)

for ri in range(r):
    data.append([int(i) for i in input().split()])
    data[ri].append(sum(data[ri]))
    print(" ".join([str(d) for d in data[ri]]))
    for ci in range(c + 1):
        sum_row[ci] += data[ri][ci]

print(" ".join([str(s) for d in sum_row]))

Submission status: Runtime Error

Solution code:
r, c = [int(i) for i in input().split()]

data = []
sum_row =[0] * (c + 1)

for ri in range(r):
    data[ri].append([int(i) for i in input().split()])
    data[ri].append(sum(data[ri]))
    print(" ".join([str(d) for d in data[ri]]))
    for ci in range(c + 1):
        sum_row[ci] += data[ri] [ci]

print(" ".join)

from pprint import pprint
pprint(data)
pprint(sum_row)

Submission status: Runtime Error

Solution code:
r, c = [int(i) for i in input().split()]

data = []
sum_row = [0] * (c + 1)

for ri in range(r):
    data[ri].append([int(i) for i in input().split()])
    data[ri].append(sum(data[ri]))
    print(" ".join([str(d) for d in data[ri]]))
    for ci in range(c + 1):
        sum_row[ci] += data[ri] [ci]
print(" ".join([str(s) for s in sum_row]))

Submission status: Runtime Error

Solution code:
r, c = [int(i) for i in input().split()]

data = []
sum_row = [0] * (c + 1)

for ri in range(r):
    data[ri].append([int(i) for i in input().split()])
    data[ri].append(sum(data[ri]))
    print(" ".join([str(d) for d in data[ri]]))
    for ci in range(c + 1):
        sum_row[ci] += data[ri] [ci]
print(" ".join([str(s) for s in sum_row]))

from pprint import pprint
pprint(data)
pprint(sum_row)

Submission status: Runtime Error

Solution code:
r, c = [int(i) for i in input().split()]

data = []
sum_row = [0] * (c + 1)

for ri in range(r):
    data.append([int(i) for i in input.split()])
    data[ri].append(sum(data[ri]))
    print(" ",join(data[str(d) for d in data[ri]]))
    for ci in renge(c + 1):
        sum_row[ci] += data[ri][ci]

print(" ".join([str(s)for s in sum_row]))

Submission status: Runtime Error

Solution code:
 r, c = [int(i) for i in input().split()]

data = []
sum_row = [0] * (c + 1)

for ri in range(r):
    data.append([int(i) for i in input().split()])
    data[ri].append(sum(data[ri]))
    print(" ".join([str(d) for d in data[ri]]))
    for ci in range(c + 1):
        sum_row[ci] += data[ri][ci]

print(" ".join([str(s) for s in sum_row]))

Submission status: Runtime Error

Solution code:
r, c = [int(i) for i in input().splist()]

data = []
sum_row = [0] * (c + 1)

for ri range(r)i
    data.append([int(i) for i in input().splist()])
    data[ri].append(sum(data[ri]))
    print(" ".join([str(d) for d in data[ri]]))
    for ci in range(c + 1):
        sum_row[ci] += data[ri][ci]
        
print(" ".join([str(s) for s in sum_row]))

Submission status: Runtime Error

Solution code:
r, c = [int(i) for i in input().split()]

data = []
sum_row = [0] * (c + 1)
for ri in range(r):
    data.append([int(i) for i in input().split()])
    data[ri].append(sum(data[ri]))
    print(" ".join(str[d] for d in data[ri]))
    for ci in range(c + 1):
        sum_row[ci] += data[ri][ci]

print(" ".join([str(s) for s in sum_row]))

Submission status: Runtime Error

Solution code:
r, c = [int(i) for i in input().split()]

data = []
sum_row = [0] * (c + 1)

for ri in range(r):
    data.append([int(i) for i in input().split()])
    data[ri].append(sum(data[ri]))
    print("".join(data[ri]))
   for ci in range(c + 1):
        sum_row[ci] += data[ri][ci]


from pprint import pprint
pprint(data)
pprint(sum_row)

Submission status: Runtime Error

Solution code:
RC = input().split()
r = int(RC[0])
c = int(RC[1])
A_c_sum = [0, 0, 0, 0, 0]
final_sum = 0
for i in range(r):
    A_r = input().split()
    A_r_sum = 0
    for j in range(c):
        A_c_sum[j] += int(A_r[j])
        print(A_r[j]+" ", end="")
        A_r_sum += int(A_r[j])
    print(A_r_sum)
    final_sum += A_r_sum
print(" ".join(map(str,A_c_sum))+" ",end="")
print(final_sum)

Submission status: Runtime Error

Solution code:
r, c = map(int, input().split())
mat = []
for i in range(r):
 mat.append(list(map(int, input().split())))

for x in range(r):
 rsum = 0
 for y in range(c):
  rsum += mat[x][y]
 mat[x].append(rsum)

for x in range(c):
 csum = 0
 for y in range(r):
  csum = mat[y][x]
 mat[r].append(csum)

for x in range(r+1):
 for y in range(c):
  print("{0} ".format(mat[x][y]), end = '')
 print(mat[x][y+1])

Submission status: Runtime Error

Solution code:
r, c = map(int, input().split())
mat = []
for i in range(r):
 mat.append(list(map(int, input().split())))
mat.append([])

for x in range(r):
 rsum = 0
 for y in range(c):
  rsum += mat[x][y]
 mat[x].append(rsum)

for x in range(c):
 csum = 0
 for y in range(r):
  csum += mat[y][x]
 mat[c].append(csum)

for x in range(r+1):
 for y in range(c):
  print("{0} ".format(mat[x][y]), end = '')
 print(mat[x][c])

Submission status: Runtime Error

Solution code:
r, c = map(int, input().split())
mat = []
for i in range(r):
 mat.append(list(map(int, input().split())))
mat.append([])

for x in range(r):
 rsum = 0
 for y in range(c):
  rsum += mat[x][y]
 mat[x].append(rsum)

for x in range(c):
 csum = 0
 for y in range(r):
  csum += mat[y][x]
 mat[c].append(csum)

for x in range(r):
 for y in range(c):
  print("{0} ".format(mat[x][y]), end = '')
 print(mat[x][c])

for i in range(c-1):
 print("{0} ".format(mat[r][i]), end = '')
print(mat[r][c-1]

Submission status: Runtime Error

Solution code:
r, c = map(int, input().split())
mat =[]

for x in range(r):
 for y in range(c):
  mat.append(list(map(int, input().split())))

for x in range(r):
 rsum = 0
 for y in range(c):
  rsum += mat[x][y]
 mat[x].append(rsum)

mat.append([])

for x in range(c):
 csum = 0
 for y in range(r):
  csum += mat[y][x]
 mat[r].append(csum)

for x in range(r):
 for y in range(c):
  print("{0} ".format(mat[x][y]), end = '')
 print(mat[x][c])

for x in range(c-1):
 print("{0} ".format(mat[r][x]), end='')
print(mat[r][c-1])

Submission status: Runtime Error

Solution code:
r,x = map(int,raw_input().split())
matrix = []
for i in range(r):
    matrix.append(map(int,raw_input().split()))

a = [0 for j in range(c)]

matrix.append(a)

for i in range(r):
    sum = 0
    for j in range(c):
        sum += matrix[i][j]
    matrix[i].append(sum)

for j in range(c):
    sum = 0
    for i in range(r):
        sum += matrix[i][j]
    matrix[r][j] = sum

sum = 0
for j in range(c):  
    sum += matrix[r][j]
matrix[r].append(sum)

for i in range(r+1):
    for j in range(c+1):
        print matrix[i][j],
    print ""

Submission status: Runtime Error

Solution code:
r, c = map(int, input().split())
a = [0]*(c+1)
for _ in range(r):
    v = list(map(int, input().split()))
    s = 0
    for i, e in enumerate(v):
        s+=e
        a[i]+=e
    print(*v, s)
    a[-1]+=s
print(*a)

Submission status: Runtime Error

Solution code:
def Input():
    matrix = []
    row, col = [int(x) for x in input().split()]
    i = row
    while i > 0:
        matrix.append([int(y) for y in input().split()])
        i -=  1
    return matrix

def calcTotalOfRowAndCol(matrix):
    for l in matrix:
        total = 0
        for val in l:
            total += val
        l.append(total)
    matrix.append([])
    for i in range(6):
        total = 0
        j = 0
        while j < 4:
            total += matrix[j][i]
            j += 1
        matrix[4].insert(i, total)

    return matrix

def Output(matrix):
    for l in matrix:
        print(' '.join(str(x) for x in l))

if __name__ == '__main__':
    matrix = Input()
    matrix = calcTotalOfRowAndCol(matrix)
    Output(matrix)

Submission status: Runtime Error

Solution code:
def Input():
    matrix = []
    row, col = [int(x) for x in input().split()]
    i = row
    while i > 0:
        matrix.append([int(y) for y in input().split()])
        i -=  1
    return matrix

def calcTotalOfRowAndCol(matrix):
    for l in matrix:
        total = 0
        for val in l:
            total += val
        l.append(total)
    matrix.append([])
    for i in range(6):
        total = 0
        j = 0
        while j < 4:
            total += matrix[j][i]
            j += 1
        matrix[4].insert(i, total)

    return matrix

def Output(matrix):
    for l in matrix:
        print(' '.join(str(x) for x in l))

if __name__ == '__main__':
    matrix1 = Input()
    matrix2 = calcTotalOfRowAndCol(matrix1)
    Output(matrix2)

Submission status: Runtime Error

Solution code:
r,c=list(map(int,input().split()))
l=[]
for i in range(r):
	a=list(map(int,input().split()))
	l.append(a.append(sum(a)))
b=[]
for i in range(c+1):
	c=0
	for j in range(r):
		c+=l[j][i]
	b.append(c)
l.append(b)

for i in l:
	print(" ".join(i))

Submission status: Runtime Error

Solution code:
r,c=map(int,raw_input().split())
A=[]
for i in range(r):
    A.append(map(int,raw_input().split()))
    A[i].append(sum(A[i]))
A.append([sum([A[i][j] for i in range(r)]) for j in range(c)])
print(A)
for i in range(r):
    print(' '.join(A[i]))

Submission status: Runtime Error

Solution code:
r, c = map(int, input().split())
mat = [list(map(int, input().split())) for i in range(r)]
for row in mat:
    print(*row, sum(row))
colSum = [sum(col) for col in zip(*mat)]
print(*colSum, sum(colSum))

Submission status: Runtime Error

Solution code:
r, c = input().split()
r = int(r)
c = int(c)

a = [0]*c

for i in range(r):
    a[i] = list(map(int, input().split()))
    a[i].append(sum(a[i]))
    print(*a[i])

b = list(zip(*a))
print(*[sum(b[i]) for i in range(len(b))])

Submission status: Runtime Error

Solution code:
r, c = map(int, input().strip().split())
l = [[] for i in range(r)].append([0 for j in range(c+1)])
for i in range(r):
    l[i] = list(map(int, input().strip().split()))
    l[i].append(sum(l[i][0:c]))
    l[r] = [l[r][j] + l[i][j] for j in range(c+1)]
    print(' '.join(map(str,l[i])))
print(' '.join(map(str,l[r])))

Submission status: Runtime Error

Solution code:
r,c = map(int,input().split(' '))
arr = [[0 for i in range(c+1)] for i in range(r+1)]

for i in range(r):
    row = list(map(int,input().split(' ')))
    for j in range(c):
        arr[i][j] = row[j]

for i in range(r):
    for j in range(c):
        arr[i][-1] += arr[i][j]
for i in range(c):
    for j in range(r):
        arr[-1][i] += arr[j][i]
for i in range(r+1):
    arr[-1][-1] += arr[-1][i]

for i in range(c):
    for j in range(r+1):
        print(arr[i][j],end = ' ')
    print(arr[i][-1])

Submission status: Runtime Error

Solution code:
r,c = map(int,input().split())

a = [[0 for i in range(c+1)] for j in range(r+1)]

for i in range(r):
    a_tmp = list(map(int,input().split()))
    for j in range(c):
        a[i][j] = a_tmp[j]
        a[i][c+1] += a_tmp[j]
        a[r+1][j] += a_tmp[j]
        a[r+1][c+1] += a_tmp[j]

for i in range(r+1):
    print(' '.join(x for x in a[i]))

Submission status: Runtime Error

Solution code:
r,c = map(int,input().split())

a = [[0 for i in range(c+1)] for j in range(r+1)]

for i in range(r):
    a_tmp = list(map(int,input().split()))
    for j in range(c):
        a[i][j] = a_tmp[j]
        a[i][c+1] += a_tmp[j]
        a[r+1][j] += a_tmp[j]
        a[r+1][c+1] += a_tmp[j]

for i in range(r+1):
    print(' '.join(str(x) for x in a[i]))

Submission status: Runtime Error

Solution code:
table = []
r, c = map(int, input().strip().split())
[table.append(input().strip().split()) for i in range(r)]

print(table)
for j in range(r + 1):
    for k in range(c + 1):
        if j == r and k != c:
            lastrow = sum(map(int, [table[x][k] for x in range(r)]))
            table[-1].append(lastrow)
        if k == c:
            print(sum(map(int, table[j])))
            break
        print(table[j][k],end=' ')

Submission status: Runtime Error

Solution code:
iranai = [int(i) for i in input().split()]
iru = [[int(i) for i in input().split()] for i in range(iranai[0])]
mikitani = []
son = []
num = 0
mikicount = 0

for i in range(iranai[0]):
    for i2 in range(iranai[1]):
        num += iru[i][i2]
    mikitani.append(num)
    num = 0

for i in range(iranai[1]):
    for i2 in range(iranai[0]):
        num += iru[i2][i]
    son.append(num)
    num = 0

for i in range(iranai[0]):
    for i2 in range(iranai[1]):
        print(iru[i][i2],end=" ")
        if i2 = iranai[2]-1:
            print(mikitani[i])
    mikicount += mikitani[i]
son.append(mikicount)

for i in range(len(son)):
    if i == len(son)-1:
        print(son[i])
    else:
        print(son[i],end=" ")

Submission status: Runtime Error

Solution code:
def sum(l):
	s=0
	for i in l:
		s+=i
	return s
r,c=map(int,raw_input().split())
su=[0]*c
for i in range(r):
	l=map(int,raw_input().split())
	for j in l:print j,
	print sum(l)
	for j in range(c):su[j]+=l[j]
for j in su:print j,
	print sum(su)

Submission status: Runtime Error

Solution code:
r,c = list(map(int, input().split()))

parent_list = []
for i in range(r):
    l = list(map(int, input().split()))
    l.append(sum(l))
    parent_list.append(l)

for l in parent_list:
    for n in l:
        print(n, end=' ')
    print('')

for (a,b,c) in zip(*parent_list):
    print(a+b+c, end=' ')

Submission status: Runtime Error

Solution code:
r,c = [int(i) for i in input().split()]
a = [[0 for i in range(r+2)] for j in range(c)]
for i in range(r):
	a[i] = [int(j) for j in input().split()]
for i in range(r):
	rowSum = 0
	for j in range(c):
		rowSum += a[i][j]
	a[i].append(rowSum)
for i in range(c+1):
	columnSum = 0
	for j in range(r):
		columnSum += a[j][i]
	a[r][i] = columnSum
for i in range(r+1):
	for j in range(c):
		print(a[i][j],end=' ')
	print(a[i][c])

Submission status: Runtime Error

Solution code:
r, c = [int(i) for i in input().split(" ")]
s_row = [0 for x in range(c + 1)]

for i in range(r):
    row = [int(n) for n in input().split(" ")]
    row.append(sum(raw))
    print(" ".join( [ str(s) for s in row ] ) )
    s_row = [ x + y for x, y in zip(s_row, row)]
print(" ".join( [str(s1) for s1 in s_row] ))

Submission status: Runtime Error

Solution code:
r, c = [int(i) for i in input().split(" ")]
s_row = [0 for x in range(c + 1)]

for i in range(r):
    row = [int(n) for n in input().split(" ")]
   row =  row.append(sum(row))
    print(" ".join( [ str(s) for s in row ] ) )
    s_row = [ x + y for x, y in zip(s_row, row)]
print(" ".join( [str(s1) for s1 in s_row] ))

Submission status: Runtime Error

Solution code:
raws,columns = map(int,input().split())
a = []
for i in range(raws):
    a.append(list(map(int,input().split())))
for i in range(raws):
    a[i].append(sum(a[i]))
a,append([sum(i) for i in a])

Submission status: Runtime Error

Solution code:
raws,columns = map(int,input().split())
a = []
for i in range(raws):
    a.append(list(map(int,input().split())))
for i in range(raws):
    a[i].append(sum(a[i]))
a.append([sum(i) for i in a])
for r in a:
    print(' '.join(x for x in r))

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
??´?????????
"""
inp = input().strip().split(" ")
row = int(inp[0])
col = int(inp[1])

cells = [[0 for r in range(row+1)] for c in range(col+1)]
for r in range(row):
    inp = input().strip().split(" ")
    for c in range(col):
        cells[r][c] = int(inp[c])
        cells[row][c] += cells[r][c]
        cells[r][col] += cells[r][c]
    cells[row][col] += cells[r][col]

for r in range(row+1):
    print(" ".join(map(str,cells[r])))

Submission status: Runtime Error

Solution code:
import output
r, c = map(int, input().split())
a = [[int(num) for num in input().split()] for i in range(r)]
a.append([0, 0, 0, 0, 0])
for i in range(c):
    for j in range(r):
        a[r][i] += a[j][i]
for i in range(c):
    a[i].append(sum(a[i]))
for i in range(r+1):
    for j in range(c+1):
        if j == c:
            print(a[i][j])
        else:
            print(a[i][j], end=" ")

Submission status: Runtime Error

Solution code:
r, c = map(int, input().split())
a = [[int(num) for num in input().split()] for i in range(r)]
a.append([0, 0, 0, 0, 0])
for i in range(c):
    for j in range(r):
        a[r][i] += a[j][i]
for i in range(c):
    a[i].append(sum(a[i]))
for i in range(r+1):
    for j in range(c+1):
        if j == c:
            print(a[i][j])
        else:
            print(a[i][j], end=" ")

Submission status: Runtime Error

Solution code:
I = input().split()
r = int(I[0])
c = int(I[1])
Rsum = 0
Csum = (c + 1) * [0]

o = [[0 for i2 in range(c + 1)] for i1 in range(r + 1)]

for i in range(r + 1):
    if i < r:
        Irc = input().split()
    for j in range(c):
        if i < r:
            o[i][j] = int(Irc[j])
            Rsum += o[i][j]
            Csum[j] += o[i][j]
        else:
            o[i][j] += Csum[j]
            Rsum += o[i][j]
    o[i][c] = Rsum
    Csum[c] = o[i][r]
    Rsum = 0

for i in range(r + 1):
    for j in range(c + 1):
        print(str(o[i][j]), end = '')
        if j != c:
            print(' ', end = '')
    print()

Submission status: Runtime Error

Solution code:
r,c=map(int,input().split())
a,b=[],[0]*c
for i in range(r):
    x=list(map(int,input().split()))
    b+=x
    print(*x, end=' ')
    print(sum(x))
print(*b, end=' ')
    print(sum(b))

Submission status: Runtime Error

Solution code:
N, M=map(int, input().split())
for n in range(N):
 arr = list(map(int, input().split()))
 sum = sum(arr)
 print(" ".join(arr) + " " + sum)

Submission status: Runtime Error

Solution code:
N, M=map(int, input().split())
sum = 0
for n in range(N):
 arr = list(map(int, input().split()))
 sum = sum(arr)
 print(" ".join(arr) + " " + sum)

Submission status: Runtime Error

Solution code:
N, M=map(int, input().split())
sum = 0
for n in range(N):
 arr = list(map(int, input().split()))
 arr.append(sum(arr))
 print(" ".join(arr))

Submission status: Runtime Error

Solution code:
# (c) midandfeed
r, c = [int(x) for x in input().split()]
q = []
sumr = [0]*c
tempr = 0
for i in range(r):
	col = [int(x) for x in input().split()]
	for j in range(c):
		sumr[j] += col[j]
	col.append(sum(col))
	q.append(col)
sumr.append(sum(sumr))
q.append(sumr)
for i in range(r+1):
	for j in range(c+1):
		print(q[i], end='')
		if (i != (r+1))
			print(' ', end='')
	print()

Submission status: Runtime Error

Solution code:
r,c = map(int,input().split())
line = []
array = [[0 for i in range(c+1)]for j in range(r+1)]
for i in range(0,r):
    line = input().split()
    for j in range(c):
        array[i][j]=int(line[j])
sum = 0
for i in range(r):
    for j in range(c):
        sum = sum + array[i][j]
    array[i][c]=sum
    sum = 0
for i in range(c):
    for j in range(r):
        sum = sum + array[j][i]
    array[r][i]=sum
    sum = 0
sum = 0
for i in range(c):
    sum = sum + array[r][i]
for j in range(r):
    sum = sum + array[i][c]
array[r][c] = sum    
for i in range(r+1):
    for j in range(c+1):
        if j == c:
            print("{}".format(array[i][j])) 
        else:    
            print("{}".format(array[i][j]),end=" ")

Submission status: Runtime Error

Solution code:
import numpy as np

r,c = map(int, input().split())
a=np.zeros([r+1,c+1])

for i in range(r):
    sumC = 0
    ar = input().split()
    for j in range(c):
        a[i,j]=int(ar[j])
        sumC +=int(ar[j])
    a[i,c]=sumC
    print(" ".join(map(str, ar)), end=" ")
    print(sumC)


for k in range(c+1):
    for m in range(r):
        a[r,k] += a[m,k]

for i in range(c):
    print(int(a[r,i]), end=" ")
print(int(a[r,c]))

Submission status: Runtime Error

Solution code:
r, c = map(int, input().split())
for i in range(c):
    n = list(map(int, input().split()))
    n.append(sum(n))
    print (n)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
mat = [[0 for _ in range(n+1)] for _ in range(m+1)]

for i in range(n):
    r = list(map(int,input().split()))
    for j in range(m):
        mat[i][j] = r[j]

for i in range(n):
    for j in range(m):
        mat[i][-1] += mat[i][j]
        mat[-1][j] += mat[i][j]
    mat[-1][-1] += mat[i][-1]
        
for i in range(n+1):
    for j in range(m+1):
        print(mat[i][j],end = ' ')
    print('')

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
mat = [[0 for x in range(n+1)] for y in range(m+1)]

for i in range(n):
    r = list(map(int,input().split()))
    for j in range(m):
        mat[i][j] = r[j]

for i in range(n):
    for j in range(m):
        mat[i][-1] += mat[i][j]
        mat[-1][j] += mat[i][j]
    mat[-1][-1] += mat[i][-1]
        
for i in range(n+1):
    for j in range(m+1):
        print(mat[i][j],end = ' ')
    print('')

Submission status: Runtime Error

Solution code:
from operator import add
from functools import reduce

r,c = map(int,input().split())

x = [list(map(int, input().split())) for i in range(r)]


import numpy as np


#x=[[3,4,5],[1,2,3]]
a=np.array(x)
#print(a)
b=reduce(add, a)
#print(b)
b=list(b)

#x=list(x[1])
x.append(b)

#print(x)

for i in range(len(x)):
    y = reduce(add,x[i])
    x[i].append(y)
    
    
z = [list(map(str,x[i])) for i in range(len(x))]

#print(z)

w = [' '.join(z[i]) for i in range(len(x))]

[print(w[i]) for i in range(len(w))]

Submission status: Runtime Error

Solution code:
r, c = map(int, input().split())
table = []
for i in range(r):
    table.append(list(map(int, input().split())))
for i in table:
    i.append(sum(i))
b = []
for i in range(c):
    b.append(sum(list(table[i for i in range(r)])))
b.append(sum(b))
for i in table:
    print(" ".join(map(str, i)))
print(" ".join(map(str, b)))

Submission status: Runtime Error

Solution code:
r, c = map(int, input().split())
table = []
for i in range(r):
    table.append(list(map(int, input().split())))
for i in table:
    i.append(sum(i))
b = []
for i in range(c):
    b.append(sum(list(table[k for k in range(r)])))
b.append(sum(b))
for i in table:
    print(" ".join(map(str, i)))
print(" ".join(map(str, b)))

Submission status: Runtime Error

Solution code:
r, c = map(int, input().split())
table = []
for i in range(r):
    table.append(list(map(int, input().split())))
for i in table:
    i.append(sum(i))
b = []
for i in range(c):
    b.append(sum(list(table[i][k for k in range(r)])))
b.append(sum(b))
for i in table:
    print(" ".join(map(str, i)))
print(" ".join(map(str, b)))

Submission status: Runtime Error

Solution code:
r, c = map(int, input().split())
table = []
for i in range(r):
    table.append(list(map(int, input().split())))
for i in table:
    i.append(sum(i))
b = []
for i in range(c):
    b.append(sum(list(table[k for k in range(r)][i])))
b.append(sum(b))
for i in table:
    print(" ".join(map(str, i)))
print(" ".join(map(str, b)))

Submission status: Runtime Error

Solution code:
r, c = map(int, input().split())
for i in range(r):
    a = list(map(int, input(),split()))
    print(a,sum(a))

Submission status: Runtime Error

Solution code:
r, c = map(int, input().split())
a = []
for i in range(r):
    a.append(list(map(int, input(),split())))
for line in arr:
    line.append(sum(line))
arr.append([sum([line[i] for line in arr]) for i in range(c+1)])
for line in arr:
    print(*line)

Submission status: Runtime Error

Solution code:
r, c = map(int, input().split())
a = []
for i in range(r):
    a.append(list(map(int, input(),split())))
for line in arr:
    line.append(sum(line))
arr.append([sum([line[i] for line in arr]) for i in range(c+1)])
for line in arr:
    print(line)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

r, c = list(map(int, input().split()))
a = []
line_sum = 0

for i in range(r):
    a.append(list(map(int, input().split())))

for i in range(r):
    for j in range(c + 1):
        if j == c:
            print('{0}'.format(sum(a[i])))
            line_sum += sum(a[i])
        else:
            print('{0} '.format(a[i][j]), end='')

for i in range(c + 1):
    column_sum = 0
    for j in range(r):
        column_sum += a[j][i]

    print('{0} '.format(column_sum), end='')

print(line_sum)

Submission status: Runtime Error

Solution code:
r, c = map(int, input().split())
matrix = [[0 for i in range(c+1)] for j in range(r+1)]
for i in range(r):
    a = list(map(int, input().split()))
    for j in range(c):
        matrix[i][j] = a[j]
    matrix[i][c] = sum(a)
for l in range(c+1):
    for m in range(r):
        matrix[r][l] += matrix[m][l]

for cv in range(r+1):
    for fv in range(c+1):
        print(matrix[cv][fv], end='')
        if fv != c:
        print(" ", end='')
    print()

Submission status: Runtime Error

Solution code:
l=input().split()
r=int(l[0])
c=int(l[1])

# for yoko
i=0
b=[]
while i<r:
    a=input().split()
    q=0
    su=0
    while q<c:
        b.append(int(a[q]))
        su+=int(a[q])
        q=q+1
    b.append(su)
    i=i+1

# for tate
#x=0
#d=b[0]+b[c+1]+b[2*(c+1)]+b[3*(c+1)]
#x<c+1
x=0
while x<c+1:
    d=0
    d=b[x]+b[x+c+1]+b[x+2*(c+1)]+b[x+3*(c+1)]
    b.append(d)
    x=x+1
# for output
# C=[]
# y=0 (for gyou)
# z=0 (for yoko)
C=[]
y=0
while y<r+1:
    z=0
    Ans=str(b[y*(c+1)+z])
    while z<c:
        z+=1
        Ans=Ans+" "+str(b[y*(c+1)+z])
    C.append(Ans)
    y+=1

for k in C:
    print(k)

Submission status: Runtime Error

Solution code:
import sys

p = 0
x1 = []
for line in open('test.txt','r'):#sys.stdin:
    x = [int(i) for i in line.split()]
    if p == 0:
        r,c = x
        p = 1
    else:
        x1.append(x)

for i in range(r):
    x1[i].append(sum(x1[i]))
x=[]
for j in range(c+1):
    s = 0
    for i in range(r):
        s += x1[i][j]
    x.append(s)
x1.append(x)

for i in range(r+1):
    for j in range(c+1):
        print x1[i][j],
    print

Submission status: Runtime Error

Solution code:
r, c = map(int, raw_input().split())
a = [[0 for i in range(r)] for j in range(c)]
for i in range(c):
    row = map(int, raw_input().split())
    for j in range(r):
        a[i][j] = row[j]

Submission status: Runtime Error

Solution code:
r, c = map(int, raw_input().split())
sum_c = [0 for x in range(r)]
sum_r = [0 for x in range(c)]
sum = 0

for i in range(r):
    column = map(int, raw_input().split())
    for j in range(c):
        sum_c[i] += column[j]
        sum_r[j] += column[j]
        sum = column[j]
    print(" ".join(map(str, column) + " " + str[sum_c[i]]

print (" ".joint(map(str, sum_r) + " " + str(sum))

Submission status: Runtime Error

Solution code:
r, c = map(int, raw_input().split())
sum_c = [0 for x in range(r)]
sum_r = [0 for x in range(c)]
sum = 0

for i in range(r):
    column = map(int, raw_input().split())
    for j in range(c):
        sum_c[i] += column[j]
        sum_r[j] += column[j]
        sum += column[j]
    print(" ".join(map(str, column)) + " " + str[sum_c[i])

print (" ".joint(map(str, sum_r)) + " " + str(sum))

Submission status: Runtime Error

Solution code:
r, c = map(int, raw_input().split())
sum_c = [0 for x in range(r)]
sum_r = [0 for x in range(c)]
sum = 0

for i in range(r):
    column = map(int, raw_input().split())
    for j in range(c):
        sum_c[i] += column[j]
        sum_r[j] += column[j]
        sum += column[j]
    print(" ".join(map(str, column)) + " " + str(sum_c[i]))

print (" ".joint(map(str, sum_r)) + " " + str(sum))

Submission status: Runtime Error

Solution code:
r, c = map(int, raw_input().split())
sum_c = [0 for x in range(r)]
sum_r = [0 for x in range(c)]
sum = 0

for i in range(r):
    column = map(int, raw_input().split())
    for j in range(c):
        sum_c[i] += column[j]
        sum_r[j] += column[j]
        sum += column[j]
X

Submission status: WA: Presentation Error

Solution code:
def main():

        m, n = tuple(map(int, input().split()))
        matrix = [[0 for j in range(n+1)] for i in range(m+1)]
        for i in range(m):
            tmp = list(map(int, input().split()))
            for j in range(n):
                matrix[i][j] = tmp[j]
                matrix[i][n] += tmp[j]
                print(tmp[j], end=' ')
            print(matrix[i][n])
        
        for j in range(n+1):
            for i in range(m):
                matrix[m][j] += matrix[i][j]
            print(matrix[m][j], end=' ')
        print()
        
if __name__ == '__main__':
    main()

Submission status: WA: Presentation Error

Solution code:
def main():

    m, n = tuple(map(int, input().split()))
    matrix = [[0 for j in range(n+1)] for i in range(m+1)]
    for i in range(m):
        tmp = list(map(int, input().split()))
        for j in range(n):
            matrix[i][j] = tmp[j]
            matrix[i][n] += tmp[j]
    
    for j in range(n+1):
        for i in range(m):
            matrix[m][j] += matrix[i][j]

    for i in range(m+1):
        for j in range(n+1):
            print(matrix[i][j], end=' ')
        print()


if __name__ == '__main__':
    main()