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: WA: Presentation Error

Solution code:
# coding: utf-8
"""
4 5
1 1 3 4 5
2 2 2 4 5
3 3 0 1 1
2 3 4 4 6
"""

'''
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
'''

r, c = map(int, input().split())
spreadsheet = []

for _ in range(r):
    spreadsheet.append(list(map(int, input().split())))

# show spreadsheet
for i, row in enumerate(spreadsheet):
    for cell in row:
        print(cell, end=' ')
    print(sum(row))
    spreadsheet[i].append(sum(row))

for i, row in enumerate(range(c + 1)):
    sum_of_sum = 0
    for column in range(r):
        sum_of_sum += spreadsheet[column][row]
    print(sum_of_sum, end='')
    if i != row + 1:
        print(' ', end='')

Submission status: WA: Presentation Error

Solution code:
# coding: utf-8
"""
4 5
1 1 3 4 5
2 2 2 4 5
3 3 0 1 1
2 3 4 4 6
"""

'''
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
'''

r, c = map(int, input().split())
spreadsheet = []

for _ in range(r):
    spreadsheet.append(list(map(int, input().split())))

# show spreadsheet
for i, row in enumerate(spreadsheet):
    print(' '.join(map(str, row)), end='')
    print(' ' + str(sum(row)))
    spreadsheet[i].append(sum(row))

for i, row in enumerate(range(c + 1)):
    sum_of_sum = 0
    for column in range(r):
        sum_of_sum += spreadsheet[column][row]
    print(sum_of_sum, end='')
    if i != row + 1:
        print(' ', end='')

Submission status: WA: Presentation Error

Solution code:
a=input().split()
r=int(a[0])
c=int(a[1])
all_list=list()
for i in range(c+1):
    all_list.append(0)
for i in range(r):
    count=0
    b=input().split()
    b=[int(i) for i in b]
    b.append(sum(b))
    for i in b:
        all_list[count]=all_list[count]+i
        print(i,end=" ")
        count+=1
    print()
for i in all_list:
    print(i,end=" ")

Submission status: WA: Presentation Error

Solution code:
a=input().split()
r=int(a[0])
c=int(a[1])
all_list=list()
for i in range(c+1):
    all_list.append(0)
for i in range(r):
    count=0
    b=input().split()
    b=[int(i) for i in b]
    b.append(sum(b))
    for i in b:
        all_list[count]=all_list[count]+i
        print(str(i),end=" ")
        count+=1
    print()
for i in all_list:
    print(str(i),end=" ")

Submission status: WA: Presentation Error

Solution code:
a=input().split()
r=int(a[0])
c=int(a[1])
all_list=list()
for i in range(c+1):
    all_list.append(0)
for i in range(r):
    count=0
    b=input().split()
    b=[int(i) for i in b]
    b.append(sum(b))
    for i in b:
        all_list[count]=all_list[count]+i
        print(i,end=" ")
        count+=1
    print()
for i in all_list:
    print(str(i),end=" ")

Submission status: WA: Presentation Error

Solution code:
a=input().split()
r=int(a[0])
c=int(a[1])
all_list=list()
for i in range(c+1):
    all_list.append(0)
for i in range(r):
    count=0
    b=input().split()
    b=[int(i) for i in b]
    b.append(sum(b))
    for i in b:
        all_list[count]=all_list[count]+i
        print(i,end="")
        count+=1
    print()
for i in all_list:
    print(i,end="")

Submission status: WA: Presentation Error

Solution code:
a=input().split()
r=int(a[0])
c=int(a[1])
all_list=list()
print()
for i in range(c+1):
    all_list.append(0)
for i in range(r):
    count=0
    b=input().split()
    b=[int(i) for i in b]
    b.append(sum(b))
    for i in b:
        all_list[count]=all_list[count]+i
        print(i,end=" ")
        count+=1
    print()
for i in all_list:
    print(i,end=" ")

Submission status: WA: Presentation Error

Solution code:
m,n=map(int,input().split())
a =[]
for _ in range(m):
    a.append(list(map(int,input().split())))
for index in range(m):
    a[index].append(sum(a[index]))
for a_column in a:
    for num in a_column:
        print(num, end=' ')
    print()
for row_index in range(n+1):
    sum = 0
    for a_column in a:
        sum += a_column[row_index]
    print(sum, end=' ')
print()

Submission status: WA: Presentation Error

Solution code:
m,n=map(int,input().split())
a =[]
for _ in range(m):
    a.append(list(map(int,input().split())))
