Problem:


クラス分け

  会津進学塾では、生徒が塾に入る際に実力テストを行ってクラス分けをします。テストは数学、英語、国語の 3 科目行い、生徒を A,B,C クラスにクラス分けします。A クラスのレベルが一番高く、順に低くなっていきます。

クラス分けの判断は以下の表に基づきます。

               条件              クラス

100 点の科目がある                     A 

数学と英語の平均点が 90 点以上                A 

3 科目の平均点が 80 点以上                 A

3 科目の平均点が 70 点以上                 B

3 科目の平均点が 50 点以上で数学か英語が 80 点以上   B

上の条件を満たさない                       C

  複数の条件を満たす場合は、よりレベルの高いクラスに分けられます。

  生徒の人数 n (1 ≤ n ≤ 10000)、各生徒の数学の点数 pmi (0 ≤ pmi ≤ 100)、英語の点数 pei (0 ≤ pei ≤ 100)、国語の点数 pji (0 ≤ pji ≤ 100) を入力とし、各生徒のクラスA,B,C (半角英字) を出力するプログラムを作成してください。

Input

複数のデータセットの並びが入力として与えられます。入力の終わりはゼロひとつの行で示されます。
各データセットは以下の形式で与えられます。

n
pm1 pe1 pj1
pm2 pe2 pj2
:
pmn pen pjn

入力はすべて整数で与えられます。データセットの数は 1000 を超えません。

Output

入力データセットごとに、各生徒のクラスを順番に出力します。

Sample Input

4
100 70 20
98 86 55
80 34 36
65 79 65
2
99 81 20
66 72 90
0

Output for the Sample Input

A
A
B
C
A
B



Sample input:
4
100 70 20
98 86 55
80 34 36
65 79 65
2
99 81 20
66 72 90
0


Sample output:
A
A
B
C
A
B

Submission status: Wrong Answer

Solution code:
while True:
    try:
        N = input()
    except:
        break
    pm, pe, pj = points = map(int, raw_input().split())
    ave = sum(points) / 3.0
    if 100 in points:
        print "A"
    elif (pm + pe) / 2.0 >= 90:
        print "A"
    elif ave >= 80:
        print "A"
    elif ave >= 70:
        print "B"
    elif ave >= 50 and (pm >= 80 or pe >= 80):
        print "B"
    else:
        print "C"

Submission status: Wrong Answer

Solution code:
while True:
    try:
        N = input()
    except:
        break
    pm, pe, pj = points = map(int, raw_input().split())
    su = sum(points)
    if 100 in points:
        print "A"
    elif (pm + pe) >= 180:
        print "A"
    elif su >= 240:
        print "A"
    elif su >= 210:
        print "B"
    elif su >= 150 and (pm >= 80 or pe >= 80):
        print "B"
    else:
        print "C"

Submission status: Wrong Answer

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    dataset = [map(int, input().split()) for _ in range(n)]
    for map_ in dataset:
        pm, pe, pj = map_
        x = (pm + pe + pj) // 3
        if 100 in map_:
            print("A")
        elif (pm + pe) // 2 >= 90:
            print("A")
        elif x >= 80:
            print("A")
        elif x >= 70:
            print("B")
        elif x >= 50 and (pm >= 80 or pe >= 80):
            print("B")
        else:
            print("C")

Submission status: Wrong Answer

Solution code:
while True:
    n=input()
    if n==0:break
    L=[map(int,raw_input().split()) for i in range(n)]
    for pm,pe,pj in L:
        if (100 in (pm,pe,pj)) or (pm+pe>=180) or (pm+pe+pj>=240):
            print "A"
        elif (pm+pe+pj>=210) and ((pm+pe+pj>=150) and (pm>=80) or (pe>=80)):
            print "A"
        elif (pm+pe+pj>=210) or ((pm+pe+pj>=150) and (pm>=80) or (pe>=80)):
            print "B"
        else:
            print "C"

Submission status: Wrong Answer

