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):
import sys

def seiseki(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"
        return "D"
    elif m + f < 30:
        return "F"

for line in sys.stdin:
    m, f, r = map(int, line.strip().split())
    if m == f == r == -1:
        break

    print seiseki(m, f, r)

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

Solution (Python):
import sys
def main():
    for line in sys.stdin:
        m, f, r = map(int, line.split())
        if m == -1 and f == -1 and r == -1:
            break
        else:
            total = m + f
            if m == -1 or f == -1:
                print("F")
            elif total >= 80:
                print("A")
            elif 65 <= total < 80:
                print("B")
            elif 50 <= total < 65:
                print("C")
            elif 30 <= total < 50:
                if r >= 50:
                    print("C")
                else:
                    print("D")
            elif total < 30:
                print("F")


if __name__ == "__main__":
    main()

Solution (Python):
while True:
	mark = map(int, raw_input().split())
	chukan = mark[0]
	kimatu = mark[1]
	saishi = mark[2]
	wa = chukan + kimatu
	if chukan == -1 and kimatu == -1 and saishi == -1:
		break
	elif chukan == -1 or kimatu == -1:
		print("F")
	elif 80 <= wa:
		print("A")
	elif 65 <= wa and wa < 80:
		print("B")
	elif 50 <= wa and wa < 65:
		print("C")
	elif 30 <= wa and wa < 50:
		if 50 <= saishi:
			print("C")
		else:
			print("D")
	else:
		print("F")

Solution (Python):
def main():

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

main()

Solution (Python):

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

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

    if m == -1 and f == -1 and r == -1:
        quit()
    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')

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

Solution (Python):

"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_7_A&lang=jp

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    while True:
        m, f, r = map(int, input().split())
        if m == -1 and f == -1 and r == -1:
            break
        grade = '@'
        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:
            if r >= 50:
                grade = 'C'
            else:
                grade = 'D'
        else:
            grade = 'F'
        print(grade)



if __name__ == '__main__':
    main(sys.argv[1:])

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")
    elif (m+f < 30):
            print("F")

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

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

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

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

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

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


import fileinput
import math

def main():

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

if __name__ == '__main__':
    main()

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):
def main():
    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")
            continue

        m = m if m > -1 else 0
        f = f if f > -1 else 0
        r = r if r > -1 else 0
        mf = m + f

        if mf >= 80:
            print("A")
        elif 65 <= mf < 80:
            print("B")
        elif 50 <= mf < 65:
            print("C")
        elif 30 <= mf < 50:
            if r >= 50:
                print("C")
            else:
                print("D")
        else:
            print("F")


if __name__ == "__main__":
    main()

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

res = []
while True:
    m, f, v = map(int, input().split())
    if m == f == v == -1:
        break;
    res.append(seiseki(m, f, v))

for i in range(len(res)):
    print(res[i])

Solution (Python):
while 1:
 m,f,r=map(int,input().split())
 if m==f==r==-1:break
 if m==-1 or f==-1:print('F')
 elif m+f>79:print('A')
 elif m+f>64:print('B')
 elif m+f>49:print('C')
 elif m+f>29:print('C') if r>49 else print('D')
 else:print('F')

Solution (Python):
while 1:
 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>79:print('A')
 elif s>64:print('B')
 elif s>49:print('C')
 elif s>29:print('C') if r>49 else print('D')
 else:print('F')

Solution (Python):
while 1:
 m,f,r=map(int,input().split());s=m+f
 if m==f==r==-1:break
 if m==-1 or f==-1 or s<30:print('F')
 elif s>79:print('A')
 elif s>64:print('B')
 elif s>49 or r>49:print('C')
 else:print('D')

Solution (Python):
while 1:
 m,f,r=map(int,input().split());s=m+f
 if m==f==r==-1:break
 if m*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,input().split());s=m+f
 if m==f==r<0:break
 if m*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,input().split());s=m+f
 if m==f==r<0:break
 if m*f<0 or s<30:print('F')
 elif s>79:print('A')
 elif s>64:print('B')
 elif s>49 or r>49:print('C')
 else:print('D')

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

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

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:
        print('F')
        continue
    if s >= 80:
        rank = 'A'
    elif 65 <= s < 80:
        rank = 'B'
    elif 50 <= s < 65 or (30 <= s < 50 and r >= 50):
        rank = 'C'
    elif 30 <= s < 50:
        rank = 'D'
    elif s < 30:
        rank = 'F'
    print(rank)

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