for index in range(m):
    a[index].append(sum(a[index]))
for a_column in a:
    for num in a_column:
        print(num, end=' ')
    print()
for row_index in range(n+1):
    sum = 0
    for a_column in a:
        sum += a_column[row_index]
    print(sum, end=' ')

Submission status: WA: Presentation Error

Solution code:
m,n=map(int,input().split())
a =[]
for _ in range(m):
    a.append(list(map(int,input().split())))
for index in range(m):
    a[index].append(sum(a[index]))
for a_column in a:
    for num in a_column[:-1]:
        print(num, end=' ')
    print(a_column[-1])
for row_index in range(n+1):
    sum = 0
    for a_column in a:
        sum += a_column[row_index]
    print(sum, end=' ')

Submission status: WA: Presentation Error

Solution code:
m,n=map(int,input().split())
a =[]
for _ in range(m):
    a.append(list(map(int,input().split())))
for index in range(m):
    a[index].append(sum(a[index]))
for a_column in a:
    for num in a_column[:-1]:
        print(num, end=' ')
    print(a_column[-1])
for row_index in range(n+1):
    sum = 0
    for a_column in a:
        sum += a_column[row_index]
    print(sum, end=' ')
print()

Submission status: WA: Presentation Error

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

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

for i in range(r+1):
    for j in range(c+1):
        print("%d " %(table[i][j]),end="")
    print()

Submission status: WA: Presentation 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:
  for j in i:
    print(j,' ',end='')
  print()

Submission status: WA: Presentation 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:
  for j in i:
    print(j,'',end='')
  print()

Submission status: WA: Presentation 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:
  for j in i:
    print(j,'',end='')
  print()
print()

Submission status: WA: Presentation Error

Solution code:
r,c=map(int,input().split())
N=[list(map(int,input().split())) for i in range(r)]
retu=[[0 for i in range(1)] for j in range(1)] 
for j in range(c):
  ret=0
  for i in range(r):
    ret+=N[i][j]
  if j==0:
    retu[0][0]+=ret
  else:
    retu[0].append(ret)
N.extend(retu)
for i in range(r+1):
  tuika=0
  for j in range(c):
    tuika+=N[i][j]
  N[i].append(tuika)
  
for i in range(r+1):
  for j in range(c+1):
    print(N[i][j],"",end="")
  print("")

Submission status: WA: Presentation 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)
print()

Submission status: WA: Presentation Error

Solution code:
r,c=map(int,input().split())
N=[list(map(int,input().split())) for i in range(r)]
retu=[[0 for i in range(1)] for j in range(1)] 
for j in range(c):
  ret=0
  for i in range(r):
    ret+=N[i][j]
  if j==0:
    retu[0][0]+=ret
  else:
    retu[0].append(ret)
N.extend(retu)
for i in range(r+1):
  tuika=0
  for j in range(c):
    tuika+=N[i][j]
  N[i].append(tuika)
  
for i in range(r+1):
  for j in range(c+1):
    print(N[i][j],"",end="")
  if i==(r+1):
    pass
  else:
    print("")

Submission status: WA: Presentation Error

Solution code:
r,c=map(int,input().split())
N=[list(map(int,input().split())) for i in range(r)]
retu=[[0 for i in range(1)] for j in range(1)] 
for j in range(c):
  ret=0
  for i in range(r):
    ret+=N[i][j]
  if j==0:
    retu[0][0]+=ret
  else:
    retu[0].append(ret)
N.extend(retu)
for i in range(r+1):
  tuika=0
  for j in range(c):
    tuika+=N[i][j]
  N[i].append(tuika)
  
for i in range(r+1):
  for j in range(c+1):
    if j!=(c+1):
      print(N[i][j],"",end="")
    else:
      print(N[i][j])
  print("")

Submission status: WA: Presentation Error

Solution code:
i = list(map(lambda x: int(x), input().split(" ")))
count = 0
h = list()
c = [0 for i in range(0, i[1]+1)]
while count < i[0]:
    l = list(map(lambda x: int(x), input().split(" ")))
    l.append(sum(l))
    h.append(l)
    for j, c_ in enumerate(l):
        c[j] += c_
    count += 1
for r_ in h:
    print("%d" % r_[0], end="")
    for c_ in r_[1:]:
        print(" %d" % c_, end="")
    print("")

print("%d" % c[0], end="")
for c_ in c[1:]:
    print(" %d" % c_, end="")