Solution code:
while True:
    n=input()
    if n==0:break
    L=[map(int,raw_input().split()) for i in range(n)]
    for pm,pe,pj in L:
        if (100 in (pm,pe,pj)) or (pm+pe>=180) or (pm+pe+pj>=240):
            print "A"
        elif (pm+pe+pj>=210) and ((pm+pe+pj>=150) and ((pm>=80) or (pe>=80))):
            print "A"
        elif (pm+pe+pj>=210) or ((pm+pe+pj>=150) and ((pm>=80) or (pe>=80))):
            print "B"
        else:
            print "C"

Submission status: Wrong Answer

Solution code:
while True:
    n=input()
    if n==0:break
    L=[map(int,raw_input().split()) for i in range(n)]
    for pm,pe,pj in L:
        ave=(pm+pe+pj)/3.0
        if (100 in (pm,pe,pj)) or (pm+pe>=180) or (ave>=90):
            print "A"
        elif ave>=70 and ((pm>=80) or (pe>=80)):
            print "A"
        elif (ave>=70) or ((ave>=50) and ((pm>=80) or (pe>=80))):
            print "B"
        else:
            print "C"

Submission status: Wrong Answer

Solution code:
while True:
    n=input()
    if n==0:break
    for i in range(n):
        pm,pe,pj=map(int,raw_input().split())
        ave=(pm+pe+pj)/3.0
        if (100 in (pm,pe,pj)) or (pm+pe>=180) or (ave>=90):
            print "A"
        elif ave>=70 and ((pm>=80) or (pe>=80)):
            print "A"
        elif (ave>=70) or ((ave>=50) and ((pm>=80) or (pe>=80))):
            print "B"
        else:
            print "C"

Submission status: Wrong Answer

Solution code:
while True:
    n=input()
    if n==0:break
    for i in range(n):
        pm,pe,pj=map(int,raw_input().split())
        ave=(pm+pe+pj)/3.0
        if (100 in (pm,pe,pj)) or (pm+pe>=180) or (ave>=80):
            print "A"
        elif ave>=70 and ((pm>=80) or (pe>=80)):
            print "A"
        elif (ave>=70) or ((ave>=50) and ((pm>=80) or (pe>=80))):
            print "B"
        else:
            print "C"

Submission status: Wrong Answer

Solution code:
import sys
for s in sys.stdin:
	s = map(int, s.split())
	if len(s) == 1:
		continue
	else:
		(pm, pe, pj) = tuple(s)
		if 100 in (pm, pe, pj): c = "A"
		elif pm + pe >= 180: c = "A"
		elif pm + pe + pj >= 240: c = "A"
		elif pm + pe + pj >= 240: c = "B"
		elif pm + pe + pj >= 150 and (pm >= 80 or pe >= 80): c = "B"
		else: c = "C"
	print c

Submission status: Accepted

Solution code:
while(True):
    n = int(input())
    if not n: break
    for _ in range(n):
        m,e,j = map(int, input().split())
        if 100 in [m,e,j]: print("A"); continue
        elif (m+e)/2 >= 90: print("A"); continue
        elif (m+e+j)/3 >= 80: print("A"); continue
        elif (m+e+j)/3 >= 70: print("B"); continue
        elif (m+e+j)/3 >= 50 and (m>=80 or e>=80): print("B"); continue
        else: print("C"); continue

Submission status: Accepted

Solution code:
while True:
  n=int(input())
  if n==0:
    break
  for i in range(n):
    m,e,j=map(int,input().split())
    if m==100 or e==100 or j==100:
      print('{}'.format('A'))
    elif ((m+e)/2)>=90:
       print('{}'.format('A'))
    elif ((m+e+j)/3)>=80:
       print('{}'.format('A'))
    elif ((m+e+j)/3)>=70:
       print('{}'.format('B'))
    elif ((m+e+j)/3)>=50:
      if m>=80 or e>=80:
          print('{}'.format('B'))
      else:
        print('{}'.format('C'))
    else:
      print('{}'.format('C'))

Submission status: Accepted

