Buggy python submission (verdict: Runtime Error):
r, c = map(int, input().split())
mat = []
for i in range(r):
 mat.append(list(map(int, input().split())))

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

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

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

Fixed submission:
r, c = map(int, input().split())
mat =[]

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

tsum = 0

for x in range(r):
 rsum = 0
 for y in range(c):
  rsum += mat[x][y]
  tsum == 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]
  tsum += 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):
 print("{0} ".format(mat[r][x]), end='')
print(tsum)

Buggy python submission (verdict: Runtime Error):
r, c = map(int, input().split())
mat = []
for i in range(r):
 mat.append(list(map(int, input().split())))
mat.append([])

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

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

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

Fixed submission:
r, c = map(int, input().split())
mat =[]

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

tsum = 0

for x in range(r):
 rsum = 0
 for y in range(c):
  rsum += mat[x][y]
  tsum == 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]
  tsum += 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):
 print("{0} ".format(mat[r][x]), end='')
print(tsum)

Buggy python submission (verdict: Runtime Error):
r, c = map(int, input().split())
mat = []
for i in range(r):
 mat.append(list(map(int, input().split())))
mat.append([])

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

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

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

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

Fixed submission:
r, c = map(int, input().split())
mat =[]

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

tsum = 0

for x in range(r):
 rsum = 0
 for y in range(c):
  rsum += mat[x][y]
  tsum == 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]
  tsum += 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):
 print("{0} ".format(mat[r][x]), end='')
print(tsum)

Buggy python submission (verdict: Runtime Error):
r, c = map(int, input().split())
mat = []
for i in range(r):
 mat.append(list(map(int, input().split())))
mat.append([])

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

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

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

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

Fixed submission:
r, c = map(int, input().split())
mat =[]

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

tsum = 0

for x in range(r):
 rsum = 0
 for y in range(c):
  rsum += mat[x][y]
  tsum == 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]
  tsum += 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):
 print("{0} ".format(mat[r][x]), end='')
print(tsum)

Buggy python submission (verdict: Runtime Error):
r, c = map(int, input().split())
mat =[]

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

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

mat.append([])

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

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

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

Fixed submission:
r, c = map(int, input().split())
mat =[]

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

tsum = 0

for x in range(r):
 rsum = 0
 for y in range(c):
  rsum += mat[x][y]
  tsum == 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]
  tsum += 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):
 print("{0} ".format(mat[r][x]), end='')
print(tsum)