Submission status: WA: Presentation Error

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):
    tmp = [int(x) for x in input().split()]
    for j in range(c + 1):
        if not j == c:
            table[i][j] = tmp[j]
            table[i][c] += table[i][j]
        table[r][j] += table[i][j]

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

Submission status: WA: Presentation 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: WA: Presentation 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: WA: Presentation 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: WA: Presentation 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: WA: Presentation Error

Solution code:
r,c=map(int,raw_input().split())
a=[map(int,raw_input().split()) for _ in xrange(r)]
s=[sum(a[i]) for i in xrange(r)]
sums,l=0,[]
for i in xrange(r):
	a[i].append(s[i])
for i in xrange(c+1):
	for j in xrange(r):
		sums+=a[j][i]
	l.append(sums)
	sums=0
a.append(l)
for i in a:
	for j in xrange(c+1):
		print i[j],
	print ""

Submission status: WA: Presentation Error

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

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

for i in range(r):
    for j in range(c):
        table2[i][c] += table2[i][j]
        table2[r][j] += table2[i][j]
    table2[r][c] += table2[i][c]

ans = ""
for i in range(r+1):
    for j in range(c+1):
        ans += str(table2[i][j])
        if j!=c+1:
            ans += " "
    if i!=r+1:
        ans += "\n"

print ans

Submission status: WA: Presentation Error

Solution code:
def show2dlist(nlist,r,c):
    for x in xrange(0,r):
        for y in xrange(0,c):
            print nlist[x][y],
        print ""
def showlist(nlist,nlistlen):
    for x in xrange(nlistlen):
        print nlist[x],

r,c = map(int,raw_input().split())
table = [[0 for x in xrange(c)] for y in xrange(r)]
i = 0
for x in xrange(r):
    table[i] = map(int,raw_input().split())
    i+=1
# calc table
csumlist =[0 for x in xrange(0,c+1)]
for x in xrange(0,r):
    table[x].append(sum(table[x]))
    for y in xrange(0,c+1):
        csumlist[y] += table[x][y]
show2dlist(table,r,c+1)
showlist(csumlist,c+1)

Submission status: WA: Presentation Error

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

r, c = map(int, raw_input().split())
mat = {}
for i in range(1, r+1):
    col = map(int, raw_input().split())
    for j in range(1, c+1):
        mat[(i, j)] = col[j-1]

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

for j in range(1, c+2):
    mat[(r+1, j)] = 0
    for i in range(1, r+1):
        mat[(r+1, j)] += mat[(i, j)]

for i in range(1, r+2):
    buf = ""
    for j in range(1, c+2):
        buf += str(mat[(i, j)]) +" "
    print buf

Submission status: WA: Presentation Error

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

row = []

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

matrix.append(row)
for i in range(r+1):
    for j in range(c+1):
        print(matrix[i][j],end="")
        if j == c:
            print("")

Submission status: WA: Presentation Error

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

row = []

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

matrix.append(row)
for i in range(r+1):
    for j in range(c+1):
        print(matrix[i][j],end="")
        if j == c and i != r:
            print("")

Submission status: WA: Presentation Error

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

row = []

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

matrix.append(row)
for i in range(r+1):
    for j in range(c+1):
        print(matrix[i][j],end="")
        print(" ",end="")
        if j == c and i != r:
            print("")

Submission status: WA: Presentation Error

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

row = []

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

matrix.append(row)
for i in range(r+1):
    for j in range(c+1):
        print(matrix[i][j],end="")
        if j != c+1:
            print(" ",end="")
        if j == c :
            print("")

Submission status: WA: Presentation Error

Solution code:
N = input().split()
r = int(N[0])
c = int(N[1])
d = [[0 for i in range(c)] for j in range(r)]
for i in range(r):
    data = input().split()
    for j in range(c):
        d[i][j] = int(data[j])
sum2 = [0 for i in range(c)]
for i in range(r):
    line = ''
    for j in range(c):
        line += str(d[i][j])
        line += ' '
        sum2[j] += d[i][j]
    line += str(sum(d[i]))
    print(line)
line2 = ''
for i in range(c):
    line2 += str(sum2[i])
    line2 += ' '
print('{0} {1}'.format(line2, sum(sum2)))

Submission status: WA: Presentation Error

Solution code:
# -*- coding: utf-8 -*-
r,c = [int(a) for a in input().split(' ')]
arr = []
Hsum=0
for x in range(r):
    i =[int(a) for a in input().split(' ')]
    i.append(sum(i))
    arr.append(i)
