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: Accepted

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

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

for i in range(r):
    temp = [int(x) for x in input().split()]
    for j in range(c+1):
        if not j == c:
            table[i][j] = temp[j]
            table[i][c] += temp[j]
        table[r][j] += table[i][j]

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python

if __name__=='__main__':
    r, c = map(int, raw_input().split())

    bottom = [0]*c
    for _ in range(r):
        s = raw_input()
        n = map(int, s.split())
        print '{} {}'.format(s, sum(n))
        for j in range(c):
            bottom[j] += n[j]

    print '{} {}'.format(' '.join(map(str, bottom)), sum(bottom))

Submission status: Accepted

Solution code:
r, c = list(map(int, input().split()))
t = [[0]*(c+1) for i in range(r+1)]
for i in range(r):
  a = list(map(int, input().split()))
  for j in range(c):
    t[i][j] = a[j]
    t[r][j] += a[j]
  t[i][c] = sum(a)
t[r][c] = sum(t[r])
for i in range(r+1):
  print(" ".join(map(str, t[i])))

Submission status: Accepted

Solution code:
r,c = map(int, tuple(input().split(' ')))
rc = [[int(s) for s in input().split(' ')] for _ in range(r)]
for row in rc: row.append(sum(row))
to = []
for col in range(c+1):
	su = 0
	for a in range(r): su += rc[a][col]
	to.append(su)
rc.append(to)
for row in rc: 
	ss = map(str, row)
	print(' '.join(ss))

Submission status: Accepted

Solution code:
arg1,arg2 = map(int, input().split())
data = []
data2 = []
tmp = []
for x in range(0,arg1):
    tmp = input().split()
    data.append([int(tmp[i]) for i in range(arg2)])
    data[x].append(sum(data[x]))
data.append([(sum(data[i][j] for i in range(arg1))) for j in range(arg2)])
data[arg1].append(sum(data[arg1][i] for i in range(arg2)))
for x in range(0,arg1+1):
    for y in range(0,arg2+1):
        if y != arg2:
            print(data[x][y],end=' ')
        else:
            print(data[x][y])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
r, c = [int(i) for i in input().split()]
data = ([int(i) for i in input().split()] for j in range(r))
ans = [data[i] + [sum(data[i])] for i in range(r)]
last_ans = ans + [[sum([ans[i][j] for i in range(r)]) for j in range(c+1)]]
for i in last_ans:
    print(*i)

Submission status: Runtime Error

Solution code:
r, c = [int(i) for i in input().split()]
data = [[int(i) for i in input().split()] for j in range(r))]
ans = [data[i] + [sum(data[i])] for i in range(r)]
last_ans = ans + [[sum([ans[i][j] for i in range(r)]) for j in range(c+1)]]
for i in last_ans:
    print(*i)

Submission status: Runtime Error

Solution code:
# coding: utf-8

row, col = map(int, input().split())
spreadsheet = []

for i in range(row):
    val = list(map(int, input().split()))
    val.append(sum(val))
    spreadsheet.append(val)

for r in spreadsheet:
    print(' '.join(map(str, r)))

last_row = []
for j in range(len(spreadsheet[1])):
    col_sum = 0
    for i in range(len(spreadsheet)):
        col_sum += spreadsheet[i][j]
    last_row.append(col_sum)

print(' '.join(map(str, last_row)))

Submission status: Runtime Error

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

d = [0] * (c + 1)

for i in range(r):
    d[i] = list(map(int, input().split()))
    d[i].append(0)
    for j in range(c):
        d[i][c] += d[i][j]

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

for i in range(r + 1):
    row = ''
    for j in range(c + 1):
        row += str(d[i][j])
        if j <= c - 1:
            row += ' '
    print(row)

Submission status: Runtime Error

Solution code:
r_c_str=input().split()
r_c=list(map(lambda i :int(i),r_c_str))
r=r_c[0]
c=r_c[1]
s_str=[input() for i in range(r)]
s_str=[i.split() for i in s_str]
s=[]
for i in s_str:
    s.append(list(map(lambda j :int(j),i)))
for i in range(r):
    s[i].append(sum(s[i]))
s.append([0,0,0,0,0,0])
for i in range(c):
    for j in range(r):
        s[4][i]+=s[j][i]
