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 judge(m, f, r):
    p = m + f
    if (m == -1 or f == -1 or p < 30):
        a = 'F'
    elif (p >= 80):
        a = 'A'
    elif (p >= 65 and p < 80):
        a = 'B'
    elif (p >= 50 and p < 65 or r >= 50):
        a = 'C'
    elif (p >= 30 and p < 50):
        a = 'D'
    return a

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

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

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

Solution (Python):
while True:
    middle,semester,additional = map(int,raw_input().split())
    if middle == -1 and semester == -1 and additional == -1:
        break
    else:
        if middle == -1 or semester == -1 or middle + semester < 30:
            print("F")
        elif middle + semester >= 80:
            print("A")
        elif middle + semester >= 65:
            print("B")
        elif middle + semester >= 50:
            print("C")
        else:
            if additional >= 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 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):
def grade(m, f, r):
    if m == -1 or f == -1:
        return 'F'
    s = m + f
    if s >= 80:
        return 'A'
    if s >= 65:
        return 'B'
    if s >= 50:
        return 'C'
    if s >= 30:
        if r >= 50:
            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:
    points = list(map(int,input().split()))
    if points==[-1,-1,-1]: break
    sum_pt = sum(points[0:2])
    if points[0]==-1 or points[1]==-1 or sum_pt<30: print('F')
    elif sum_pt<50 and points[2]<50: print('D')
    elif sum_pt<65: print('C')
    elif sum_pt<80: print('B')
    else: print('A')

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 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 = [int(_) for _ in input().split()]
  if m == -1 and f == -1 and r == -1:        
    break                                    
  sum = m+f                                  
  if m == -1 or f == -1 or sum < 30:         
    print("F")                               
  else:                                      
    if sum >= 80:                            
      print("A")                             
    elif sum >= 65:                          
      print("B")                             
    elif sum >= 50:                          
      print("C")                             
    else:                                    
      if r >= 50:                            
        print("C")                           
      else:                                  
        print("D")

Solution (Python):
def get_score(medium, final, retry):
    medium_final = medium + final
    if medium == -1 or final == -1:
        return 'F'
    elif 80 <= medium_final:
        return 'A'
    elif 65 <= medium_final:
        return 'B'
    elif 50 <= medium_final:
        return 'C'
    elif 30 <= medium_final:
        if 50 <= retry:
            return 'C'
        else:
            return 'D'
    else:
        return 'F'


while True:
    [medium, final, retry] = [int(x) for x in raw_input().split()]
    if [medium, final, retry] == [-1, -1, -1]:
        break

    print(get_score(medium, final, retry))

Solution (Python):
def get_score(medium, final, retry):
    medium_final = medium + final
    if medium == -1 or final == -1:
        return 'F'
    elif 80 <= medium_final:
        return 'A'
    elif 65 <= medium_final:
        return 'B'
    elif 50 <= medium_final:
        return 'C'
    elif 30 <= medium_final:
        if 50 <= retry:
            return 'C'
        else:
            return 'D'
    else:
        return 'F'


data = []
while True:
    [medium, final, retry] = [int(x) for x in raw_input().split()]
    if [medium, final, retry] == [-1, -1, -1]:
        break
    data.append(get_score(medium, final, retry))

for n in data:
    print(n)

Solution (Python):
while True:
    m, f, r = [int (x) for x in 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 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')

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:
        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):
if __name__ == '__main__':
    
    scores = []
    while True:
        score = [int(x) for x in input().split(' ')]
        if score[0] == -1 and score[1] == -1 and score[2] == -1:
            break
        scores.append(score)

    
    for s in scores:
        midterm_exam = s[0]
        final_exam = s[1]
        re_exam = s[2]
        if midterm_exam == -1 or final_exam == -1:
            grade = 'F'
        elif midterm_exam + final_exam >=80:
            grade = 'A'
        elif midterm_exam + final_exam >= 65:
            grade = 'B'
        elif midterm_exam + final_exam >= 50:
            grade = 'C'
        elif midterm_exam + final_exam < 30:
            grade = 'F'
        elif re_exam >= 50:
            grade = 'C'
        else:
            grade = 'D'
        print(grade)

Solution (Python):
def get_perfomance(score):
    m, f, r = score
    sum_mf = m + f
    if 0 > m or 0 > f:
        return 'F'
    elif 80 <= sum_mf:
        return 'A'
    elif 65 <= sum_mf:
        return 'B'
    elif 50 <= sum_mf:
        return 'C'
    elif 30 <= sum_mf:
        if 50 <= r:
            return 'C'
        else:
            return 'D'
    else:
        return 'F'

if __name__ == '__main__':
    score_list = []
    while True:
        values = [int(x) for x in input().split()]
        if 3 == values.count(-1):
            break
        score_list.append(values)

    for score in score_list:
        print(get_perfomance(score))

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")
        continue
    s = m + f
    if s >= 80:
        print("A")
    elif s >= 65:
        print("B")
    elif s >= 50:
        print("C")
    elif s >=30:
        if r >= 50:
            print("C")
        else:
            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:
		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):