Solution (Python):
while True:
    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 < 80 and sum >= 65:
        print('B')
    elif sum < 65 and sum >= 50:
        print('C')
    elif sum < 50 and sum >= 30:
        if r >= 50 :
            print('C')
        else:
            print('D')
    else:
        print('F')

Solution (Python):
while 1:
	m, f, r = map(int, raw_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 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):
def grade(score_list):
    chukan = score_list[0]
    kimatu = score_list[1]
    saishi = score_list[2]
    pre_score = chukan + kimatu
    if chukan == -1 or kimatu == -1 or pre_score < 30:
        return "F"
    elif pre_score >= 80:
        return "A"
    elif 65 <= pre_score < 80:
        return "B"
    elif 50 <= pre_score < 65:
        return "C"
    elif 30 <= pre_score < 50:
        if saishi >= 50:
            return "C"
        else:
            return "D"

while True:
    score = list(map(int, list(input().split())))
    if score[0] == -1 and score[1] == -1 and score[2] == -1:
        break
    else:
        rate = grade(score)
        print(rate)

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

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

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

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:
        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 solve(m, f, r):
    if (m == -1 or f == -1) or m + f < 30:
        return "F"
    for a, b in ((80, "A"), (65, "B"), (50, "C")):
        if m + f >= a:
            return b
    if r >= 50:
        return "C"
    return "D"
while True:
    m, f, r = map(int, input().split())
    if m == f == r == -1:
        break
    print(solve(m, f, r))

Solution (Python):
while 1:
 m,f,r=map(int,input().split());s=m+f
 if m==f==r<0:break
 if m*f<0 or s<30:print('F')
 elif s<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())
    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(1):
    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"
    if m == -1:
        m = 0
    elif f == -1:
        f = 0

    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) = input().rstrip('\r\n').split(' ')
  m = int(m)
  f = int(f)
  r = int(r)
  if m == -1 and f == -1 and r == -1:
    break

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

  mf = m + f

  if 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')
  else:
    print('F')

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

Solution (Python):
while 1:
 m,f,r=map(int,input().split());s=m+f
 if m==f==r<0:break
 if(m*f<0)|(s<30):print('F')
 elif(s<50)*(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,input().split());s=m+f
 if m==f==r<0:break
 if m*f<0 or s<30:print('F')
 elif(s<50)*(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,input().split());s=m+f
 if m==f==r<0:break
 if m*f<0 or s<30:print('F')
 elif s>79:print('A')
 elif s>64:print('B')
 elif s>49 or r>49:print('C')
 else:print('D')

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

Solution (Python):
'''
先に基準を変数で設定して、whileで回すと見た目もきれいだし、あとから調整も楽。
ついでだからclass化する？しなくてもいいけど。
while意味ない
'''
s = []

while True:
    t = input()
    if t == "-1 -1 -1":
        break
    else:
        s.append(list(map(int, t.split())))
        






a, b, c, d = 80, 65, 50, 30

g = []

for i in range(len(s)):
    r = s[i][0] + s[i][1]
    
    if s[i][0]==-1 or s[i][1]==-1:
        g.append("F")
        
    elif r >= a:
        g.append("A")
    elif r >= b:
        g.append("B")
    elif r >= c:
        g.append("C")
    elif r >= d:
        if s[i][2] >= 50:
            g.append("C")
        else:
            g.append("D")
    else:
        g.append("F")
    
[print(g[i]) for i in range(len(g))]

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

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")
    elif m + f >= 0:
        print("F")

Solution (Python):
from sys import stdin
for line in stdin:
    mid, final, make = map(int, line.split())
    if mid == -1 and final == -1 and make == -1:
        break
    elif mid == -1 or final == -1:
        print('F')
    elif mid + final >= 80:
        print('A')
    elif mid + final >= 65:
        print('B')
    elif mid + final >= 50:
        print('C')
    elif mid + final >= 30:
        if make >= 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 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(i) for i in 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 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 < 30:
        print("F")