Solution code:
def rank_a(m,e,j):
    if m == 100 or e == 100 or j==100:return True
    if (float(m) + e) /2 >= 90:return True
    if (float(m) + e + j) / 3 >= 80: return True

    return False

def rank_b(m,e,j):
    if (float(m) + e + j) / 3 >= 70: return True
    if (float(m) + e + j) / 3 >= 50 and \
        (m >= 80 or e >= 80):
            return True
while True:
    n = int(input())
    if n == 0: break
    for i in range(n):
        pm,pe,pj = list(map(int,input().split()))
        if rank_a(pm,pe,pj):
            print("A")
        elif rank_b(pm,pe,pj):
            print("B")
        else:
            print("C")

Submission status: Accepted

Solution code:
def rank(pm, pe, pj):
    ave_me = (pm + pe) // 2
    ave_all = (pm + pe + pj) // 3

    if 100 == pm or 100 == pe or 100 == pj or 90 <= ave_me or 80 <= ave_all:
        return 'A'
    
    if 70 <= ave_all or 50 <= ave_all and (80 <= pm or 80 <= pe):
        return 'B'
    return 'C'

import sys
f = sys.stdin

while True:
    n = int(f.readline())
    if n == 0:
        break
    for _ in range(n):
        pm, pe, pj = map(int, f.readline().split())
        print(rank(pm, pe, pj))

Submission status: Accepted

Solution code:
while True:
    n = int(raw_input())
    if n == 0: break
    for i in range(n):
        data = map(int, raw_input().split())
        if 100 in data or 90 <= float(sum(data[:2]))/2:
            print 'A'
        elif 80 <= float(sum(data))/3:
            print 'A'
        elif 70 <= float(sum(data))/3:
            print 'B'
        elif 50 <= float(sum(data))/3 and (80 <= data[0] or 80 <= data[1]):
            print 'B'
        else:
            print 'C'

Submission status: Accepted

Solution code:
while 1:
    n=int(input())
    if n==0: break
    for _ in range(n):
        a=list(map(int,input().split()))
        c=sum(a)
        if sum(a[:2])/2>=90 or c/3>=80 or 100 in a: b='A'
        elif c/3>=70 or (c/3>=50 and (a[0]>=80 or a[1]>=80)): b='B'
        else: b='C'
        print(b)

Submission status: Accepted

Solution code:
while 1:
    n=int(input())
    if n==0: break
    for _ in range(n):
        a=list(map(int,input().split()))
        c=sum(a)
        if sum(a[:2])>179 or c>239 or 100 in a: b='A'
        elif c>209 or (c>149 and max(a[:2])>79): b='B'
        else: b='C'
        print(b)

Submission status: Accepted

Solution code:
while True:
    n= int(input())
    if n== 0: break
    datasets= [list(map(int, input().split())) for _ in range(n)]
    for d in datasets:
        av= sum(d)//3
        if 100 in d:
            print("A")
        elif sum(d[:2])//2 >=90:
            print("A")
        elif av>= 80:
            print("A")
        elif av>= 70:
            print("B")
        elif av>= 50 and d[0]>= 80 or d[1]>= 80:
            print("B")
        else:
            print("C")

Submission status: Accepted

Solution code:
# Aizu Problem 0218: Dividing Students

import sys, math, os, fractions

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


def grade(m, e, j):
    if m + e >= 180 or m + e + j >= 240 or max(e, j, m) == 100:
        return 'A'
    elif m + e + j >= 210:
        return 'B'
    elif m + e + j >= 150 and max(m, e) >= 80:
        return 'B'
    return 'C'


