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 func():
    data=[]
    while(True):
        try:
            line=[ int(item) for item in input().rstrip().split(" ") ]
            if(line == [-1, -1, -1]):
                break
            data.append(line)
        except EOFError:
            break
        except:
            return inputError()

    result=""
    for score in data:
        if( (score[0]<0) or (score[1]<0)):
            result+="F\n"
        elif(score[0]+score[1] >= 80):
            result+="A\n"
        elif(score[0]+score[1] >= 65):
            result+="B\n"
        elif(score[0]+score[1] >= 50):
            result+="C\n"
        elif(score[0]+score[1] >= 30):
            if(score[2] >= 50):
                result+="C\n"
            else:
                result+="D\n"
        else:
            result+="F\n"
    
    print(result.rstrip())

def inputError():
    print("input error")
    return -1

func()

Solution (Python):
grades = []
lettergrade = []

while True:
    m, f, r = input().split()    
    m = int(m)
    f = int(f)
    r = int(r)
    if m == f == r == -1:
        break
    grades.append([m, f, r])

for x in grades:
    if x[0] == -1 or x[1] == -1 or (x[0] + x[1] >= 0 and x[0] + x[1] < 30):
        lettergrade.append('F')
    elif x[0] + x[1] >= 80:
        lettergrade.append('A')
    elif x[0] + x[1] >= 65 and x[0] + x[1] < 80:
        lettergrade.append('B')
    elif (x[0] + x[1] >= 50 and x[0] + x[1] < 65) or (x[2] >= 50):
        lettergrade.append('C')
    else:
        lettergrade.append('D')

print("\n".join(lettergrade))

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

Solution (Python):

while True:
    m,f,r = map(int,raw_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 and m + f < 80:
        print('B')
    elif m + f >= 50 and m + f < 65 or r >= 50:
        print('C')
    elif m + f >= 30 and m + f < 50:
        print('D')
    elif m + f <= 29:
        print('F')

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

Solution (Python):
m=0
f=0
r=0
while True:
    m,f,r=map(int,input().split())
    s=m+f
    if m==-1 and f==-1 and r==-1:
        break
    elif 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):
from sys import stdin

def main():
    for l in stdin:
        m ,f, r = map(int, l.split(' '))

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

        print(judge(m, f, r))

def judge(m, f, r):
    if -1 == m or -1 == f:
        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:
        return 'C' if 50 <= r else 'D'

    return 'F'

if __name__ == '__main__': main()

Solution (Python):
L = []
m, f, r = map(int, input().split())
while not(m == -1 and f == -1 and r == -1):
 L.append([m, f, r])
 m, f, r = map(int, input().split())
 
for i in L:
 if i[0] == -1 or i[1] == -1:
  print("F")
 elif i[0] + i[1] >= 80:
  print("A")
 elif i[0] + i[1] >= 65:
  print("B")
 elif i[0] + i[1] >=  50:
  print("C")
 elif i[0] + i[1] >= 30 and i[2] >=50:
  print("C")
 elif i[0] + i[1] >= 30:
  print("D")
 else:
  print("F")

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

Solution (Python):
while True:
    m, f, r = map(int, input().split())
    if not (~ m or ~ f or ~ r):
        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')

