Problem:
Grading Write a program which reads a list of student test scores and evaluates the performance for each student. The test scores for a student include scores of the midterm examination m (out of 50), the final examination f (out of 50) and the makeup examination r (out of 100). If the student does not take the examination, the score is indicated by -1. The final performance of a student is evaluated by the following procedure:  If the student does not take the midterm or final examination, the student's grade shall be F.  If the total score of the midterm and final examination is greater than or equal to 80, the student's grade shall be A.  If the total score of the midterm and final examination is greater than or equal to 65 and less than 80, the student's grade shall be B.  If the total score of the midterm and final examination is greater than or equal to 50 and less than 65, the student's grade shall be C.  If the total score of the midterm and final examination is greater than or equal to 30 and less than 50, the student's grade shall be D. However, if the score of the makeup examination is greater than or equal to 50, the grade shall be C.  If the total score of the midterm and final examination is less than 30, the student's grade shall be F.  Input The input consists of multiple datasets. For each dataset, three integers m , f and r are given in a line. The input ends with three -1 for m , f and r respectively. Your program should not process for the terminal symbols. The number of datasets (the number of students) does not exceed 50. Output For each dataset, print the grade ( A , B , C , D or F ) in a line. Sample Input 40 42 -1
20 30 -1
0 2 -1
-1 -1 -1 Sample Output A
C
F

Solution (Python):
def test():

	
	output = [0] * 50
	num_student = 0

	
	
	
	
	
	

	while True:

		
		inputs = list(map(int,input().split()))
		
		
		if inputs[0] == -1 and inputs[1] == -1 and inputs[2] == -1:
			output[num_student] = 5
			break

		
		if inputs[0] == -1 or inputs[1] == -1:
			output[num_student] = 4
			num_student += 1
			continue
		
		elif (inputs[0] + inputs[1]) >= 80:
			output[num_student] = 0
			num_student += 1
			continue
		
		elif (inputs[0] + inputs[1]) >= 65:
			output[num_student] = 1
			num_student += 1
			continue
		
		elif (inputs[0] + inputs[1]) >= 50:
			output[num_student] = 2
			num_student += 1
			continue
		
		elif (inputs[0] + inputs[1]) >= 30:
			output[num_student] = 3
			if inputs[2] >= 50:
				output[num_student] = 2
			num_student += 1
			continue
		
		else:
			output[num_student] = 4
			num_student += 1
			continue

	for i in range(num_student):
		if output[i] == 0:
			print("A")
		elif output[i] == 1:
			print("B")
		elif output[i] == 2:
			print("C")
		elif output[i] == 3:
			print("D")
		elif output[i] == 4:
			print("F")


if __name__ == "__main__":
	test()

Solution (Python):
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")