while True:
    n = int(input())
    if n == 0:
        break
    for _ in range(n):
        m, e, j = [int(__) for __ in input().split()]
        print(grade(m, e, j))

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    for _ in range(n):
        p = list(map(int, input().split()))
        if 100 in p:
            print("A")
        elif (p[0] + p[1]) // 2 >= 90:
            print("A")
        elif sum(p) // 3 >= 80:
            print("A")
        elif sum(p) // 3 >= 70:
            print("B")
        elif sum(p) // 3 >= 50 and (p[0] >= 80 or p[1] >= 80):
            print("B")
        else:
            print("C")

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    for _ in range(n):
        p = list(map(int, input().split()))
        x = sum(p) // 3
        if 100 in p:
            print("A")
        elif (p[0] + p[1]) // 2 >= 90:
            print("A")
        elif x >= 80:
            print("A")
        elif x >= 70:
            print("B")
        elif x >= 50 and (p[0] >= 80 or p[1] >= 80):
            print("B")
        else:
            print("C")

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    dataset = [list(map(int, input().split())) for _ in range(n)]
    for p in dataset:
        x = sum(p) // 3
        if 100 in p:
            print("A")
        elif (p[0] + p[1]) // 2 >= 90:
            print("A")
        elif x >= 80:
            print("A")
        elif x >= 70:
            print("B")
        elif x >= 50 and (p[0] >= 80 or p[1] >= 80):
            print("B")
        else:
            print("C")

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    dataset = [list(map(int, input().split())) for _ in range(n)]
    for p in dataset:
        x = (p[0] + p[1] + p[2]) // 3
        if 100 in p:
            print("A")
        elif (p[0] + p[1]) // 2 >= 90:
            print("A")
        elif x >= 80:
            print("A")
        elif x >= 70:
            print("B")
        elif x >= 50 and (p[0] >= 80 or p[1] >= 80):
            print("B")
        else:
            print("C")

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    if n==0:
        break
    for i in range(n):
        m,e,j=map(int,input().split())
        if m==100 or e==100 or j==100 or (m+e)//2>=90 or (m+e+j)//3>=80:
            print("A")
        elif (m+e+j)//3>=70 or (m+e+j)//3>=50 and m>=80 or e>=80:
            print("B")
        else:
            print("C")

Submission status: Accepted

Solution code:
# AOJ 0218: Dividing Students
# Python3 2018.6.23 bal4u

while 1:
	n = int(input())
	if n == 0: break
	for i in range(n):
		pm, pe, pj = map(int, input().split())
		k = pm+pe+pj
		if pm == 100 or pe == 100 or pj == 100: print("A")
		elif pm + pe >= 90*2: print("A")
		elif k >= 80*3: print("A")
		elif k >= 70*3: print("B")
		elif k >= 50*3 and (pm >= 80 or pe >= 80): print("B")
		else: print("C")

Submission status: Accepted

Solution code:
def rank(m, e, j):
  if 100 in (m, e, j) or (m + e) / 2 >= 90 or (m + e + j) / 3 >= 80:
    return "A"
  elif (m + e + j) / 3 >= 70 or ((m + e + j) / 3 >= 50 and (m >= 80 or e >= 80)):
    return "B"
  return "C"

while True:
  n = int(input())
  if n == 0:
    break
  for _ in range(n):
    m, e, j = map(int, input().split())
    print(rank(m, e, j))

Submission status: Accepted

Solution code:
while True:
  c = int(input())
  if c == 0:
    break
  else:
    for t in range(c):
     s = map(int,raw_input().split())
     pm,pe,pj = s[0],s[1],s[2]
     if pm == 100 or pe == 100 or pj == 100 or (pm+pe)/2 >= 90 or (pm+pe+pj)/3 >= 80:
       print "A"
     elif (pm+pe+pj)/3 >= 70:
       print "B"
     elif (pm+pe+pj)/3 >= 50 and pm >= 80 or pe >= 80:
       print "B"
     else:
       print "C"

Submission status: Accepted

Solution code:
while True:
    n=input()
    if n==0:break
    for i in range(n):
        pm,pe,pj=map(int,raw_input().split())
        ave=(pm+pe+pj)/3.0
        if (100 in (pm,pe,pj)) or ((pm+pe)/2>=90) or (ave>=80):
            print "A"
        elif (ave>=70) or ((ave>=50) and ((pm>=80) or (pe>=80))):
            print "B"
        else:
            print "C"

Submission status: Accepted

Solution code:
def main():
	while True:
		n=int(raw_input())
		if n==0:	break;
		solve(n)