arr2=[]
for y in range(c+1):
    for z in range(r):
        Hsum += arr[z][y]
    arr2.append(Hsum)
    Hsum=0
arr.append(arr2)

for y in range(r+1):
    for z in range(c+1):
        print(arr[y][z], end =" ")
    else:
        print()

Submission status: WA: Presentation Error

Solution code:
rc=list(map(int,input().split()))
a=[[0 for x in range(rc[1]+1)]for x in range(rc[0]+1)]
for x in range(rc[0]):
    code=list(map(int,input().split()))
    result=0
    for y in range(rc[1]):
        a[x][y]=code[y]
        result+=code[y]
    a[x][rc[1]]=result

for y in range(rc[1]+1):
    result=0
    for x in range(rc[0]):
        result+=a[x][y]
    a[rc[0]][y]=result

for x in range(rc[0]+1):
    string=""
    for y in range(rc[1]+1):
        string+=str(a[x][y])
        if (y!=rc[1]+1):
            string+=" "
    print(string)

Submission status: WA: Presentation Error

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

for i in range(r):
    row = [int(i) for i in input().split()]
    row.append(sum(row))
    array.append(row)
    print(*row)

for i in range(c+1):
    total = 0
    for a in array:
        total += a[i]
    print(total, end=' ')
print('')

Submission status: WA: Presentation Error

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

for i in range(r):
    row = [int(i) for i in input().split()]
    row.append(sum(row))
    array.append(row)
    print(*row)

for i in range(c+1):
    total = 0
    for a in array:
        total += a[i]
    print(total, end=' ')

Submission status: WA: Presentation Error

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

data = [0 for i in range(r)]
temp = [0 for i in range(c)]

for i in range(r):
    data[i] = map(int, raw_input().split())
    
for i in range(r):
    data[i].append(0)
    data[i][c] = sum(data[i])
for i in range(c):
    for j in range(r):
        temp[i] += data[j][i]
temp.append(sum(temp))
data.append(temp)

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

Submission status: WA: Presentation Error

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

data = [0 for i in range(r)]
temp = [0 for i in range(c)]

for i in range(r):
    data[i] = map(int, raw_input().split())
    
for i in range(r):
    data[i].append(0)
    data[i][c] = sum(data[i])
for i in range(c):
    for j in range(r):
        temp[i] += data[j][i]
temp.append(sum(temp))
data.append(temp)

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

Submission status: WA: Presentation Error

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

data = [0 for i in range(r)]
temp = [0 for i in range(c)]

out = ""

for i in range(r):
    data[i] = map(int, raw_input().split())
    
for i in range(r):
    data[i].append(0)
    data[i][c] = sum(data[i])
for i in range(c):
    for j in range(r):
        temp[i] += data[j][i]
temp.append(sum(temp))
data.append(temp)

for i in range(r+1):
    for j in range(c+1):
        out += str(data[i][j]) + " "
    out += '\n'
print out

Submission status: WA: Presentation Error

Solution code:
r,c = 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: WA: Presentation Error

Solution code:
r,c = 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):
    for j in range(c+1):
        print matrix[i][j],
    print ""

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

Submission status: WA: Presentation Error

Solution code:
r,c = 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):
    for j in range(c+1):
        print matrix[i][j],
    print ""

for j in range(c):
    print matrix[r][j],

print matrix[r][c]

Submission status: WA: Presentation Error

Solution code:
max_row, max_col = map(int, input().split(" "))
rows = [[0 for i in range(max_col)] for j in range(max_row)]
row = ""

for i in range(max_row):
    row =  input().split(" ")
    total_row = 0
    for j in range(max_col):
        rows[i][j] = int(row[j])
        total_row = total_row + int(row[j])
    rows[i].append(total_row)
    
#get summery of each columns
total = [0 for i in range(max_col+1)]
for m in range(max_col+1):
    for n in range(max_row):
        total[m] = total[m] + rows[n][m]
rows.append(total)


for i in range(max_row+1):
    out_str = ""
    for j in range(max_col+1):    
        out_str = out_str + " " + str(rows[i][j]) 
    
    print(out_str)

Submission status: WA: Presentation 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+1):
		print(a[i][j],end=' ')
	print()

Submission status: WA: Presentation Error

Solution code:
# coding: utf-8
# Here your code !
 
import math
 