Solution (Python):
while(1):
    m,f,r=map(int,input().split())
    if m==-1&f==-1&r==-1:
        break
    else:
        if (m==-1)|(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')

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

Solution (Python):
while True:
    m, f, r = [int(_) for _ in input().split()]
    if m == f == r == -1:
        exit(0)
    
    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")

Solution (Python):
n=""
while True:
	a=map(int,raw_input().split())
	b=a[0]+a[1]
	if a[0]==-1 & a[1]==-1 & a[2]==-1:
		break
	if b>=80:
		n="A"
	elif b>=65:
		n="B"
	elif b>=50:
		n="C"
	elif b>=30:
		n="D"
		if a[2]>=50:
			n="C"
	else:
		n="F"
	if a[0]==-1 or a[1]==-1:
		n="F"
	print(n)

Solution (Python):
while 1:
    m, f, r = map(int, input().split())
    if m == -1 and f == -1 and r == -1:
        break
    sum = m + f

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

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

Solution (Python):
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:
        print("F")
    else:
        if r < 50:
            print("D")
        else:
            print("C")

Solution (Python):
while True:	
	a,b,c=map(int,input().split())
	if a==-1 and b==-1 and c==-1:
		break
	if	a==-1 or b==-1:
		print("F")
	elif a+b >= 80:
		print("A")
	elif a+b >= 65:
		print("B")
	elif a+b >= 50  or c >=50:
		print("C")
	elif a+b >= 30:
		print("D")
	elif a+b < 30:
		print("F")

Solution (Python):
while True:
	a,b,c=map(int,input().split())
	if a==-1 and b==-1 and c==-1:
		break
	elif a==-1 or b==-1:
		print("F")
	elif a+b >= 80:
		print("A")
	elif a+b>=65:
		print("B")
	elif a+b>=50 or c>=50:
		print("C")
	elif a+b>=30:
		print("D")
	elif a+b<30:
		print("F")

Solution (Python):
while True:	
	a,b,c=map(int,input().split())
	if a==-1 and b==-1 and c==-1:
		break
	if	a==-1 or b==-1:
		print("F")
	elif a+b >= 80:
		print("A")
	elif a+b >= 65:
		print("B")
	elif a+b >= 50  or c >=50:
		print("C")
	elif a+b >= 30:
		print("D")
	elif a+b < 30:
		print("F")

Solution (Python):
while True:
    m,f,r =input().split()
    a = int(m) + int(f)
    if m == '-1' or f == '-1':
        if m == f == r == '-1':break
        else:                       print('F')
    elif a >= 80:                   print('A')
    elif 65 <= a < 80:          print('B')
    elif 50 <= a < 65:          print('C')
    elif 30 <= a < 50:
        if int(r) >= 50:       print('C')
        else:                   print('D')
    else:                       print('F')

Solution (Python):
while True:

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

Solution (Python):
while True:
	a,b,c=map(int,input().split())
	if a == -1 and b == -1 and c == -1:
		break
	elif a == -1 or b == -1:
		print("F")
	elif 80 <= a + b:
		print("A")
	elif 65 <= a + b:
		print("B")
	elif 50 <= a + b:
		print("C")
	elif 30 <= a + b:
		if c  < 50:
			print("D")
		else:
			print("C")
	else:
		print("F")

Solution (Python):
while 1:
 m,f,r=map(int,input().split());s=m+f
 if r<0>s:break
 print('F'if(m*f<0)+(s<30)else'D'if s<50>r else'C'if s<65 else'B'if s<80 else'A')

Solution (Python):
mlist = []
flist = []
rlist = []
 
while(1):
    m, f, r = map(int, input().split())
    if m == -1 and f == -1 and r == -1:
        break
    mlist.append(m)
    flist.append(f)
    rlist.append(r)

for m, f, r in zip(mlist, flist, rlist):
    if m == -1 or f == -1:
        print("F")
    elif 80 <= m + f:
        print("A")
    elif 65 <= m + f < 80:
        print("B")
    elif 50 <= m + f < 65:
        print("C")
    elif 30 <= m + f < 50:
        if 50 <= r:
            print("C")
        else:
            print("D")
    else:
        print("F")

Solution (Python):
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")

Solution (Python):
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
 
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")

Solution (Python):
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
 
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")

Solution (Python):
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")

Solution (Python):
import sys,os,re
from collections import Counter,deque
from operator import itemgetter
from itertools import accumulate
sys.setrecursionlimit(10**6)

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

Solution (Python):
ans = []
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:
        ans.append("F")
    elif m + f < 30:
        ans.append("F")
    elif 30 <=  m + f < 50:
        if r < 50:
            ans.append("D")
        else:
            ans.append("C")
    elif 50 <= m + f < 65:
        ans.append("C")
    elif 65 <= m + f < 80:
        ans.append("B")    
    else:
        ans.append("A")

for a in ans:
    print(a)

Solution (Python):
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')

Solution (Python):
ans = []
while True:
    m,f,r = map(int,input().split())
    x = m+f
    if m==-1 and f==-1 and r==-1:
        break
    
    if m==-1 or f==-1:
        ans.append('F')  
    elif x>=80:
        ans.append('A')
    elif x>=65 and x<80:
        ans.append('B')
    elif x>=50 and x<65 or r>=50:
        ans.append('C')
    elif x>=30 and x<50:
        ans.append('D')
    elif x<30:
        ans.append('F')
        
for i in range(len(ans)):
    print(ans[i])

Solution (Python):
while True:
    m, f, r = map(int, input().split())
    if (m, f, r) == (-1, -1, -1):
        break
    if m == -1 or f == -1:
        grade = "F"
    else:
        total = m + f
        if total >= 80:
            grade = "A"
        elif total >= 65:
            grade = "B"
        elif total >= 50:
            grade = "C"
        elif total >= 30:
            if r >= 50:
                grade = "C"
            else:
                grade = "D"
        else:
            grade = "F"
    print(grade)

Solution (Python):
a=[]
w=""
while(w!="-1 -1 -1"):
    w=input()
    a.append(w)
a.pop()
for st in a:
    s=st.split()
    m=int(s[0])
    f=int(s[1])
    r=int(s[2])
    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 and r<50):
        print("D")
    else:
        print("F")

