qyliang/CodeNanoFix huggingface dataset:
Buggy code:
import sys

for line in sys.stdin:
    m, f, r = map(int, line.split())
    if m == f == r == -1:
        break
    if m == -1 or f == -1:
        print('F')
    elif (m + f) >= 80:
        print('A')
    elif (m + f) >= 65:
        print('B')
    elif (m + f) >= 50:
        print('C')
    elif (m + f) >= 30:
        if r >= 50:
            print('C')
        else:
            print('D')
    else:
        print('E')

Fixed code:
import sys

for line in sys.stdin:
    m, f, r = map(int, line.split())
    if m == f == r == -1:
        break
    if m == -1 or f == -1:
        print('F')
    elif (m + f) >= 80:
        print('A')
    elif (m + f) >= 65:
        print('B')
    elif (m + f) >= 50:
        print('C')
    elif (m + f) >= 30:
        if r >= 50:
            print('C')
        else:
            print('D')
    else:
        print('F')
Buggy code:
scores = []
while True:
    score = list(map(int, input().split()))
    if score[0] == -1 and score[1] == -1 and score[2] == -1:
        break
    else:
        scores.append(score)

print(scores)
for i in scores:
    mid_exam = i[0]
    final_exam = i[1]
    re_exam = i[2]
    total = i[0] + i[1]
    if mid_exam == -1 or final_exam == -1:
        print("F")
    elif total >= 80:
        print("A")
    elif total in range(65, 80):
        print("B")
    elif total in range(50, 65):
        print("C")
    elif 30 <= total < 50:
        if re_exam >= 50:
            print("C")
        else:
            print("D")
    elif total < 30:
        print("F")

Fixed code:
scores = []
while True:
    score = list(map(int, input().split()))
    if score[0] == -1 and score[1] == -1 and score[2] == -1:
        break
    else:
        scores.append(score)

for i in scores:
    mid_exam = i[0]
    final_exam = i[1]
    re_exam = i[2]
    total = i[0] + i[1]
    if mid_exam == -1 or final_exam == -1:
        print("F")
    elif total >= 80:
        print("A")
    elif total in range(65, 80):
        print("B")
    elif total in range(50, 65):
        print("C")
    elif 30 <= total < 50:
        if re_exam >= 50:
            print("C")
        else:
            print("D")
    elif total < 30:
        print("F")
Buggy code:
while True:
 m,f,r=map(int,raw_input().split())
 if m==-1 and f==-1 and r==-1:break
 if m+f<30 or m==-1 or f==-1:print "F"
 elif m+f<65 or r>=50: print "C"
 elif m+f<50:print "D" 
 elif m+f<80: print "B"
 elif 80<=m+f: print "A"

Fixed code:
while True:
    m, f, r = map(int,input().split())
    if m==-1 and f==-1 and r==-1:
        break
    elif m ==-1 or f==-1:
        print('F')
    elif m+f >= 80:
        print('A')
    elif m+f >= 65 and m+f < 80:
        print('B')
    elif m+f >= 50 and m+f < 65:
        print('C')
    elif m+f >= 30 and m+f < 50:
        if r >= 50:
            print('C')
        else:
            print('D')
    elif m+f < 30:
        print('F')
Buggy code:
while True:
    m, f, r = map(int, input().split())
    sum_score = m + f
    if m != -1 and f != -1:
        if sum_score >= 80:
            print("A")
        elif 65 <= sum_score < 80:
            print("B")
        elif 50 <= sum_score < 65:
            print("C")
        elif 30 <= sum_score < 50:
            if r >= 50:
                print("C")
            else:
                print("D")
        else:
            print("D")
    else:
        if m == -1 and f == -1 and r == -1:
                break
        else:
            print("F")



Fixed code:
while True:
    m,f,r = map(int, input().split())
    if m == -1 and f == -1 and r == -1:
        break
    else:
        if m == -1 or f == -1:
            print("F")
        elif m + f >= 80:
            print("A")
        elif m + f >= 65:
            print("B")
        elif  m + f >= 50:
            print("C")
        elif  m + f >= 30 and r >= 50:
            print("C")
        elif m + f < 30:
            print("F")
        else:
            print("D")