Solution (Python):
for _ in range(10000):
    res = list(map(int,input().split()))
    if res == [-1,-1,-1]:
        break
    su = res[0]+res[1]
    if su<30:
        gr="F"
    elif su<50:
        if res[2]>=50:
            gr="C"
        else:
            gr="D"
    elif su<65:
        gr="C"
    elif su<80:
        gr="B"
    else:
        gr="A"
    if res[0]==-1 or res[1]==-1:
        gr="F"
    print(gr)

Solution (Python):



import sys

while True:
    m, f, r = map(int, sys.stdin.readline().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):
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:
		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 == -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 = 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 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 mf < 30:
        print("F")

Solution (Python):
def grader(mid, fin, re):
    """ 
    -1 <= mid <= 50
    -1 <= fin <= 50
    0 <= re <= 100

    >>> grader(40, 42, -1)
    'A'
    >>> grader(20, 30, -1)
    'C'
    >>> grader(0, 2, -1)
    'F'
    """
    score = mid + fin 
    if mid == -1 or fin == -1 or score < 30: 
        return 'F' 
    elif score < 50: 
        if re >= 50: 
            return 'C' 
        else:
            return 'D' 
    elif score < 65: 
        return 'C' 
    elif score < 80: 
        return 'B' 
    else:
        return 'A' 


def run():
    while True:
        m, f, r = [int(x) for x in input().split()]

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

run()

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

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):
ans = ''
while True:
    m, f, r = map(int, input().split(' '))
    if (m == -1 and f == -1) and r == -1:
        break
    else:
        x = m + f
        if (m == -1) or (f == -1):
            ans += 'F\n'
        elif x >= 80:
            ans += 'A\n'
        elif x >= 65:
            ans += 'B\n'
        elif x >= 50:
            ans += 'C\n'
        elif x >= 30:
            if r >= 50:
                ans += 'C\n'
            else:
                ans += 'D\n'
        else:
            ans += 'F\n'
if ans != '':
    print(ans[:-1])

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

Solution (Python):
import sys

while True:
    n = sys.stdin.readline()[:-1]

    if n == '-1 -1 -1':
        break

    marks = [ int(m) for m in n.split() ]

    mt_points,retest = marks[0] + marks[1],marks[2]

    if -1 in marks[:-1]:
        print('F')
        continue
    elif mt_points >= 80:
        print('A')
        continue
    elif mt_points >= 65 and 80 > mt_points:
        print('B')
        continue
    elif mt_points >= 50 and 65 > mt_points:
        print('C')
        continue
    elif mt_points >= 30 and 50 > mt_points:
        if retest >= 50:
            print('C')
            continue
        print('D')
        continue
    elif 30 > mt_points:
        print('F')

Solution (Python):
while 1:
  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 >= 80:
    print("A")
  elif s >= 65 and s < 80:
    print("B")
  elif s >= 50 and s < 65:
    print("C")
  elif s >= 30 and s < 50:
    if r < 50:
      print("D")
    else:
      print("C")

Solution (Python):
N=int(0)
i=int(0)
m,f,r,point=[],[],[],[]
while 1:
    point=list(map(int,input().split(' ')))
    m.append(point[0])
    f.append(point[1])
    r.append(point[2])
    if(m[i]==-1&f[i]==-1&r[i]==-1):
        break
    N=N+1
    i=i+1
i=0
while (i<N):
    if(m[i]+f[i]>=80 and m[i]!=-1 and f[i]!=-1):
        print('A')
    elif(m[i]+f[i]>=65 and m[i]+f[i]<80 and m[i]!=-1 and f[i]!=-1):
        print('B')
    elif(m[i]+f[i]>=50 and m[i]+f[i]<65 and m[i]!=-1 and f[i]!=-1):
        print('C')
    elif(m[i]+f[i]>=30 and m[i]+f[i]<50 and m[i]!=-1 and f[i]!=-1):
        if(r[i]>=50):
            print('C')
        else:
            print('D')
    elif(m[i]+f[i]<30 or m[i]==-1 or f[i]==-1):
        print('F')
    i=i+1