Solution (Python):
list_gra = []
while True:
    m, f, r = list(map(int, input().split()))
    if m == -1 and f == -1 and r == -1:
        break
    list_gra.append([m, f, r])
for count in range(len(list_gra)):
    if list_gra[count][0] >= 0 and list_gra[count][1] >= 0:
            if sum(list_gra[count][: 2]) >= 80:
                print("A")
            elif 65 <= sum(list_gra[count][: 2]) < 80:
                print("B")
            elif 50 <= sum(list_gra[count][: 2]) < 65:
                print("C")
            elif 30 <= sum(list_gra[count][: 2]) < 50 and list_gra[count][2] < 50:
                print("D")
            elif 30 <= sum(list_gra[count][: 2]) < 50 and list_gra[count][2] >= 50:
                print("C")
            elif 0 <= sum(list_gra[count][: 2]) < 30:
                print("F")
    else:
        print("F")

Solution (Python):
while True:
  scores = list(map(int, input().split()))
  if scores[0] == scores[1] == scores[2] == -1:
    break
  if (scores[0] == -1) or (scores[1] == -1):
    print("F")
  elif scores[0] + scores[1] >= 80:
    print("A")
  elif 80 > scores[0] + scores[1] >= 65:
    print("B")
  elif 65 > scores[0] + scores[1] >= 50:
    print("C")
  elif (50 > scores[0] + scores[1] >= 30) and (scores[2] >= 50):
    print("C")
  elif 50 > scores[0] + scores[1] >= 30:
    print("D")
  else:
    print("F")

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

Solution (Python):
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")

Solution (Python):
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

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

Solution (Python):
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 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 r>=50:
			print('C')
		else:
			print('D')
	else:
		print('F')

Solution (Python):
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")

Solution (Python):
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")

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

Solution (Python):
def grade(m, f, r):
    if m == -1 or f == -1:
        return 'F'

    if 80 <= m+f:
        return 'A'

    if 65 <= m+f < 80:
        return 'B'

    if 50 <= m+f < 65:
        return 'C'

    if 30 <= m+f < 50:
        if 50 <= r:
            return 'C'
        else:
            return 'D'

    return 'F'

while True:
    m, f, r = map(int, input().split())

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

    print(grade(m, f, r))

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

Solution (Python):
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 80<=m+f:
      print("A")
    elif 65<=m+f:
      print("B")
    elif 50<=m+f:
      print("C")
    elif 30<=m+f:
      if r>=50:
        print("C")
      else:
        print("D")
    else:
      print("F")

Solution (Python):
while True:
    middle, final, reexam = map(int, input().split())
    if (middle, final, reexam) == (-1,-1,-1):
        break
    elif middle == -1:
        print('F')
    elif final == -1:
        print('F')
    elif middle + final >= 80:
        print('A')
    elif middle + final >= 65:
        print('B')
    elif middle + final >= 50:
        print('C')
    elif middle + final >= 30:
        if reexam >= 50:
            print('C')
        else:
            print('D')
    else:
        print('F')