s[-1][-1]+=sum(s[4])
for i in s:
    print(*i)

Submission status: Runtime Error

Solution code:
r_c_str=input().split()
r_c=list(map(lambda i :int(i),r_c_str))
r=r_c[0]
c=r_c[1]
s_str=[input() for i in range(r)]
s_str=[i.split() for i in s_str]
s=[]
for i in s_str:
    s.append(list(map(lambda j :int(j),i)))
for i in range(r):
    s[i].append(sum(s[i]))
s.append([0,0,0,0,0,0])
for i in range(c):
    for j in range(r):
        s[r][i]+=s[j][i]
s[-1][-1]+=sum(s[4])
for i in s:
    print(*i)

Submission status: Runtime Error

Solution code:
r_c_str=input().split()
r_c=list(map(lambda i :int(i),r_c_str))
r=r_c[0]
c=r_c[1]
s_str=[input() for i in range(r)]
s_str=[i.split() for i in s_str]
s=[]
for i in s_str:
    s.append(list(map(lambda j :int(j),i)))
for i in range(r):
    s[i].append(sum(s[i]))
s.append([0,0,0,0,0,0])
for i in range(c):
    for j in range(r):
        s[-1][i]+=s[j][i]
s[-1][-1]+=sum(s[4])
for i in s:
    print(*i)

Submission status: Runtime Error

Solution code:
r_c_str=input().split()
r_c=list(map(lambda i :int(i),r_c_str))
r=r_c[0]
c=r_c[1]
s_str=[input() for i in range(r)]
s_str=[i.split() for i in s_str]
s=[]
for i in s_str:
    s.append(list(map(lambda j :int(j),i)))
for i in range(r):
    s[i].append(sum(s[i]))
s.append([])
for i in range(c+1):
    s[-1].append(0)
for i in range(c):
    for j in range(r):
        s[r][i]+=s[j][i]
s[-1][-1]+=sum(s[4])
for i in s:
    print(*i)

Submission status: Runtime Error

Solution code:
a = [[0 for i in range(100+1)]for j in range(100+1)]

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

t = 0
for i in range(r):
    for j in range(c):
        t += sum(j)
        a.append(t)

print(a)

Submission status: Runtime Error

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

A = [list(map(int,input().split())) for i in range(c)]
for i in range(c):
    for j in range(r):
        print(A[i][j],end=" ")
    print(sum(A[i]))
for i in range(c):
    ans = 0
    for j in range(r):
        ans += A[j][i]
    print(ans,end=" ")
print(sum(map(sum,A)))

Submission status: Runtime Error

Solution code:
r,c=map(int,input().split())
tbl=[[0]*c for i in range(r+1)]
for i in range(r):
    tbl[i]=list(map(int,input().split()))
for i in range(c):
    for j in renge(r):
        tbl[r][i] +=tbl[j][i]
for i in rnage(r+1):
    m=0
    for j in range(c):
        m += tbl[i][j]
        print(tbl[i][j],end=" ")
    print(m)

Submission status: Runtime Error

Solution code:
#coding: UTF-8

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

a = [input().split() for k in range(c)]

for l in range(r):
    for m in range(c):
        list[l][c] += int(a[l][m])
        list[r][m] += int(a[l][m])
        list[l][m] = int(a[l][m])

for n in range(r):
    print(list[r][c])
    print(int(a[n][c-1]))
    list[r][c] += list[n][c]

print(list)

Submission status: Runtime Error

Solution code:
#coding: UTF-8
import sys

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

a = [input().split() for k in range(c)]

for l in range(r):
    for m in range(c):
        list[l][c] += int(a[l][m])
        list[r][m] += int(a[l][m])
        list[l][m] = int(a[l][m])

for n in range(r):
    list[r][c] += list[n][c]

for o in range(r+1):
    for p in range(c+1):
        print(list[o][p], " ", end = '')
    print(" ")

Submission status: Runtime Error

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

Submission status: Runtime Error

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

table = []
i = 0

while i < r
  table[0] = list(int(x) for x in input().split())
  i += 1

# output R
i,j = 0,0
while i < r
  sum = 0
  while j < c
    if j != 0:
      print(' ')
    print(' ' + teble[i][j], end='')
    sum += table[i][j]
    j += 1
    if j == c:
      print(' ' + sum)

