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: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
all_ele = []
sum_ele = []
h,w = [int(x) for x in input().split()]
for ele in range(h):
    all_ele.append([int(x) for x in input().split()])
    all_ele[ele].append(sum(all_ele[ele]))
all_ele.append([int(x) for x in range(w+1)])
for a in range(w + 1):
    for b in range(h):
        sum_ele.append(all_ele[b][a])

    all_ele[h][a] = sum(sum_ele)
    sum_ele = []

Submission status: Wrong Answer

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, sep='\n')

Submission status: Wrong Answer

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

d = [0] * (c + 1)
print(d)

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: Wrong Answer

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[j][i]+=s[j][i]
s[-1][-1]+=sum(s[4])
for i in s:
    print(*i)

Submission status: Wrong Answer

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

for row in range(r):
    for column in range(c+1):
        if column == (c):
            print(sum(data[row]))
        else: 
            print("%d " %data[row][column],end = "")

Submission status: Wrong Answer

Solution code:
r,c = map(int,input().split())
data = [[0] * (c+1) for i in range(r)]
for row in range(r):
    data[row] = [int(i) for i in input().split()]
    data[row].append(sum(data[row]))
for row in range(r):
    for column in range(c+1):
        if column == (c):
            print(data[row][column])
        else: 
            print("%d " %data[row][column],end = "")
#転置

data_t = []
sumColumn = []
sumSumRow = 0
for column in range(c):
    dataRow = []
    for rowVector in data[:][:c]:
        dataRow.append(rowVector[column])
    data_t.append(dataRow) 

for column in data_t:
    sumColumn.append(sum(column))
for index in range(c):
    print("%d " %sumColumn[index],end = "")
for row in range(r):
    sumSumRow = sumSumRow + sum(data[row][:-1])
print("%d" % sumSumRow)

Submission status: Wrong Answer

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(" ")
    print()

Submission status: Wrong Answer

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(" ")
    print()

Submission status: Wrong Answer

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: Wrong Answer

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

for row in range(H):
    work = list(map(int,input().split()))
    for col in range(W):
        table[row][col] = work[col]

for row in range(H):
    for col in range(W):
        table[row][W] += table[row][col]

for col in range(W):
    for row in range(H):
        table[H][col] += table[row][col]

for row in range(H+1):
    print("%d"%(table[row][0]),end="")
    for col in range(1,W+1):
        print(" %d"%(table[row][col]),end="")
    print()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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)
for i in al:
    print(' '.join([str(v) for v in i]))

Submission status: Wrong Answer

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[1]):
        li_sum[j] += mtx[i][j]
    li_sum[j] += sum(mtx[i])

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

Submission status: Wrong Answer

Solution code:
r,c=map(int, input().split())
S=[]
for ls 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))
print(C)
S.append(C)
print(S)

Submission status: Wrong Answer

Solution code:
r,c=map(int, input().split())
S=[]
for ls 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)
print(S)

Submission status: Wrong Answer

Solution code:
r, c = map(int, input().split())
arr = []
for i in range(r):
    arr.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)])

for line in arr:
    print(*line)

Submission status: Wrong Answer

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

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

for i in range(r):
    sum = 0
    for j in a[i]:
        print(j, end=' ')
        sum += j
    print(sum)

Submission status: Wrong Answer

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

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

b = [0 for i in range(c)]
for i in range(r):
    sum = 0
    for j in a[i]:
        print(j, end=' ')
        sum += j
        b[i] += j
    print(sum)

sum = 0
for j in b:
    print(j, end=' ')
    sum += j
print(sum)

Submission status: Wrong Answer

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

ct = [0 for d in range(c)]
tmp = []
for rc in range(r):
    tmp = [int(i) for i in input().split()]
    total = 0
    for cc in range(c):
        ct[cc] += tmp[cc]
        total += tmp[cc]
        print(tmp[cc], end=' ')
    print(total)
total = sum(ct)
print(' '.join([str(i) for i in tmp]), total)

Submission status: Wrong Answer

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

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

    print()

Submission status: Wrong Answer

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

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)

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

    print()

Submission status: Wrong Answer

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[rc][c] += row_total

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

    print()

Submission status: Wrong Answer

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(x+1):
	print sum([row[i] for row in a]),

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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[c] += src[rc][cc]
src.append(last_row)

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