Solution (Python):
while True:
    m, f, r = map(int, raw_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:
        print "C"
    elif m + f >= 30 and r >= 50:
        print "C"
    elif m + f >= 30:
        print "D"
    else:
        print "F"

Solution (Python):


m = 0
f = 0
r = 0

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

Solution (Python):
while 1:
    mid,term,add = map(int,input().split())
    if mid == -1 and term == -1 and add == -1:
        break
    s = mid + term
    if mid == -1 or term == -1:
        rank = 'F'    
    elif s >= 80:
        rank = 'A'
    elif s >= 65:
        rank = 'B'
    elif s >= 50:
        rank = 'C'
    elif s >= 30:
        if add >= 50:
            rank = 'C'
        else:
            rank = 'D'
    else:
        rank = 'F'
    print(rank)

Solution (Python):
while True:
    s = input().split(" ")
    m = int(s[0])
    f = int(s[1])
    r = int(s[2])
    if m == -1 and f == -1 and r == -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")
    else:
        if r >= 50:
            print("C")
        else:
            print("D")

Solution (Python):
while True:
    m, f, r = map(int,input().split())
    if m + f < 0:
        break
    if m < 0 or f < 0:
        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\
    or r >= 50:
        print("C")
    elif m + f >= 30:
        print("D")
    elif m + f < 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 80 > m + f >= 65:
        print('B')
    elif 65 > m + f >= 50 or r >= 50:
        print('C')
    elif 50 > m + f >= 30:
        print('D')
    else:
        print('F')

Solution (Python):
while True:
    m, f, r = list(map(int, 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')

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

Solution (Python):
while True:
    m, f, r = list(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")
    else:
        print ("F")

Solution (Python):
while 1 :
    x,y,z=[int(i) for i in input().split()]
    if x==y==z==-1:
        break
    if x==-1 or y==-1:
        print('F')
    elif x+y>=80:
        print('A')
    elif x+y>=65:
        print('B')
    elif x+y>=50:
        print('C')
    elif x+y>=30:
        if z>=50:
            print('C')
        else:
            print('D')
    else:
        print('F')

Solution (Python):
def grading(m,f,r):
	mf = m+f
	if mf >= 80:
		grade = 'A'
	elif mf >= 65:
		grade = 'B'
	elif mf >= 50:
		grade = 'C'
	elif mf >= 30:
		grade = 'D'
	else:
		grade = 'F'
	if -1 in [m,f]:
		grade = 'F'
	if grade == 'D' and r >= 50:
		grade = 'C'
	return grade

data = []
while True:
	temp = [int(s) for s in input().split(' ')]
	if temp == [-1,-1,-1]:
		break
	else:
		data.append(temp)

grades = [grading(*points) for points in data]
[print(g) for g in grades]

Solution (Python):


"""
??´?????????
"""

while True:
    inp = input().strip().split(" ")
    m = int(inp[0])
    f = int(inp[1])
    r = int(inp[2])

    
    if m < 0 and f < 0 and r < 0 :
        break
    
    if m < 0 or f < 0 :
        S = "F"
    else:
        t = m + f
        if t < 30:
            S = "F"
        elif t < 50:
            if r >= 50:
                S = "C"
            else:
                S = "D"
        elif t < 65:
            S = "C"
        elif t < 80:
            S = "B"
        else:
            S = "A"

    print(S)

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:
    m,f,r=list(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<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")

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

  print(ans)

Solution (Python):
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 s < 50 and r < 50: 
        print('D')
 elif s < 65: 
        print('C')
 elif s < 80:
        print('B')
 else:
        print('A')

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

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

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

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

Solution (Python):
while True:
    m,f,r = map(int,input().split())
    if m == f == 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:
        print("C")
    elif m+f >= 30:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")

Solution (Python):
while True:
    m, f, r = (int(x) for x in input().split())
    if (m, f, r) == (-1, -1, -1):
        break
    sum_score = m + f

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

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

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

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

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

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

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

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

Solution (Python):
ret = []
while True:
    m, f, r = map(int, raw_input().split())
    if (m,f,r) == (-1, -1, -1):
        break
    if m == -1 or f == -1:
        ret += 'F'
    elif 80 <= m + f:
        ret += ['A']
    elif 65 <= m + f < 80:
        ret += ['B']
    elif 50 <= m + f < 65:
        ret += ['C']
    elif 30 <= m + f < 50 and 50 <= r:
        ret += ['C']
    elif 30 <= m + f < 50 and r < 50:
        ret += ['D']
    elif m + f < 30:
        ret += ['F']

for i in ret:
    print i

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

Solution (Python):


import sys, math, os


PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


while True:
    m, f, r = [int(_) for _ in 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:
    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")

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

Solution (Python):

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


while 1:
    mfr = input().split()
    m = int(mfr[0])
    f = int(mfr[1])
    r = int(mfr[2])

    if m == -1 and f == -1 and r == -1:
        break
    else:
        print(eval(m, f, r))

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

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

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

Solution (Python):
m, f, r = map(int, input().split())
while m != -1 or f != -1 or r != -1:
	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")
	m, f, r = map(int, input().split())

Solution (Python):
while 1:
    list = [input().split()]
    m = int(list[0][0])
    f = int(list[0][1])
    r = int(list[0][2])
    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 and m + f < 50 and r < 50 :
        print("D")
    elif m + f < 30 :
        print("F")

Solution (Python):
m = 0
f = 0
r = 0

while(True):
    I = input().split()
    m = int(I[0])
    f = int(I[1])
    r = int(I[2])
    if m == -1 and f == -1 and r == -1:
        break
    score = m + f
    if m == -1 or f == -1:
        print('F')
        continue
    if score >= 80:
        print('A')
    if 65 <= score and score < 80:
        print('B')
    if 50 <= score and score < 65:
        print('C')
    if 30 <= score and score < 50:
        if r >= 50:
            print('C')
        else:
            print('D')
    if score < 30:
        print('F')

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

while m+f+r != -3:
    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")

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

Solution (Python):
while True:
    m, f, r = map(int, input().split())
    if m == f == r == -1:
        break
    if m + f < 30 or 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 or 30 <= m + f < 50 and r >= 50:
        print("C")
    else :
        print("D")

Solution (Python):
def f(s):
    m, f, r = list(map(int, s.split()))
    if m == -1 or f == -1:
        return "F"

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

while True:
    s = input()
    if s == "-1 -1 -1":
        break
    print(f(s))

Solution (Python):
grade=[]

while True:
    test_point=[]
    test_point=input().split()
    test_point[0]=int(test_point[0])
    test_point[1]=int(test_point[1])
    test_point[2]=int(test_point[2])
    if test_point[0]==-1 and test_point[1]==-1 and test_point[2]==-1:
        break
    elif test_point[0]==-1 or test_point[1]==-1:
        grade.append('F')
    elif test_point[0]+test_point[1]>=80:
        grade.append('A')
    elif test_point[0]+test_point[1]<80 and test_point[0]+test_point[1]>=65:
        grade.append('B')
    elif test_point[0]+test_point[1]<65 and test_point[0]+test_point[1]>=50:
        grade.append('C')
    elif test_point[0]+test_point[1]<50 and test_point[0]+test_point[1]>=30:
        if test_point[2]>=50:
            grade.append('C')
        else:
            grade.append('D')
    elif test_point[0]+test_point[1]<30:
        grade.append('F')

for i in range(0,len(grade)):
    print(grade[i])

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

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

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

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

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

Solution (Python):
while True:

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

    total = m+f

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

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

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

    elif 30<=m+f<50:
        print("D")

    else:
        print("F")

Solution (Python):
M, F, R = map(int, input().split())
while not (M == -1 and F == -1 and R == -1):
 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")

 M, F, R = map(int, input().split())

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

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

Solution (Python):


while True:
    m, f, r = map(int,input().split())
    if r == m == f == -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")

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

Solution (Python):

while(1):
	m, f, r = [int(x) for x in input().split()]
	if(m+f+r == -3):
		break
	else:
		temp = m+f
		if( (m==-1) or (f==-1) ):
			print("F")
		elif (temp >= 80):
			print("A")
		elif (temp >= 65):
			print("B")			
		elif (temp >= 50):
			print("C")		
		elif (temp >= 30):
			if (r >= 50):
				print("C")
			else:
				print("D")
		else:
			print("F")