Buggy code:
while True:
    m, f, r = map(int, input().split())
    sum_score = m + f
    if m != -1 and f != -1:
        if sum_score >= 80:
            print("A")
        elif 65 <= sum_score < 80:
            print("B")
        elif 50 <= sum_score < 65:
            print("C")
        elif 30 <= sum_score < 50:
            if r >= 50:
                print("C")
            else:
                print("D")
        else:
            print("D")
    else:
        if m == -1 or f == -1:
            if m == -1 and f == -1 and r == -1:
                break
        else:
            print("F")



Fixed code:
while True:
    m,f,r = map(int,input().split())
    t = m + f
    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        print('F')
    elif t >= 80:
        print('A')
    elif t >= 65 and t < 80:
        print('B')
    elif t >= 50 and t < 65:
        print('C')
    elif t >= 30 and t < 50:
        if r >= 50:
            print('C')
        else:
            print('D')
    else:
        print('F')
Buggy code:
while True:
    points = list(map(int,input().split()))

    if points == [-1,-1,-1]:
        break

    gou = points[0] + points[1]
    if -1 in points[0] or -1 in points[1]:
        print("F")
    elif gou >= 80:
        print("A")
    elif 65 <= gou < 80:
        print("B")
    elif 50 <= gou < 65:
        print("C")
    elif 30 <= gou < 50:
        if points[2] >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")

Fixed code:
while True:
    points = list(map(int,input().split()))

    if points == [-1,-1,-1]:
        break

    gou = points[0] + points[1]
    if points[0]==-1 or points[1]==-1:
        print("F")
    elif gou >= 80:
        print("A")
    elif 65 <= gou < 80:
        print("B")
    elif 50 <= gou < 65:
        print("C")
    elif 30 <= gou < 50:
        if points[2] >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")
Buggy code:
while True:
    m, f, r = [int(i) for i in input().split()]

    if m == f == r == -1:
        break

    elif m == -1 or f == -1:
        print("F")

    elif m + f >= 80:
        print("A")

    elif 65 <= m + f < 80:
        print("B")

    elif 50 <= m + f < 65:
        print("C")

    elif 30 <= m + f < 50:
        if r > 50:
            print("C")
        else:
            print("D")

    else
        print("F")

Fixed code:
while True:
    m, f, r = [int(i) for i in input().strip().split()]
    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        print("F")
    elif m + f >= 80:
        print("A")
    elif m + f >= 65:
        print("B")
    elif m + f >= 50:
        print("C")
    elif m + f >= 30:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")
Buggy code:
while True:
 m,f,r=map(int,input().split())
 if m==f==r==-1 : break
 if((m==-1) or (f==-1))
   print('F')

 if m+f>=80 :
   print('A')

 elif m+f >= 65 :
   print('B')

 elif m+f >= 50 :
   print('C')

 elif m+f >= 30 :
   if r >= 50
    print('C')
   else
    print('D')

 if(m+f<30)
   print('F')



 

Fixed code:
while True:
    m, f, r = map(lambda x: int(x), input().split(" "))
    if (m, f, r) == (-1, -1, -1):
        break
    if m == -1 or f == -1:
        print("F")
    elif m + f >= 80:
        print("A")
    elif m + f >= 65:
        print("B")
    elif m + f >= 50 or r >= 50:
        print("C")
    elif m + f >= 30:
        print("D")
    else:
        print("F")
Buggy code:
while True:
 m,f,r=map(int,input().split())
 if m==f==r==-1 : break

 if (m==-1) or (f==-1):
   print('F')

 if(m+f>=80):
   print('A')

 if (65<= m+f) and (m+f<80) :
   print('B')

 if (50<= m+f) and (m+f<60):
   print('C')

 if(30<= m+f) and (m+f<50):
   if (50<=r):
    print('C')
   else
    print('D')

 if(m+f<30):
   print('F')

Fixed code:
while True:
    m, f, r = map(int,input().split())
    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        print("F")
    elif m + f >= 80:
        print("A")
    elif m + f >= 65:
        print("B")
    elif m + f >= 50:
        print("C")
    elif m + f >= 30:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")
Buggy code:
while True:
    (m, f, r) = [int(i) for i in input().split()]
    if m == f == r == -1:
        break

    s = m + f

    if m == -1 or f == -1 or s < 30:
        print('F')

    elif 80 < s:
        print('A')


    elif 65 < s:
        print('B')

    elif 50 < s or 50 < r:
        print('C')

    elif 30 < s:
        print('D')