def solve(n):
	for _ in range(n):
		pm,pe,pj=map(int, raw_input().split(" "))
		ave,aveme=(pm+pe+pj)/3,(pm+pe)/2
# 		print ave,aveme
		if pm==100 or pe==100 or pj==100 or aveme>=90 or ave>=80:	print "A"
		elif ave>=70 or (ave>=50 and(pm>=80 or pe>=80)):	print "B"
		else:	print "C"

if __name__ == "__main__":	main()

Submission status: Accepted

Solution code:
import sys
for s in sys.stdin:
	s = map(int, s.split())
	if len(s) == 1:
		continue
	else:
		(pm, pe, pj) = tuple(s)
		if 100 in (pm, pe, pj): c = "A"
		elif pm + pe >= 180: c = "A"
		elif pm + pe + pj >= 240: c = "A"
		elif pm + pe + pj >= 210: c = "B"
		elif pm + pe + pj >= 150 and (pm >= 80 or pe >= 80): c = "B"
		else: c = "C"
	print c

Submission status: Accepted

Solution code:
if __name__ == '__main__':


    while True:


        n = int(raw_input())

        if n == 0:
            break

        for num in range(n):

            a,b,c = map(int, raw_input().split(' '))

            if a == 100 or b == 100 or c == 100:

                print 'A'

            elif (a+b)/2 >= 90:
                print 'A'

            elif (a+b+c)/3 >= 80:

                print 'A'

            elif (a+b+c)/3 >= 70:
                print 'B'

            elif (a+b+c)/3 >= 50:

                if a >= 80 or b >= 80:
                    print 'B'
                
                else:
                    print 'C'

            else:
                print 'C'

Submission status: Accepted

Solution code:
while 1:
    n=input()
    if n==0: break
    for i in xrange(n):
        pm,pe,pj=map(int,raw_input().split())
        if max(pm,pe,pj)==100 or (pm+pe)>=180 or (pm+pe+pj)>=240:
            print "A";
        elif (pm+pe+pj)>=210 or ((pm+pe+pj)>=150 and max(pm,pe)>=80):
            print "B";
        else:
            print "C";

Submission status: Accepted

Solution code:
while 1:
	n=input()
	if n==0:break
	for i in range(n):
		m,e,j=map(int, raw_input().split())
		if 100 in [m,e,j] or m+e>=180 or m+e+j>=240:print "A"
		elif m+e+j>=210 or (m+e+j>=150 and max(m,e)>=80):print "B"
		else:print"C"

Submission status: Accepted

Solution code:
while 1:
	n=input()
	if n==0:break
	for i in range(n):
		m,e,j=map(int, raw_input().split())
		a=m+e+j
		if 100 in [m,e,j] or m+e>179 or a>239:print "A"
		elif a>209 or (a>149 and max(m,e)>79):print "B"
		else:print"C"

Submission status: Accepted

Solution code:
while 1:
	n=input()
	if n==0:break
	for i in range(n):
		m,e,j=map(int, raw_input().split())
		a=m+e+j
		if 100 in [m,e,j] or m+e>179 or a>239:print"A"
		elif a>209 or (a>149 and max(m,e)>79):print"B"
		else:print"C"

Submission status: Accepted

Solution code:
while 1:
    n = int(input())
    if n == 0:
        break
    l = [list(map(int,input().split())) for i in range(n)]
    for i in range(n):
        if l[i][0] == 100 or l[i][1] == 100 or l[i][2] == 100:
            print("A")
        elif l[i][0] + l[i][1] >= 180:
            print("A")
        elif l[i][0] + l[i][1] + l[i][2] >= 240:
            print("A")
        elif l[i][0] + l[i][1] + l[i][2] >= 210:
            print("B")
        elif l[i][0] + l[i][1] + l[i][2] >= 150 and (l[i][0] >=80 or l[i][1] >=80) :
            print("B")
        else:
            print("C")

Submission status: Accepted

Solution code:

def a1(li):
    if 100 in li: return 1
    else: return 0