Submission status: Wrong Answer

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[c] += src[rc][cc]
src.append(last_row)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

r,c = map(int,raw_input().split())
table_list = [[0 for i in range(c)]for j in range(r)]
for k in range(r):
	Sum = 0
	table_list[k] = map(int,raw_input().split())
	for l in table_list[k]:
		Sum += l
	table_list[k].append(Sum)
end_list = []
for m in range(c):
	Sum = 0
	for n in range(r):
		Sum += table_list[n][m]
	end_list.append(Sum)
Sum = 0
for o in end_list:
	Sum += o
end_list.append(Sum)
print(end_list)
table_list.append(end_list)
for p in range(r+1):
	for q in range(c+1):
			if q==c:
				print '%d' %table_list[p][q]
			else :
				sys.stdout.write(str(table_list[p][q]))
				sys.stdout.write(' ')

Submission status: Wrong Answer

Solution code:
height,width=map(int,input().split())
A=[]
for i in range(height):
	A.append([int(j) for j in input().split()])


for i in range(height):
	print(' '.join(map(str,A[i])),str(sum(A[i])))

B=[]
C=[0 for _ in range(width)]
for i in range(width):
	for j in range(height):
		s=0
		s+=A[j][i]
		B.append(s)
	C[i]=sum(B)
	B=[]
print(' '.join(map(str,C)))

Submission status: Wrong Answer

Solution code:
#   ??¨????????°r??¨?????°c???r ?? c ???????´????????????¨?????????????????§???????????¨??????????¨?????????\????????°????????¨???????????????????????°??????
r, c = map(int, input().split())
spreadSheet = [[0 for i in range(c + 1)] for j in range(r + 1)]
#   ??¨??\????????????
for i in range(0, r):
    spreadSheet[i][:c] = map(int, input().split())
    #   print(spreadSheet)
#   ?????????????¨??????????
for i in range(0, r):
    for j in range(0, c):
        spreadSheet[i][c] += spreadSheet[i][j]
#   ?????????????¨??????????
for i in range(0, c + 1):
    for j in range(0, r):
        spreadSheet[r][i] += spreadSheet[j][i]
print(spreadSheet)

Submission status: Wrong Answer

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

# ??? Aizu??§numpy ??????????????£??????
#---------------------------------------------------------------
# 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) )
#---------------------------------------------------------------


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

data = []
csum = [0]*c

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

# print(data)

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

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

# print( sum(csum) )

Submission status: Wrong Answer

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

# ??? Aizu??§numpy ??????????????£??????
#---------------------------------------------------------------
# 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) )
#---------------------------------------------------------------


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

data = []
csum = [0]*c

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

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

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

# print( sum(csum) )

Submission status: Wrong Answer

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: Wrong Answer

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)

Submission status: Wrong Answer

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]


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

Submission status: Wrong Answer

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: Wrong Answer

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: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
r,c=[int(x) for x in input().split()]
s_row=[0 for x in range(c+1)]
for i in range(r):
    row=[int(x) for x in input().split()]
    row.append(sum(row))
    print(" ".join([str(x) for x in row]))
    s_row=[x+y for x,y in zip(s_row,row)]

Submission status: Wrong Answer

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

for x 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)

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: Wrong Answer

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

    for j in range(c):
        a += matrix[i][j]
    matrix[i].append(a)
    for j in range(c+ 1):
        print matrix[i][j],

Submission status: Wrong Answer

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

    for j in range(c):
        a += matrix[i][j]
    matrix[i].append(a)
    for j in range(c+ 1):
        print str(matrix[i][j]),

Submission status: Wrong Answer

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)
print matrix

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: Wrong Answer

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

for i in range(r):
    line = list(map(int, input().split()))
    line.append(sum(line))
    line = map(str, line)
    print(" ".join(line))

Submission status: Wrong Answer