Fixed code:
while 1:
    m, f, r = [int(i) for i in input().split()]
    if m == f == r == -1:
        break
    elif m == -1 or f == -1:
        print("F")
    elif m + f >= 80:
        print("A")
    elif 65 <= m + f < 80:
        print("B")
    elif 50 <= m + f < 65:
        print("C")
    elif 30 <= m + f < 50:
        if r >= 50:
            print("C")
        else:
            print("D")
    elif m + f < 30:
        print("F")
Buggy code:
while 1:
 m,f,r=map(int,input().split());s=m+f
 if m*f<-1:break
 if m==-1 or f==-1 or s<30:print('F')
 elif s>79:print('A')
 elif s>64:print('B')
 elif s>49 or r>49:print('C')
 else:print('D')

Fixed code:
while 1:
 m,f,r=map(int,input().split());s=m+f
 if m==f==r<0:break
 if m*f<0 or s<30:print('F')
 elif s>79:print('A')
 elif s>64:print('B')
 elif s>49 or r>49:print('C')
 else:print('D')
Buggy code:
while True:
 m,f,r=map(int,input().split())
 g=m+f
 if m==-1 and f==-1 and r==-1:
  break
 elif m==-1 or g==-1 or g>30:
  print("F")
 elif g>=80:
  print("A")
 elif 65<=g<80:
  print("B")
 elif 50<=g<65 or 30<=g<50 and r>=50:
  print("C")
 elif 30<=g<50:
  print("D")


Fixed code:
while True:
    m, f, r = map(int, input().split())
    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        print('F')
    elif m + f >= 80:
        print('A')
    elif m + f >= 65:
        print('B')
    elif m + f >= 50:
        print('C')
    elif m + f >= 30:
        if r >= 50:
            print('C')
        else:
            print('D')
    else:
        print('F')
Buggy code:
while True:
    m,f,r =[int(i) for i in input().split()]

    if m == f == r ==-1:
        break

    total =m+f
    if m ==-1 or f == -1 or total <30:
        print("F")

    elif total < 50 and r < 50:
        print("D")
    
    elif total <65
        print("C")

    elif total <80:
        pirnt("B")

    else:
         print("A")

Fixed code:
while True:
    m, f, r = [int(i) for i in input().split()]
 
    if m == f == r == -1:
        break
 
    total = m + f
    if m == -1 or f == -1 or total < 30:
        print('F')
 
    elif total < 50 and r < 50:
        print('D')
 
    elif total < 65:
        print('C')
         
    elif total < 80:
        print('B')
         
    else:
        print('A')
Buggy code:
while True:
  m,r,f = map (int,input().split())
  if m ==-1 and f==-1 and r==-1:
      break
  if m== -1 or f ==-1:
      print("F")
  elif m+f>=80:
      print("A")
  elif m+f>=65:
      print("B")
  elif m+f>=50:
      print("C")
  elif m+f>=30:
    if r>=50:
       print("C")
    else:
       print("D")
  else:
      print("F")


Fixed code:
while True:
  m, f, r = list(map(int, input().split()))
  if m==f==r==-1:
    break
  if m==-1 or f==-1:
    print("F")
  elif m+f>=80:
    print("A")
  elif m+f>=65:
    print("B")
  elif m+f>=50 or (m+f>=30 and r>=50):
    print("C")
  elif m+f>=30:
    print("D")
  else:
    print("F")
Buggy code:
while True:
    m, f, r = [int(i) for i in input().split()]

    if m == f == r == -1:
        break

    if m + f <= 80:
        print('A')
    if 65<= m + f <80:
        print('B')
    if 50 <= m+f < 65:
        print('C')
    if 30<= m+f < 50:
        print('D')
    if m+r < 30:
        print('F')
    if 50 <= r:
        print('C')
    if m == -1 or f == -1:
        print('F')
    

Fixed code:
while True:
    m, f, r = [int(i) for i in input().split()]
 
    if m == f == r == -1:
        break
 
    total = m + f
    if m == -1 or f == -1 or total < 30:
        print('F')
 
    elif total < 50 and r < 50:
        print('D')
 
    elif total < 65:
        print('C')
 
    elif total < 80:
        print('B')
         
    else:
        print('A')
Buggy code:
while True:
    m, f, r = [int(i) for i in input().split()]

    if m == f == r == -1:
        break

    total = m + f
    if m == -1 or f == -1 or total< 30:
        print('F')

    elif total < 50 anfd r < 50:
        print('D')

    elif total < 65:
        print('C')
        
    elif total < 80:
        print('B')
        
    else:
        print('A')

Fixed code:


while True:
   m, f, r = [int(i) for i in input().split()]
  
   if m == f == r == -1:
      break
   total = m + f
   if m == -1 or f == -1 or total < 30:
      print("F")
    
   elif total < 50 and r < 50:
      print("D")
 
   elif r >= 50 or total < 65:
      print("C")
    
   elif total < 80:
      print("B")
 
   else:
      print("A")
Buggy code:
while True:
	numlist = list(int(i) for i in input().split())
	mid = numlist[0]
	final = numlist[1]
	retest = numlist[2]

	sum = mid + final

	if mid == -1 or final == -1:
		print("F")
	elif mid == -1 and final == -1 and retest == -1:
		break
	elif sum >= 80:
		print("A")
	elif 80 > sum >= 65:
		print("B")
	elif 65 > sum >= 50:
		print("C")
	elif 50 > sum >= 30 and retest < 50:
		print("D")
	elif 50 > sum >= 30 and retest >= 50:
		print("C")
	elif sum < 30:
		print("F")

Fixed code:
while True:
	numlist = list(int(i) for i in input().split())
	mid = numlist[0]
	final = numlist[1]
	retest = numlist[2]

	sum = mid + final

	if mid == -1 and final == -1 and retest == -1:
		break

	if mid == -1 or final == -1:
		print("F")	
	elif sum >= 80:
		print("A")
	elif 80 > sum >= 65:
		print("B")
	elif 65 > sum >= 50:
		print("C")
	elif 50 > sum >= 30 and retest < 50:
		print("D")
	elif 50 > sum >= 30 and retest >= 50:
		print("C")
	elif sum < 30:
		print("F")
Buggy code:
def evl_score(m,f,r):
    if m == -1 or f == -1:
        ret = 'F'
    elif m + f >= 80:
        ret = 'A' 
    elif m + f >= 65 and m + f < 80:
        ret = 'B' 
    elif m + f >= 50 and m + f < 65: 
        ret = 'C' 
    elif m + f >= 30 and m + f < 50: 
        if r >= 50: 
            ret = 'C' 
        else:
            ret = 'D' 
    else: ret = 'F'
    return ret 
m,f,r =[int(i) for i in input().split(' ')] 
while not (m == -1 and f == -1 and r == -1): 
    m,f,r =[int(i) for i in input().split(' ')] 
    print(evl_score(m,f,r)) 


Fixed code:
def evl_score(m,f,r):
    if m == -1 or f == -1:
        ret = 'F'
    elif m + f >= 80:
        ret = 'A' 
    elif m + f >= 65 and m + f < 80:
        ret = 'B' 
    elif m + f >= 50 and m + f < 65: 
        ret = 'C' 
    elif m + f >= 30 and m + f < 50: 
        if r >= 50: 
            ret = 'C' 
        else:
            ret = 'D' 
    else: 
        ret = 'F'
    return ret 
while True:
    m,f,r =[int(i) for i in input().split(' ')] 
    if (m == -1 and f == -1 and r == -1):
        break 
    print(evl_score(m,f,r))
Buggy code:
while True:
    m, f, r  = [int(_) for _ in input().split()]
    if m == f == r == -1:
        break

    if m == -1 or f == -1:
        rank = "F"
    elif (m + f) >= 80:
        rank = "A"
    elif 65 <= (m + f) < 80:
        rank = "B"
    elif 50 <= (m + f) < 65:
        rank = "C"
    elif 30 <= (m + f) < 50:
        if r >= 50:
            rank = "C"
        else:
            rank = "D"
    else:
        rank = "F"
    print("{:f}".format(m + f), str(m + f), rank)


Fixed code:
while True:
    m, f, r  = [int(_) for _ in input().split()]
    if m == f == r == -1:
        break

    if m == -1 or f == -1:
        rank = "F"
    elif (m + f) >= 80:
        rank = "A"
    elif 65 <= (m + f) < 80:
        rank = "B"
    elif 50 <= (m + f) < 65:
        rank = "C"
    elif 30 <= (m + f) < 50:
        if r >= 50:
            rank = "C"
        else:
            rank = "D"
    else:
        rank = "F"
    print(rank)
Buggy code:
while True:
    m, f, r = list(map(int,input().split()))
    if (m == -1) & (f == -1) & (r == -1):
        break
    if (m + f) < 30 | m == -1 | f == -1:
        print("F")
    elif (m + f) < 50 & r < 50:
        print("D")
    elif (m + f) < 65:
        print("C")
    elif (m + f) < 80:
        print("B")
    else:
        print("A")