M=[]
F=[]
R=[]
while True:
    m,f,r=map(int,raw_input().split())
    if (m,f,r)==(-1,-1,-1):
        break
    else:
        M.append(m)
        F.append(f)
        R.append(r)
for i in range(len(M)):
    sum=M[i]+F[i]
    if M[i]==-1 or F[i]==-1:
        print('F')
    elif sum>=80:
        print('A')
    elif sum>=65:
        print('B')
    elif sum>=50:
        print('C')
    elif sum>=30:
        if R[i]>=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
    
    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 or r >= 50:
        print("C")
    else:
        print("D")

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

while m!=-1 or f!=-1 or r!= -1:
    score = m+f
    if m==-1 or f ==-1:
        grade = "F"
    elif score >= 80:
        grade = "A"
    elif score < 80 and score >= 65:
        grade = "B"
    elif score < 65 and score >= 50:
        grade = "C"
    elif score < 50 and score >= 30:
        if r>=50:
            grade = "C"
        else:
            grade = "D"
    else:
        grade = "F"

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

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

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

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

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

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

print('\n'.join(score))

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

Solution (Python):
score = []

while True:
    m, f, r = [int(i) for i in input().split()]
    if m == -1 and f == -1 and r == -1:
        break
    score.append([[m],[f],[r]])

for i in range(len(score)):
    if score[i][0][0] == -1 or score[i][1][0] == -1:
        print('F')
    elif score[i][0][0] + score[i][1][0] >= 80:
       print('A')
    elif score[i][0][0] + score[i][1][0] >= 65:
        print('B')
    elif score[i][0][0] + score[i][1][0] >= 50:
        print('C')
    elif score[i][0][0] + score[i][1][0] >= 30:
        print('C') if score[i][2][0] >= 50 else print('D')
    else:
        print('F')

Solution (Python):
'''
ITP-1_7-A
 ??????
????????????????????????????????????????????°????????????????????????????????°??????????????????????????¨??§??????
????????°??????????????°?????????????????????????????°????????????????????????
?????????????????°????????????????¨?????????° m?????????????¨?????????° f??????????¨?????????° r ??§?§?????????????????????????
??????????¨???¨??????????¨???? 50 ????????????m, f ??? 50?????????????¨???? 100 ????????? ???r ??? 100?????§??????
????¨????????????????????????´???????????°??? -1 ??¨????????????
??\??????????????§??????????????????????????????
?????????????¨??????????????¨????????????????????¬????????????´???????????? F???
?????????????¨???¨??????????¨????????¨??????°??? 80 ??\???????????°????????? A ???
?????????????¨???¨??????????¨????????¨??????°??? 65 ??\??? 80 ??????????????°????????? B???
?????????????¨???¨??????????¨????????¨??????°??? 50 ??\??? 65 ??????????????°????????? C???
?????????????¨???¨??????????¨????????¨??????°??? 30 ??\??? 50 ??????????????°????????? D???
??????????????????????¨?????????°??? 50 ??\???????????°????????? C???
?????????????¨???¨??????????¨????????¨??????°??? 30 ??????????????°????????? F???
???Input
?????°??????????????????????????\?????¨??????????????????????????????????????????????????§??????????????§??????????????? m???f???r ??? 1 ???????????????????????????
m???f???r ???????????? -1 ?????¨?????\?????????????????¨????????????
???Output
?????????????????????????????????????????????A???B???C???D???????????? F???????????????????????????????????????
'''
while True:
    
    m, f, r = map(int, input().split())
    mf = m + f

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

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

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

import sys

for l in sys.stdin:
    m, f, r = map(int,l.split())
    if f == -1 and m == -1 and r == -1:
        break
    print (seiseki(m,f,r))

Solution (Python):
import sys


fin = sys.stdin

while True:
	[m, f, r] = list(map(int, fin.readline().split()))

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

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

Solution (Python):
while 1:
    m,f,r=map(int,raw_input().split())
    
    score=m+f
    if m == -1  or  f ==  -1 :
        if m == -1 and f == -1 and r == -1 :
            break
        else: 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):


import sys


def main():
    while True:
        m, f, r = [int(score) for score in sys.stdin.readline().split()]
        if m == f == 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:
            print('C')
        elif 50 > m+f >= 30:
            if r >= 50:
                print('C')
            else:
                print('D')
        elif m+f < 30:
            print('F')


if __name__ == '__main__':
    main()

Solution (Python):


import sys