i,j = 0
while j < c:
  while i < r:
  i += 1

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
a = []
b = []
for i in range(n):
    a = [list(map(int, input().split()))]
    a[i] += [sum(a[i])]
for i in range(m):
    b += [a[:][i]]
    a += [b]
for i in range(n):
    print(*a[i])

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
al = []
b_lis = []

for _ in range(a):
    g = list(map(int, input().split()))
    g.append(sum(g))
    al.append(g)
for i in range(b+1):
    p = 0
    for j in range(a):
        p += al[a][i]
    b_lis.append(p)
for i in al:
    print(' '.join([str(v) for v in i]))

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
al = []
b_lis = []

for _ in range(a):
    g = list(map(int, input().split()))
    g.append(sum(g))
    al.append(g)
for i in range(b+1):
    p = 0
    for j in range(a):
        p += al[j][i]
    b_lis.append(p)
    al += b_lis
for i in al:
    print(' '.join([str(v) for v in i]))

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
al = []
b_lis = []

for _ in range(a):
    g = list(map(int, input().split()))
    g.append(sum(g))
    al.append(g)
for i in range(b+1):
    p = 0
    for j in range(a):
        p += al[j][i]
    b_lis.append(p)
al += b_lis
for i in al:
    print(' '.join([str(v) for v in i]))

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
al = []
b_lis = []

for _ in range(a):
    g = list(map(int, input().split()))
    g.append(sum(g))
    al.append(g)
for i in range(b+1):
    p = 0
    for j in range(a):
        p += al[j][i]
    b_lis.append(p)
al_1 = al + b_lis
for i in al_1:
    print(' '.join([str(v) for v in i]))

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
al = []
b_lis = []

for _ in range(a):
    g = list(map(int, input().split()))
    g.append(sum(g))
    al.append(g)
for i in range(b+1):
    p = 0
    for j in range(a):
        p += al[j][i]
    b_lis.append(p)
al_1.append((b_lis))
for i in al_1:
    print(' '.join([str(v) for v in i]))

Submission status: Runtime Error

Solution code:
#include<iostream>
using namespace std;
int main(){
    int r,c,t;
    t=0;
    cin>>r>>c;
    int R[c+1]={};
    int S[c+1]={};
    for (int i=0;i<r;i++){
        for(int x=0;x<c;x++){
            cin>>R[x];
            cout<<R[x]<<" ";
        }
        for(int x=0;x<c;x++){
            t+=R[x];
        }
    cout<<t<<endl;
    for(int b=0;b<c;b++){
        S[b]+=R[b];
    }
    R[c+1]={};
    t=0;
    }
    for(int x=0;x<c;x++){
        cout<<S[x]<<" ";
        S[c]+=S[x];
    }
    cout<<S[c]<<endl;    
}

Submission status: Runtime Error

Solution code:
n = int(input())
for i in range(1,n+1):
  if i%3==0 or i%10==3:
    print(" ",i,sep='',end="")
  else:
    pass
print()

Submission status: Runtime Error

Solution code:
n = int(input())
for i in range(1,n+1):
  if i%3==0 or i%10==3:
    print(" ",i,sep='',end="")
print()

Submission status: Runtime Error

Solution code:
i,j=map(int,input().split())
listA=[]
for i in range(i):
    listA.append(list(map(int,input().split())))
    listA[n].append(sum(listA[n]))
listA.append([])
for n in range(j+1):
    number =0
    for m in range(i):
        number+=listA[m][n]
    listA[i].append(number)
for n in range(i+1):
    print(''.join(map(str,listA[n])))

Submission status: Runtime Error

Solution code:
li = list(map(int,input().split()))
mtx = [[] for _ in range(li[0])]
li_sum = []

for i in range(li[0]):
    mtx[i] = list(map(int,input().split()))
    print(mtx[i],sum(mtx[i]))
    
    for j in range(li[j]):
        li_sum[j] += mtx[i][j]
    li_sum[j] += sum(mtx[i])

print(' '.join(map(str,li_sum)))

Submission status: Runtime Error