Solution (Python):
lilis = []
count = 0
try:
  while True:
    lis = list(map(int,input().split()))
    if lis[0]==lis[1]==lis[2]==-1:
      break
    lilis.append(lis)
    count +=1
  for i in range(count):
    if lilis[i][0]+lilis[i][1]>=80:
      print("A")
    
    elif 80>lilis[i][0]+lilis[i][1]>=65:
      print("B")
      
    elif 65>lilis[i][0]+lilis[i][1]>=50:
      print("C")
      
    elif 50>lilis[i][0]+lilis[i][1]>=30:
      if lilis[i][0]==-1 or lilis[i][1]==-1:
        print("F")
      else:
        if lilis[i][2]>=50:
          print("C")
        else:
          print("D")
    elif 30>lilis[i][0]+lilis[i][1]:
      print("F")
      
except EOFError:
  pass

Solution (Python):
a =  list(map(int, input().split()))
while a != [-1, -1, -1]:
    if a[0]==-1 or a[1]==-1:
        print('F')
    elif a[0]+a[1]>=80:
        print('A')
    elif 65 <= a[0]+a[1] < 80:
        print('B')
    elif 50 <= a[0]+a[1] <65:
        print('C')
    elif 30 <= a[0]+a[1] <50:
        if a[2] >= 50:
            print('C')
        else:
            print('D')
    else:
        print('F')
    a =  list(map(int, input().split()))