def main():
    while True:
        m, f, r = [int(score) for score in sys.stdin.readline().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 80 > m+f >= 65:
            print('B')
        elif 65 > m+f >= 50:
            print('C')
        elif 50 > m+f >= 30:
            if r >= 50:
                print('C')
            else:
                print('D')


if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
out_grade = ""

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

    if m==f==r==-1:
        
        break
    
    if m==-1 or f==-1:
        out_grade = "F"
    elif m + f >= 80:
        out_grade = "A"
    elif m + f >= 65:
        out_grade = "B"
    elif m + f >= 50:
        out_grade = "C"
    elif m + f >= 30:
        if r >= 50:
            out_grade = "C"
        else:
            out_grade = "D"
    else:
        out_grade = "F"
    
    print(out_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:
        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())
    rank = ""
    if (m == -1) and (f == -1) and (r == -1):
        break
    if (m == -1) or (f == -1):
        rank = "F"
    elif m+f >= 80:
        rank = 'A'
    elif 80 > m+f >= 65:
        rank = 'B'
    elif 65 > m+f >= 50:
        rank = 'C'
    elif 50 > m+f >= 30:
        if r >= 50:
            rank = 'C'
        else:
            rank = 'D'
    elif 30 > m+f :
        rank = 'F'

    print(rank)

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

    sum = m + f
    if m == -1 or f == -1:
        res = "F"
    elif sum >= 80:
        res = "A"
    elif 65<= sum < 80:
        res = "B"
    elif 50<= sum < 65:
        res = "C"
    elif 30<= sum < 50:
        res = "D"
    else:
        res = "F"

    if res == "D" and r >= 50: res = "C"

    print(res)

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

result = []
grade = []
for i in sys.stdin:
    m, f, r = map(int, i.split())
    if m == f == r == -1:
        break
    result.append([m, f, r])

for j in range(len(result)):
    sum = result[j][0] + result[j][1]
    if result[j][0] == -1 or result[j][1] == -1 or sum < 30:
        grade.append('F')
    elif sum >= 80:
        grade.append('A')
    elif 65 <= sum < 80:
        grade.append('B')
    elif 50 <= sum < 65:
        grade.append('C')
    elif 30 <= sum < 50:
        grade.append('D')
        if result[j][2] >= 50:
            grade[j] = 'C'

for k in range(len(grade)):
    print(grade[k])

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

Solution (Python):
array = []
while True:
    n =input()
    if n == "-1 -1 -1":
        break
    array.append(n.split())
suum = 0
seiseki = []
for i in range(len(array)):
    if array[i][0]!="-1" and array[i][1] != "-1":
        suum = int(array[i][0]) + int(array[i][1])
        if suum >= 80:
            seiseki.append("A")
        elif suum < 80 and suum >= 65:
            seiseki.append("B")
        elif suum < 65 and suum >= 50:
            seiseki.append("C")
        elif suum <50 and suum >= 30:
            if int(array[i][2]) >= 50:
                seiseki.append("C")
            else:
                seiseki.append("D")
        else:
            seiseki.append("F")
    else:
        seiseki.append("F")
    print(seiseki[i])

Solution (Python):
while True:
    m,f,r = [int(x) for x in input().split()]
    if m == f == r == -1:
        break
    else:
        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 30 <= m + f < 50 and r >= 50:
            print("C")
        elif m + f < 30:
            print("F")

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

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

for i in grade:
    print(i)

Solution (Python):


import sys
import os


def input_to_list():
    return list(map(int, input().split()))

for s in sys.stdin:
    m, f, r = list(map(int, s.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):
pupils = []

while True:
    l = list(map(int, input().split()))
    if sum(l) == -3:
        break
    pupils.append(l)

for pupil in pupils:
    score = pupil[0] + pupil[1]
    if pupil[0] == -1 or  pupil[1] == -1:
        rank = 'F'
    elif score >= 80:
        rank = 'A'
    elif score >= 65:
        rank = 'B'
    elif (score >= 50) or (score >= 30 and pupil[2] >= 50):
        rank = 'C'
    elif score >= 30:
        rank = 'D'
    else:
        rank = 'F'
    print(rank)

Solution (Python):
def ifExit(a):
    if a[0] =='-1' and a[1] =='-1' and a[2] =='-1':
        return True
    else:
        return False



l=[]

while(True):
    tmp = input().split()
    if ifExit(tmp): break

    m=int(tmp[0])
    f=int(tmp[1])
    r=int(tmp[2])

    if (m < 0) or (f < 0) :
        l.append('F')
    elif (m+f >= 80):
        l.append('A')
    elif (80 > m+f and m+f >= 65):
        l.append('B')
    elif (65 > m+f and m+f >= 50):
        l.append('C')
    elif (50 > m+f and m+f >= 30):
        if r>=50:
            l.append('C')
        else:
            l.append('D')
    else:
        l.append('F')

print('\n'.join(l))

Solution (Python):
m = 0
f = 0
r = 0
while m!=-1 or f!=-1 or r!=-1:
	m,f,r = [int(i) for i in input().split()]
	sum = m + f
	if m!=-1 or f!=-1 or r!=-1:
		if m == -1 or f == -1:
			print('F')
		elif sum >= 80:
			print('A')
		elif sum >= 65:
			print('B')
		elif sum >= 50:
			print('C')
		elif sum >= 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 and f == -1 and r == -1:
        break

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