def a2(li):
    if (li[0]+li[1])/2>=90: return 1
    else: return 0

def a3(li):
    if sum(li)/3>=80: return 1
    else: return 0

def isA(li):
    if a1(li) or a2(li) or a3(li): return 1
    else: 0

def b1(li):
    if sum(li)/3>=70: return 1
    else: return 0

def b2(li):
    if sum(li)/3>=50 and (li[0]>=80 or li[1]>=80):
        return 1
    else: return 0

def isB(li):
    if b1(li) or b2(li): return 1
    else: 0

def isX(li):
    if isA(li):
        return 'A'
    elif isB(li):
        return 'B'
    else:
        return 'C'

while True:
    N=int(input())
    if N==0: break
    for _ in range(N):
        l=list(map(int,input().split()))
        print(isX(l))

Submission status: Accepted

Solution code:
while True :
    n = int(input())
    if n == 0 :
        break
    
    for i in range(n) :
        m, e, j = map(int, input().split())
        if m == 100 or e == 100 or j == 100 :
            print("A")
        elif (m + e) / 2 >= 90 :
            print("A")
        elif (m + e + j) / 3 >= 80 :
            print("A")
        elif (m + e + j) / 3 >= 70 :
            print("B")
        elif (m + e + j) / 3 >= 50 and (m >= 80 or e >= 80) :
            print("B")
        else :
            print("C")

Submission status: Accepted

Solution code:
while True:
    #繰り返し回数を入力し0であった場合はbreakする
    num = int(input())
    if num == 0:
        break
    else:
        for _ in range(num):
            a,b,c = map(int,input().split())
            
            #100 点の科目があるまたは数学と英語の平均点が 90 点以上または3 科目の平均点が 80 点以上の場合"A"を出力する
            if a == 100 or b == 100 or c == 100 or (a + b) / 2 >= 90 or (a + b + c) / 3 >= 80:print("A")
            
            #3 科目の平均点が 70 点以上または3 科目の平均点が 50 点以上で数学か英語が 80 点以上の場合"B"を出力する
            elif (a + b + c) / 3 >= 70 or (a + b + c) / 3 >= 50 and a >= 80 or (a + b + c) / 3 >= 50 and b >= 80:print("B")
            
            #上記のどれにも当てはまらない場合、"C"を出力する
            else:print("C")

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    for i in range(n):
        p = list(map(int,input().split()))
        if max(p)==100 or sum(p[:2])>=180 or sum(p)>=240:
            print('A')
        elif sum(p)>=210 or (sum(p)>=150 and max(p[:2])>=80):
            print('B')
        else:
            print('C')

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    for _ in range(n):
        a,b,c = map(int,input().split())
        if a == 100 or b == 100 or c == 100 or a+b >= 180 or a+b+c >= 240:
            print("A")
        elif a+b+c >= 210 or (a+b+c >= 150 and (a >= 80 or b >= 80)):
            print("B")
        else:
            print("C")

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n==0:
        break
    for i in range(n):
        m,e,j = [ int(s) for s in input().split() ]
        if m == 100 or e == 100 or j == 100:
            print('A')
        elif (m+e)/2 >= 90:
            print('A')
        elif (m+e+j)/3 >= 80:
            print('A')
        elif (m+e+j)/3 >= 70:
            print('B')
        elif (m+e+j)/3 >= 50 and (m >= 80 or e>= 80):
            print('B')
        else:
            print('C')

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    
    for _ in range(n):
        m, e, j = [int(x) for x in input().split()]
        
        if m == 100 or e == 100 or j == 100:
            print("A")
            continue
        if m + e >= 180:
            print("A")
            continue
        if m + e + j >= 240:
            print("A")
            continue
        if m + e + j >= 210:
            print("B")
            continue
        if m + e + j >= 150 and (m >= 80 or e >=80):
            print("B")
            continue
        print("C")

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    if n==0:
        break
    for i in range(n):
        s,e,k=map(int,input().split())
        if k==100 or s==100 or e==100:
            print("A")
        elif (s+e)/2 >=90:
            print("A")
        elif (s+k+e)/3 >=80:
            print("A")
        elif (s+k+e)/3 >=70:
            print("B")
        elif (s+k+e)/3 >=50 and s>=80:
            print("B")
        elif (s+k+e)/3 >=50 and e>=80:
            print("B")
        else:
            print("C")