Solution code:
print """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: Wrong Answer

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

A = []

counter = 0
while counter < r:
    raw = [int(x) for x in raw_input().split()]
    A.append(raw + [sum(raw)])
    counter += 1

A.append([sum([A[raw][col] for raw in range(r)]) for col in range(c + 1)])
print(A)

Submission status: Wrong Answer

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(map(str,A[i])))

Submission status: Wrong Answer

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+1):
    print(' '.join(map(str,A[i])))

Submission status: Wrong Answer

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)])
for i in range(r+1):
    print(' '.join(map(str,A[i])))

Submission status: Wrong Answer

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):
        print(arr[i][j],end = ' ')
    print(arr[i][-1])

Submission status: Wrong Answer

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(r+1):
    for j in range(c):
        print(arr[i][j],end = ' ')
    print(arr[i][-1])

Submission status: Wrong Answer

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

for row in ss:
    row.append(sum(row))
    print(' '.join(map(str, row)))

Submission status: Wrong Answer

Solution code:
r,c = map(int,input().split())
ss = [[int(i) for i in input().split()]for j in range(r)]
sum_ss = [0 for i in range(c + 1)]
for row in ss:
    row.append(sum(row))
    sum_ss = [x+y for (x, y) in zip(sum_ss, row)]
    print(' '.join(map(str, row)))

Submission status: Wrong Answer

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

for i in range(r):
	sheet[i] = input().split()
	k = 0
	for j in range(c):
		k += int(sheet[i][j])
	sheet[i].append(k)

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

Submission status: Wrong Answer

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

for i in range(r):
	sheet[i] = input().split()
	k = 0
	for j in range(c):
		k += int(sheet[i][j])
	sheet[i].append(k)

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

Submission status: Wrong Answer

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

matrix = []
for i in range(r):
    matrix.append([int(x) for x in input().split()])
    
for i in range(r):
    for j in range(c):
        print(matrix[i][j], '', end='')
    print(sum(matrix[i]))

for j in range(c):
    csum = 0
    for i in range(r):
        csum += matrix[i][j]
    print(csum, '', end='')
    crsum = 0
    crsum += csum
print(crsum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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):
 S = 0
 for j in range(r):
  S += L[j][c]
 print(str(S) + " ", end="")
print()

Submission status: Wrong Answer

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):
 S = 0
 for j in range(r):
  S += L[j][i]
 print(str(S) + " ", end="")
print()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m = map(int,(input().split()))
a = []
for i in range(n):
    k = [int(i) for i in input().split()]
    k.append(sum(k))
    a.append(k)

for j in a:
    print(' '.join(map(str, j)))

Submission status: Wrong Answer

Solution code:
rc=list(map(int,input().split()))
sheet=[list(map(int,input().split()))+[0] for i in range(rc[0])]
sheet.append([0 for i in range(rc[1]+1)])
for s in sheet:
    s[-1]=sum(s[0:-1])
for i in range(len(sheet)+1):
    r=sum([n[i] for n in sheet[0:-1]])
    sheet[-1][i]=r
for sh in sheet:
    print(*sh)

Submission status: Wrong Answer

Solution code:
r, c = map(int, input().split())
for j in range(r):
    a = [int(i) for i in input().split()]
    for k in a:
        print('{} '.format(k),end='')

    print(sum(a))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
r,c = map(int,input().split())
total = 0
for i in range(r):
    li = list(map(int,input().split()))
    sub = sum(li)
    li.append(sub)
    total += sub
    if i == r-1 : li.append(total)
    strli = " ".join([str(i) for i in li])
    print(strli)

Submission status: Wrong Answer

Solution code:
r,c = map(int,input().split())
rc = tuple([int(x) for x in input().split()] for _ in range(r))
temp = []
total = [0] * (c+1)

for col in rc:
    col.append(sum(col))
    print(*col)
    
    temp = total
    total = []
    for a,b in zip(temp,col):
        total.append(a+b)
total.append(sum(total))
print(*total)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
list = [input().split()]
r = int(list[0][0])
c = int(list[0][1])
i = 0
sum2 = 0
list3 = [0] * c
while i < r:
    sum = 0
    list2 = [input().split()]
    for j in list2[0]:
        print(j, end=' '),
        sum += int(j)
    for k in range(r+1):
        list3[k] += int(list2[0][k])
    print(sum)
    sum2 += sum
    i += 1
for l in list3:
    print(l, end=' ')
print(sum2)

Submission status: Wrong Answer

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: Wrong Answer

Solution code:
#coding: utf-8

r, c = (int(i) for i in input().split())

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

for i in range(r):
    s[i] = input().split()
    s[i].append(0)

for i in range(r):
    for j in range(c):
        s[i][j] = int(s[i][j])

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

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

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