Fixed code:
while True:
    m, f, r = list(map(int,input().split()))
    if (m == -1) & (f == -1) & (r == -1):
        break
    if (m + f) < 30 or m == -1 or f == -1:
        print("F")
    elif (m + f) < 50 and r < 50:
        print("D")
    elif (m + f) < 65:
        print("C")
    elif (m + f) < 80:
        print("B")
    else:
        print("A")
Buggy code:
while True:
    m, f, r = [int(i) for i in input().split()]

    if m == f == r == -1:
        break

    total = m + f

    if m == -1 or f == -1 or total < 30:
        print("F")
    
    elif total < 80:
        print("B")
        
    elif total < 65 or r >= 50:
        print("C")
        
    elif total < 50 and r < 50:
        print("D")
        
    else:
        print("A")

Fixed code:
while True:
   m, f, r = [int(i) for i in input().split()]
  
   if m == f == r == -1:
      break
   total = m + f
   if m == -1 or f == -1 or total < 30:
      print("F")
    
   elif total < 50 and r < 50:
      print("D")
 
   elif r >= 50 or total < 65:
      print("C")
    
   elif total < 80:
      print("B")
 
   else:
      print("A")
Buggy code:
while True:
    m,f,r = map(int, input().split())
    if m == f == r ==-1:
        break
    elif (m+f) >= 80:
        print("A")
    elif (m+f) < 80 and (m+f) >= 65:
        print("B")
    elif ((m+f) < 65 and (m+f) >= 50) or (((m+f) < 50 and (m+f) >= 30 and (m != -1 and f != -1)) and r >= 50)
        print("C")
    elif (m+f) < 50 and (m+f) >= 30 and (m != -1 and f != -1):
        print("D")
    else:
        print("F")


Fixed code:
while True:
    m, f, r = map(int, input().split())
    if m == f == r == -1:
        break

    if m == -1 or f == -1:
        print("F")
    elif m + f >= 80:
        print("A")
    elif m + f >= 65:
        print("B")
    elif m + f >= 50:
        print("C")
    elif m + f >= 30:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")
Buggy code:
while True:
   m, f, r = map(int, input().split())
   if m+f+r = -3:
      break
   if m == -1 or f == -1:
      print("F")
   S = m + f
   if S >= 80:
      print("A")
   elif S >= 65 and S < 80:
      print("B")
   elif S >= 50 and S < 65:
      print("C")
   elif S >= 30 and S < 50:
      if r >= 50:
         print("C")
      else:
         print("D")
   else:
      print("F")


Fixed code:
while True :
  m, f, r = map(int, input().split())
  if(m == -1 and f == -1 and r == -1) :
    break
  elif(m == -1 or f == -1) :
    print("F")
  elif(m + f >= 80) :
    print("A")
  elif(65 <= m + f and m + f < 80) :
    print("B")
  elif(50 <= m + f and m + f < 65) :
    print("C")
  elif(30 <= m + f and m + f < 50) :
    if(50 <= r) :
      print("C")
    else :
      print("D")
  else :
    print("F")
Buggy code:
while True:
    m, f, r = map(int, input().split())
    if (m, f, r) = (-1, -1, -1):
        break
    if m+f >= 80:
        print("A")
    elif m+f >= 65 and m+f < 80:
        print("B")
    elif m+f >= 50 and m+f < 65:
        print("C")
    elif m+f >= 30 and m+f < 50:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")

Fixed code:
while True:
    m, f, r = map(int, input().split())
    if (m, f, r) == (-1, -1, -1):
        break
    if m == -1 or f == -1:
        print("F")
    elif m+f >= 80:
        print("A")
    elif m+f >= 65 and m+f < 80:
        print("B")
    elif m+f >= 50 and m+f < 65:
        print("C")
    elif m+f >= 30 and m+f < 50:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")
Buggy code:
def main():

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

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


if __name__ == '__main__':
    main()


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

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

if __name__ == '__main__':
    main()
Buggy 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)


Fixed 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)
Buggy 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)



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

d = [0] * (r + 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)
Buggy 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)


Fixed 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[r])
for i in s:
    print(*i)
Buggy 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)


Fixed 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 range(r):
        tbl[r][i] +=tbl[j][i]
for i in range(r+1):
    m=0
    for j in range(c):
        m += tbl[i][j]
        print(tbl[i][j],end=" ")
    print(m)