def func():
    try:
        (rows,columns) = [ int(item) for item in input().rstrip().split(" ") ]
        data = [ [ int(item) for item in input().rstrip().split(" ") ] for i in range(rows) ]
    except:
        return inputError()
        
    [item.append(sum(item)) for item in data]
    data.append( [sum( [ item[i] for item in data ] ) for i in range(columns+1) ])
    
    result=""
    for row in data:
        for item in row:
            result += str(item)+" "
        result += "\n"
    
    print(result.rstrip())

def inputError():
    '''
    print("input Error")
    return -1
    '''
 
    print("input Error")
    return -1
     
func()

Submission status: WA: Presentation Error

Solution code:
# coding: utf-8
# Here your code !
 
import math
 
def func():
    try:
        (rows,columns) = [ int(item) for item in input().rstrip().split(" ") ]
        data = [ [ int(item) for item in input().rstrip().split(" ") ] for i in range(rows) ]
    except:
        return inputError()
        
    [item.append(sum(item)) for item in data]
    data.append( [sum( [ item[i] for item in data ] ) for i in range(columns+1) ])
    
    result=""
    for row in data:
        for item in row:
            result += str(item)+" "
        result.rstrip(" ")
        result += "\n"
    
    print(result.rstrip())

def inputError():
    '''
    print("input Error")
    return -1
    '''
 
    print("input Error")
    return -1
     
func()

Submission status: WA: Presentation Error

Solution code:
r,c = map(int, input().split())
L=[]
for i in range(r):
 al = input()
 print(al, end="")
 AL = list(map(int, al.split()))
 S = sum(AL)
 print(" " + str(S))
 AL. append(S)
 L.append(AL)

for i in range(c+1):
 S = 0
 for j in range(r):
  S += L[j][i]
 print(str(S) + " ", end="")
print()

Submission status: WA: Presentation Error

Solution code:
r,c = map(int, input().split())
L=[]
for i in range(r):
 al = input()
 print(al, end="")
 AL = list(map(int, al.split()))
 S = sum(AL)
 print(" " + str(S))
 AL. append(S)
 L.append(AL)

for i in range(c+1):
 S = 0
 for j in range(r):
  S += L[j][i]
 print(str(S) + " ", end="")

Submission status: WA: Presentation 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):
    l = list(map(int, input().split()))
    for j in range(c):
        a[i][j] = l[j]
        a[i][c] += a[i][j]

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

for i in range(r+1):
    for j in range(c+1):
        print(str(a[i][j]) + " ", end="")
    print()

Submission status: WA: Presentation Error

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

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

for i in range(r):
    r_total = sum(a[i])
    a[i].append(r_total)

c_total = []

for j in range(c+1):
    s = 0
    for k in range(r):
        s += a[k][j]
    c_total.append(s)

a.append(c_total)

for z in range(r+1):
    for w in range(c+1):
        print(a[z][w],end=" ")
    print()

Submission status: WA: Presentation 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 r in q:
	for a in r:
		print(a, end = ' ')
	print()

Submission status: WA: Presentation 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][j], end='')
		if (j != (r+1)):
			print(' ', end='')
	print()

Submission status: WA: Presentation 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][j], end='')
		if (j != (c+1)):
			print(' ', end='')
	if (i != (j+1) ):
		print()

Submission status: WA: Presentation 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][j], end='')
		if (j != (c+1)):
			print(' ', end='')
	if (i != (r+1) ):
		print()

Submission status: WA: Presentation 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][j], end='')
		if (j != (c)):
			print(' ', end='')
	if (i != (r) ):
		print()

Submission status: WA: Presentation Error

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],end=' ')
    print()

Submission status: WA: Presentation Error

Solution code:
n, m = map(int, input().split())
mat = [[0 for x in range(m+1)] for y in range(n+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: WA: Presentation Error

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

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

l_row = []

for k in range(c + 1):
    c_sum = 0
    for l in range(r):
        c_sum += args[l][k]
    l_row.append(c_sum)        

for m in range(r):
    for item in args[m]:
        print(item, end=' ')
    print()

for sums in l_row:
    print(sums, end=' ')
print()

Submission status: WA: Presentation Error

Solution code:
r,c = map(int,input().split())
num=[]
r_sum =[]
for i in range(r):
    num.append([int(i) for i in input().split()])
for i in range(r):
    line_sum = 0
    for j in range(c):
        line_sum += num[i][j]
    num[i].append(line_sum)
for i in range(c+1):
    row_sum = 0
    for j in range(r):
        row_sum += num[j][i]
    r_sum.append(row_sum)
num.append(r_sum)
for i in range(len(num)):
    print(' '+' '.join(str(i) for i in num[i]))

Submission status: WA: Presentation Error

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