Submission status: Accepted

Solution code:
def bar(a,b,c):
  x=(a+b+c)/3
  return x
while True:
  n=int(input())
  if n==0:
    break
  for i in range(n):
    m,e,j=map(int, input().split())
    y=(m+e)/2
    x =bar(m,e,j)
    if (m==100 or e==100 or j==100) or y>=90 or x>=80:
      print("A")
    elif x>=70:
      print("B")
    elif x>=50:
      if m>=80 or e>=80:
        print("B")
      else:
        print("C")
    else:
      print("C")

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n==0: break

    for i in range(n):
        m,e,j = map(int,input().split())
        if (m==100 or e==100 or j ==100) or ((m+e)/2 >= 90) or ((m+e+j)/3 >=80):
            print("A")
        elif((m+e+j)/3 >=70) or (((m+e+j)/3>=50) and (m>=80 or e>=80)):
            print("B")
        else:
            print("C")

Submission status: Accepted

Solution code:
while 1:
  n = int(input())
  if n == 0:
    break
    
  for _ in range(n):
    m, e, j = map(int, input().split())
    total = m + e + j
    if 100 in [m, e, j]:
      print('A')
    elif m + e >= 180:
      print('A')
    elif total >= 240:
      print('A')
    elif total >= 210:
      print('B')
    elif total >= 150 and (m >= 80 or e >= 80):
      print('B')
    else:
      print('C')

Submission status: Accepted

Solution code:
while 1:
    n = int(input())
    if n == 0: break
    i = 0
    while True:
        if i == n: break
        m, e, j = map(int, input().split())
        sum = m + e + j
        if m==100 or e==100 or j==100:
            print("A")
        elif (m+e)/2 >= 90:
            print("A")
        elif sum/3 >= 80:
            print("A")
        elif sum/3 >= 70:
            print("B")
        elif sum/3 >= 50 and m >= 80 or e >= 80:
            print("B")
        else:
            print("C")
        i += 1

Submission status: Accepted

Solution code:
while 1:
    n = int(input())
    if n == 0: break
    for i in range(n):
        pm, pe, pj = map(int, input().split())
        k = pm+pe+pj
        if pm == 100 or pe == 100 or pj == 100: print("A")
        elif pm + pe >= 90*2: print("A")
        elif k >= 80*3: print("A")
        elif k >= 70*3: print("B")
        elif k >= 50*3 and (pm >= 80 or pe >= 80): print("B")
        else: print("C")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Dividing Students
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0218