Solution code:
li = list(map(int,input().split()))
mtx = [[] for _ in range(li[0])]
li_sum = []

for i in range(li[0]):
    mtx[i] = list(map(int,input().split()))
    print(mtx,end='')
    print(sum(mtx[i]))
    
    for j in range(li[j]):
        li_sum[j] += mtx[i][j]
    li_sum[j] += sum(mtx[i])

print(' '.join(map(str,li_sum)))

Submission status: Runtime Error

Solution code:
li = list(map(int,input().split()))
mtx = [[] for _ in range(li[0])]
li_sum = []

for i in range(li[0]):
    a = input()
    mtx[i] = list(map(int,a.split()))
    print(mtx,end='')
    print(' ' ,sum(mtx[i]),sep='')
    
    for j in range(li[j]):
        li_sum[j] += mtx[i][j]
    li_sum[j] += sum(mtx[i])

print(' '.join(map(str,li_sum)))

Submission status: Runtime Error

Solution code:
li = list(map(int,input().split()))
mtx = [[] for _ in range(li[0])]
li_sum = []

for i in range(li[0]):
    a = input()
    mtx[i] = list(map(int,a.split()))
    print(a,end='')
    print(' ' ,sum(mtx[i]),sep='')
    
    for j in range(li[j]):
        li_sum[j] += mtx[i][j]
    li_sum[j] += sum(mtx[i])

print(' '.join(map(str,li_sum)))

Submission status: Runtime Error

Solution code:
li = list(map(int,input().split()))
mtx = [[] for _ in range(li[0])]
li_sum = [0 for _ in range(li[1]+1)]

for i in range(li[0]):
    a = input()
    mtx[i] = list(map(int,a.split()))
    print(a,end='')
    print(' ' ,sum(mtx[i]),sep='')
    
    for j in range(li[j]):
        li_sum[j] += mtx[i][j]
    li_sum[j] += sum(mtx[i])

print(' '.join(map(str,li_sum)))

Submission status: Runtime Error

Solution code:
import numpy as np

r,c = map(int,input().split())
table = [[0]*c for i in range(r)]

Submission status: Runtime Error

Solution code:
r,c=map(int, input().split())
S=[]
for num in range(c-1):
  A=list(map(int, input().split()))
  S.append(A)
  A.append(sum(A))

#print(list(zip(*S)))
C=[]
for t in (zip(*S)):
  C.append(sum(t))
S.append(C)
for i in S:
  print(*i)

Submission status: Runtime Error

Solution code:
r,c=map(int, input().split())
S=[]
for num in range(c-1):
  A=list(map(int, input().split()))
  S.append(A)
  A.append(sum(A))

#print(list(zip(*S)))
C=[]
for t in (zip(*S)):
  C.append(sum(t))
S.append(C)
for i in S:
  print(*i)

Submission status: Runtime Error

Solution code:
r,c=map(int, input().split())
S=[]
for num in range(c-1):
  A=list(map(int, input().split()))
  S.append(A)
  A.append(sum(A))

#print(list(zip(*S)))
C=[]
for t in (zip(*S)):
  C.append(sum(t))
S.append(C)
for i in S:
  print(*i)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

table = []
for rc in range(r):
    table.append([int(i) for i in input().split()])

table.append([0 for _ in range(c + 1)])

for rc in range(r):
    row_total = 0
    for cc in range(c):
        table[r][cc] += table[rc][cc]
        row_total += table[rc][cc]

    table[rc].append(row_total)
    table[r][c] += row_total

for row in table:
    for column in row:
        print(column, end =' ')
    print()

Submission status: Runtime Error

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

table = []
for rc in range(r):
    table.append([int(i) for i in input().split()])

table.append([0 for    in range(c + 1)])

for rc in range(r):
    row_total = 0
    for cc in range(c):
        table[r][cc] += table[rc][cc]
        row_total += table[rc][cc]

    table[rc].append(row_total)
    table[r][c] += row_total

for row in table:
    for column in row:
        print(column,end=' ')

    print()

Submission status: Runtime Error

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

table = []
for rc in range(r):
    table.append([int(i) for i in input().split()])

table.append([0 for  _  in range(c + 1)])