Solution (Python):
while True:
	[m, f, r] = [int(i) for i in 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 and 50 <= r:
		print('C')
	elif 30 <= m + f < 50:
		print('D')
	else:
		print('F')

Solution (Python):

while True:

    m,f,r = map(int,input().split())

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


    ans = ""

    if m == -1 or f == -1:
        ans = "F"

    elif m + f >= 80:
        ans = "A"

    elif m + f >= 65:
        ans = "B"

    elif m + f >= 50:
        ans = "C"

    elif m + f >= 30:

        if r >= 50:
            ans = "C"
        else:
            ans = "D"

    else:
        ans = "F"


    print (ans)

Solution (Python):
A=list()

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

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

Solution (Python):
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 80 <= m + f:
        print("A")
    elif 65 <= m + f:
        print("B")
    elif 50 <= m + f:
        print("C")
    elif 30 <= m + f:
        if 50 <= r:
            print("C")
        else:
            print("D")
    else:
        print("F")

Solution (Python):
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 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")

Solution (Python):
def evaluate_grade(m: int, f: int, r: int) -> str:
    if (m == -1 or f == -1):
        if (50 <= r):
            return "C"
        else:
            return "F"

    total_score: int = m + f
    if (80 <= total_score):
        return "A"
    elif (65 <= total_score < 80):
        return "B"
    elif (50 <= total_score < 65):
        return "C"
    elif (30 <= total_score < 50):
        if (50 <= r):
            return "C"
        else:
            return "D"
    else:
        return "F"


if __name__ == "__main__":
    datasets = []

    while(True):
        m, f, r = map(lambda x: int(x), input().split())

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

        datasets.append([m, f, r])

    for (m, f, r) in datasets:
        print(f"{evaluate_grade(m, f, r)}")

Solution (Python):
while True:
    try:
        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:
            print("B")
        elif m + f >= 50 or r >= 50:
            print("C")
        elif m + f >= 30:
            print("D")
        elif m + f < 30:
            print("F")
        
            

    except:
        break

Solution (Python):
while True:
    m,f,r = map(int,input().split())

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

Solution (Python):
while True:
    m,f,r = [int(x) for x in input().split()]
    if (m,f,r)==(-1,-1,-1): break
    s_mf = m + f
    if   m < 0 or f < 0: print('F')
    elif s_mf <  30:     print('F')
    elif s_mf >= 80:     print('A')
    elif s_mf >= 65:     print('B')
    elif s_mf >= 50:     print('C')
    elif r    >= 50:     print('C')
    else:                print('D')

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

Solution (Python):
while True:
    m,f,r = [int(x) for x in input().split()]
    if (m,f,r)==(-1,-1,-1): break
    s_mf = m + f
    if   m < 0 or f < 0: print('F')
    elif s_mf <  30:     print('F')
    elif s_mf >= 80:     print('A')
    elif s_mf >= 65:     print('B')
    elif s_mf >= 50:     print('C')
    elif r    >= 50:     print('C')
    else:                print('D')

Solution (Python):
while True:
  m, f, r = map(int,input().split())
  score = m + f
  
  if m == f == r == -1:
    break
  elif m == -1 or f == -1 :
    print('F')
  elif score >= 80:
    print('A')
  elif score >= 65:
    print('B')
  elif score >= 50 or ( score >= 30 and r >= 50 ) :
    print('C')
  elif score >= 30:
    print('D')
  else:
    print('F')

Solution (Python):
while True:
    value = list(map(int, str(input()).split()))
    if value[0] == -1 and value[1] == -1 and value[2] == -1:
        break



    sum = value[0] + value[1]

    if value[0] == -1 or value[1] == -1:
        print("F")
    elif sum >= 80:
        print("A")
    elif sum >= 65:
        print("B")
    elif sum >= 50:
        print("C")
    elif value[2] >= 50:
        print("C")
    elif sum >= 30:
        print("D")
    else:
        print("F")

Solution (Python):
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')

Solution (Python):
while True:
    [a,b,c]=map(int,input().split())
    if a==-1:
        if b==-1:
            if c==-1:
                break
        grade="F"
    elif b==-1:
        grade='F'
    else:
        if a+b>=80:
            grade='A'
        elif a+b>=65 and a+b<80:
            grade='B'
        elif a+b>=50 and a+b<65:
            grade='C'
        elif a+b>=30 and a+b<50:
            if c>=50:
                grade='C'
            else:
                grade='D'
        elif a+b<30:
            grade='F'
    print(grade)

Solution (Python):
for _ in range(50):
    m, f, r = map(int, input().split())
    total = m + f
    if m == -1 and  f == -1 and r == -1:
        break
    elif m == -1 or f == -1:
        print('F')
    elif total >=80:
        print('A')
    elif total >= 65:
        print('B')
    elif total >= 50:
        print('C')
    elif total >= 30 and r >= 50:
        print('C')
    elif total >= 30:
        print('D')
    else:
        print('F')

Solution (Python):
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 80 <= m + f:
        print('A')
    elif 65 <= m + f < 80:
        print('B')
    elif 50 <= m + f < 65:
        print('C')
    elif 30 <= m + f < 50:
        if 50 <= r:
            print('C')
        else:
            print('D')
    else:
        print('F')

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

Solution (Python):

while True:
    student = list(map(int,input().split()))
    m = student[0]
    f = student[1]
    r = student[2]

    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 80>m+f and m+f>=65:
        print("B")
    elif 65>m+f and m+f>=50:
        print("C")
    elif 50>m+f and m+f>=30:
        if r>=50:
            print("C")
        else:
            print("D")
    else:
        print("F")

Solution (Python):
while True:
    score = 'F'
    m, f, r = map(int,input().split())
    if m == -1 and f == -1 and r == -1:
        break
    total = m + f
    
    if m == -1 or f == -1:
        print(score)
        continue
    
    if total >= 80:
        score = 'A'
    elif total >= 65:
        score = 'B'
    elif total >= 50:
        score = 'C'
    elif total >= 30:
        score = 'D'
        if r >= 50:
            score = 'C'
    
    print(score)

Solution (Python):
while True:
    vals = list(map(int,input().split()))
    score = vals[0]+vals[1]
    if vals[0]==-1 and vals[1]==-1 and vals[2]==-1:
        break
    if vals[0]==-1 or vals[1]==-1:
        print ("F")
    elif score>=80:
        print ("A")
    elif score>=65:
        print ("B")
    elif score>=50:
        print ("C")
    elif score>=30:
        if vals[2]>=50:
            print ("C")
        else:
            print ("D")
    else:
        print ("F")

Solution (Python):
def grade(m, f, r):
	if m == -1 or f == -1: return "F"
	if m + f >= 80: return "A"
	if m + f >= 65: return "B"
	if m + f >= 50 : return "C"
	if m + f < 30: return "F"
	if r >= 50: return "C"
	return "D"

while True:
	m,f,r = map(int, input().split())
	if m == -1 and f == -1 and r == -1: 
		break
	print(grade(m,f,r))

Solution (Python):
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")

Solution (Python):
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")