"""
import sys


def solve(n):
    ans = []
    for _ in range(n):
        m, e, j = map(int, input().split())
        if max([m, e, j]) == 100 or m + e >= 180 or m + e + j >= 240:
            ans.append('A')
        elif m + e + j >= 210 or (m + e + j >= 150 and (m >= 80 or e >= 80)):
            ans.append('B')
        else:
            ans.append('C')
    return ans


def main(args):
    while True:
        n = int(input())
        if n == 0:
            break
        ans = solve(n)
        print(*ans, sep='\n')


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

Submission status: Accepted

Solution code:
while 1:
    n=int(input())
    if n==0:break
    for i in range(n):
        a,b,c=map(int,input().split())
        if a==100 or b==100 or c==100 or a+b>=180 or a+b+c>=240:
            print("A")
        elif a+b+c>=210 or a+b+c>=150 and (a>=80 or b>=80):
            print("B")
        else:
            print("C")

Submission status: Accepted

Solution code:
while True:
    N = int(input())
    if N == 0: break
    for _ in range(N):
        m, e, j = map(int, input().split())
        me, mej = (m+e)//2, (m+e+j)//3
        if 100 in (m, e, j) or me >= 90 or mej >= 80:
            print('A')
        elif mej >= 70 or (mej >= 50 and m >= 80 or e >= 80):
            print('B')
        else:
            print('C')

Submission status: Accepted

Solution code:
while 1:
    n = int(input())
    if n == 0:
        break

    for _ in range(n):
        m, e, j = map(int, input().split())
        total = m + e + j
        if 100 in [m, e, j]:
            print("A")
        elif m + e >= 180:
            print("A")
        elif total >= 240:
            print("A")
        elif total >= 210:
            print("B")
        elif total >= 150 and (m >= 80 or e >= 80):
            print("B")
        else:
            print("C")

Submission status: Accepted

Solution code:
while True:

    N = int(input())
    if N == 0:
        break

    for l in range(N):
        m,e,j = [int(i) for i in input().split()]

        ans = ""
        if m == 100 or e == 100 or j == 100:
            ans = "A"
        elif m + e >= 180:
            ans = "A"
        elif m + e + j >= 240:
            ans = "A"
        elif m + e + j >= 210:
            ans = "B"
        elif (m + e + j >= 150) and (m >= 80 or e >= 80):
            ans = "B"
        else:
            ans = "C"

        print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
while True:
  if n==0:
    break
  for i in range(n):
    m,e,j=map(int,input().split())
    if m==100 or e==100 or j==100:
      print('{}'.format('A'))
    elif (m+e)/2>=90:
       print('{}'.format('A'))
    elif (m+e+j)/3>=80:
       print('{}'.format('A'))
    elif (m+e+j)/3>=70:
       print('{}'.format('B'))
    elif (m+e+j)/3>=50:
      if m>=80 or e>=80:
          print('{}'.format('B'))
      else:
        print('{}'.format('C'))
    else:
      print('{}'.format('C'))

Submission status: Runtime Error

Solution code:
while True:
    try:
        N = input()
    except:
        break
    pm, pe, pj = points = map(int, raw_input())
    ave = sum(points) / 3.0
    if 100 in points:
        print "A"
    elif (pm + pe) / 2.0 >= 90:
        print "A"
    elif ave >= 80:
        print "A"
    elif ave >= 70:
        print "B"
    elif ave >= 50 and (pm >= 80 or pe >= 80):
        print "B"
    else:
        print "C"

Submission status: Runtime Error

Solution code:
while 1:
    n=int(input())
    if n=='0': break
    for _ in range(n):
        a=list(map(int,input().split()))
        c=sum(a)
        if sum(a[:2])/2>=90 or c/3>=80 or 100 in a: b='A'
        elif c/3>=70 or (c/3>=50 and (a[0]>=80 or a[1]>=80)): b='B'
        else: b='C'
        print(b)

Submission status: Runtime Error

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    dataset = [map(int, input().split()) for _ in range(n)]
    for map_ in dataset:
        pm, pe, pj = map_
        x = (pm + pe + pj) // 3
        if 100 in p:
            print("A")
        elif (pm + pe) // 2 >= 90:
            print("A")
        elif x >= 80:
            print("A")
        elif x >= 70:
            print("B")
        elif x >= 50 and (pm >= 80 or pe >= 80):
            print("B")
        else:
            print("C")

Submission status: Runtime Error

Solution code:
for s in sys.stdin:
	s = map(int, s.split())
	if len(s)==1:
		continue
	else:
		(pm,pe,pj) = tuple(s)
		if 100 in (pm,pe,pj): c = "A"
		elif pm+pe>=180: c = "A"
		elif pm+pe+pj>=240: c = "A"
		elif pm+pe+pj>=240: c = "B"
		elif pm+pe+pj>=150 and (pm>=80 or pe>=80): c = "B"
		else: c = "C"
	print c

Submission status: Runtime Error

Solution code:
while 1:
	n=input()
	if n==0:break
	for i in range(n):
		m,e,j=map(int, raw_input().split())
		a=sum(m,e,j)
		if 100 in [m,e,j] or m+e>=180 or a>=240:print "A"
		elif a>=210 or (a>=150 and max(m,e)>=80):print "B"
		else:print"C"