for rc in range(r):
    row_total = 0
    for cc in range(c):
        table[r][cc] += table[rc][cc]
        row_total += table[rc][cc]

    table[rc].append(row_total)
    table[r][c] += row_total

for row in table:
   print(' '.join([str(column) for column in row]))

    print()

Submission status: Runtime Error

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

table = []
for rc in range(r):
    table.append([int(i) for i in input().split()])

table.append([0 for _ in range(c + 1)])

for rc in range(r):
    row_total = 0
    for cc in range(c):
        table[r][cc] += table[rc][cc]
        row_total += table[rc][cc]

    table[rc].append(row_total)
    table[r][c] += row_total

for row in table:
    print(' '.join([str(column) for column in row]))

Submission status: Runtime Error

Solution code:
x,y=map(int,raw_input().split())
a=[map(int,raw_input().split()) for i in range(x)]
for i in range(x):
	a[i].append(sum(a[i]))
	for j in range(y+1):
		print a[i][j],
	print
for i in range(???+1):
	print sum([row[i] for row in a]),

Submission status: Runtime Error

Solution code:
while True:
    (a, op, b) = input().split()
    a =int(a)
    b =int(b)

    if op == '?':
        break

    elif op == '+':
        print(a + b)

    elif op == '-':
        print(a - b)

    elif op == '*':
        print(a * b)

    elif op == '/':
        print(a // b)

Submission status: Runtime Error

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

print(src)

Submission status: Runtime Error

Solution code:
(r, c) = [int(i) for i in input().split()]
src = []
for _ in range(r):
    row = ([int(i) for i in input().split()])
    row.append(sum(row))
    src.append(row)

last_row = [0 for _ in range(c+1)]
for rc in range(r):
    for cc in range(c):
        last_row += src[rc][cc]
src.append(last_row)

for rc in range(r+1):

Submission status: Runtime Error

Solution code:
(r, c) = [int(i) for i in input().split()]
src = []
for _ in range(r):
    row = ([int(i) for i in input().split()])
    row.append(sum(row))
    src.append(row)

last_row = [0 for _ in range(c+1)]
for rc in range(r):
    for cc in range(c):
        last_row += src[rc][cc]
src.append(last_row)

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

Submission status: Runtime Error

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

src = []

for _ in range(r) :
    row[int(i) for i in input().split()]
    row.append(sum(row))
    src.append(row)

last_row = [0 for _ in range(c+1)]
for rc in range(r):
    for cc in range(c+1):
        last_row[cc] += src[rc][cc]
src.append(last_row)

for rc in range(r+1) :
    print(' '.join([stc(a) for a in src[rc]]))

Submission status: Runtime Error

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

src = []

for _ in range(r) :
    row[int(i) for i in input().split()]
    row.append(sum(row))
    src.append(row)

last_row = [0 for _ in range(c+1)]
for rc in range(r):
    for cc in range(c+1):
        last_row[cc] += src[rc][cc]
src.append(last_row)

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

Submission status: Runtime Error

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

src = []

for _ in range(r) :
    row[int(i) for i in input().split()]
    row.append(sum(row))
    src.append(row)

last_row = [0 for _ in range(c+1)]
for rc in range(r):
    for cc in range(c+1):
        last_row[cc] += src[rc][cc]
src.append(last_row)

for rc in range(r+1) :
    print(' ',join([str(a) for a in src[rc]]))

Submission status: Runtime Error

Solution code:
(r, c) = [int(i) for i in input().split()]
src = []
for _ in range(r):
    row = [int(i) for i in input().split()]
    row.append(sum(row))
    src.append(row)
    
last_row = [0 for _ in range(c)]
for rc in range(r):
    for cc in range(c):
        last_row[cc] += src[rc][cc]
src = append(last_row)


for _ in range(r+1):
    print(' '.join([str(a) for a in src[rc]]))

Submission status: Runtime Error

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

for _ in range(r):
    row = [int(i) for i in input().split()]
    for cc in range(c):
        last_row[cc] += int(row[cc])
        print(row[cc], end=' ')

    print(sum(row))

last_row[-1] = sum(last_row)
print(' '.join([str(a) for a in last_row])

Submission status: Runtime Error

Solution code:
r, c = map(int, input().split())
table = [[*cc, sum(cc)] for cc in (list(map(int, input().split())) for _ in range(r))]
table.append(list(map(sum, zip(*table))))
print('\n'.join(' '.join(map(str, line)) for line in table))

Submission status: Runtime Error

Solution code:
r, c = map(int, input().split())
table = [[*cc, sum(cc)] for cc in (list(map(int, input().split())) for _ in range(r))]
table.append(list(map(sum, zip(*table))))
print('\n'.join(' '.join(map(str, line)) for line in table) + '\n')

Submission status: Runtime Error

Solution code:
r, c = map(int, input().split())
table = [[*cc, sum(cc)] for cc in (list(map(int, input().split())) for _ in range(r))]
table.append(list(map(sum, zip(*table))))
for line in table:
    print(*line)

Submission status: Runtime Error

Solution code:
mat = []
new_map = []

r,c = map(int, raw_input().split())
for i in range(r):
    mat = map(int, raw_input().split())
    new_map.append(mat)


for i in range(r):
    new_map[i].append(sum(new_map[i][:]))
    for j in range(c):
        print new_map[i][j],
    printf(" " + str(new_map[i][j + 1]) + "\n")


for j in range(c + 1):
    a = 0
    for i in range(r):
        a += new_map[i][j]
    if j == c:
        printf(" " + str(a) + "\n")
        break
    else:
        print a,

Submission status: Runtime Error

Solution code:
#-*- encoding=utf-8 -*-

import numpy as np
import matplotlib.pyplot as plt
import sys

printf = sys.stdout.write


mat = []
new_map = []

r,c = map(int, raw_input().split())
for i in range(r):
    mat = map(int, raw_input().split())
    new_map.append(mat)


for i in range(r):
    new_map[i].append(sum(new_map[i][:]))
    for j in range(c):
        print new_map[i][j],
    printf(" " + str(new_map[i][j + 1]) + "\n")


for j in range(c + 1):
    a = 0
    for i in range(r):
        a += new_map[i][j]
    if j == c:
        printf(" " + str(a) + "\n")
        break
    else:
        print a,

Submission status: Runtime Error

Solution code:
# 13-Structured_Program_II-Spreadsheet.py

# ??¨?¨????
# ??¨?¨??????????????°???????????????°???????????????????????????
# ??¨????????°r??¨?????°c???r ?? c ???????´????????????¨?????????????????§???
# ????????¨??????????¨?????????\????????°????????¨???????????????????????°?????????????????????????????????

# Input
# ???????????????r??¨c????????????????????§?????????????????????
# ?¶????r??????????????????c????????´??°????????????????????§?????????????????????

# Output
# (r+1) ?? (c+1) ?????°????????¨???????????????????????????
# ???????????£???????????´??°????????????????????§????????£??????????????????????????????????????¨??????????????????????¨?????????????????????????????????¨??????????????????????¨?????????????????????????????????¨??¨??????????¨????????????\??????????????????

# Constraints
# 1 ??? r, c ??? 100
# 0 ??? ????´? ??? 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

import numpy as np

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

data = np.zeros((r,c))

for i in range(r):
	data[i] = np.array( input().split() )

data=data.astype("int")
print("data",data)

for i in range( r ):
	for j in range(c):
		print("{0} ".format(data[i][j]), end="")
	print( np.sum(data[i]) )

for j in range(c):
	print("{0} ".format( np.sum(data, axis=0)[j] ), end="" )

print( np.sum(data) )

Submission status: Runtime Error

Solution code:
# 13-Structured_Program_II-Spreadsheet.py

# ??¨?¨????
# ??¨?¨??????????????°???????????????°???????????????????????????
# ??¨????????°r??¨?????°c???r ?? c ???????´????????????¨?????????????????§???
# ????????¨??????????¨?????????\????????°????????¨???????????????????????°?????????????????????????????????

# Input
# ???????????????r??¨c????????????????????§?????????????????????
# ?¶????r??????????????????c????????´??°????????????????????§?????????????????????

# Output
# (r+1) ?? (c+1) ?????°????????¨???????????????????????????
# ???????????£???????????´??°????????????????????§????????£??????????????????????????????????????¨??????????????????????¨?????????????????????????????????¨??????????????????????¨?????????????????????????????????¨??¨??????????¨????????????\??????????????????

# Constraints
# 1 ??? r, c ??? 100
# 0 ??? ????´? ??? 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

import numpy as np

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

data = np.zeros((r,c))

for i in range(r):
	data[i] = np.array( input().split() )

data=data.astype("int")
print("data",data)

# for i in range( r ):
# 	for j in range(c):
# 		print("{0} ".format(data[i][j]), end="")
# 	print( np.sum(data[i]) )

# for j in range(c):
# 	print("{0} ".format( np.sum(data, axis=0)[j] ), end="" )

# print( np.sum(data) )

Submission status: Runtime Error

Solution code:
# 13-Structured_Program_II-Spreadsheet.py

# ??¨?¨????
# ??¨?¨??????????????°???????????????°???????????????????????????
# ??¨????????°r??¨?????°c???r ?? c ???????´????????????¨?????????????????§???
# ????????¨??????????¨?????????\????????°????????¨???????????????????????°?????????????????????????????????

# Input
# ???????????????r??¨c????????????????????§?????????????????????
# ?¶????r??????????????????c????????´??°????????????????????§?????????????????????

# Output
# (r+1) ?? (c+1) ?????°????????¨???????????????????????????
# ???????????£???????????´??°????????????????????§????????£??????????????????????????????????????¨??????????????????????¨?????????????????????????????????¨??????????????????????¨?????????????????????????????????¨??¨??????????¨????????????\??????????????????

# Constraints
# 1 ??? r, c ??? 100
# 0 ??? ????´? ??? 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

import numpy as np

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

# data = np.zeros((r,c))

# for i in range(r):
# 	data[i] = np.array( input().split() )

# data=data.astype("int")
# print("data",data)

# for i in range( r ):
# 	for j in range(c):
# 		print("{0} ".format(data[i][j]), end="")
# 	print( np.sum(data[i]) )

# for j in range(c):
# 	print("{0} ".format( np.sum(data, axis=0)[j] ), end="" )

# print( np.sum(data) )

Submission status: Runtime Error

Solution code:
r,c=map(int,raw_input().split())
m=[]
ans=[]

for i in range(r):
	a=map(int,raw_input().split())
	m.append(a)
	sum=0
	for j in range(c)
		print(a[j]),
		sum+=a[j]
	print(sum)
total=0
for i in range(c):
	sum=0
	for j in range(r):
		sum+=m[j][i]
	print(sum),
	total+=sum
print(total)

Submission status: Runtime Error

Solution code:
c, r = map(int, input().split())
last_list = [0] * r
for _ in range(c):
    n = 0
    x = input()
    sum_list = list(map(int, x.split()))
    for i in range(r):
        last_list[i] += sum_list[i]
        n += sum_list[i]
    print(x, end = " ")
    print(n)

sum = 0   
for a in last_list:
    sum += a
print(*last_list, sum)

Submission status: Runtime Error

Solution code:
c, r = map(int, input().split())
last_list = [0] * r
for _ in range(c):
    n = 0
    x = input()
    sum_list = list(map(int, x.split()))
    for i in range(r):
        last_list[i] += sum_list[i]
        n += sum_list[i]
    print(x+" "+str(n))

sum = 0   
for a in last_list:
    sum += a
print(*last_list, sum)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
r,c = map(int,input().split())
mat = [[i for i in map(int,input().split())] for _ in range(4)]
c_sum = [0 for _ in range(c+1)]
for i in mat :
    i.append(sum(i))
    for j in range(len(i)) :
        c_sum[j] += i[j]
    
mat.append(c_sum)
for i in mat :
    print(" ".join(list(map(str,i))))

Submission status: Runtime Error

Solution code:
while True:
    n, x = [int(i) for i in input().split()]

    if n == x == 0:
        break

    count = 0
    for s in range(1, n - 1):
        for m in range(s + 1, n):
            for e in range(m + 1, n + 1):
                if x == sum([s, m, e]):
                    count += 1

    print(count)

Submission status: Runtime Error

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

data = []

for ri in range(r):
    data[ri].append([int(i) for i in input().split()])
    data[ri].append(sum(data[ri]))

from pprint import pprint
pprint(data)

Submission status: Runtime Error

Solution code:
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]
    

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]))

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