Problem:


A と B の 2 人のプレーヤーが， 0 から 9 までの数字が書かれたカードを使ってゲームを行う．最初に， 2 人は与えられた n 枚ずつのカードを，裏向きにして横一列に並べる．その後， 2 人は各自の左から 1 枚ずつカードを表向きにしていき，書かれた数字が大きい方のカードの持ち主が，その 2 枚のカードを取る．このとき，その 2 枚のカードに書かれた数字の合計が，カードを取ったプレーヤーの得点となるものとする．ただし，開いた 2 枚のカードに同じ数字が書かれているときには，引き分けとし，各プレーヤーが自分のカードを 1 枚ずつ取るものとする．

例えば， A，B の持ち札が，以下の入力例 1 から 3 のように並べられている場合を考えよう．ただし，入力ファイルは n + 1 行からなり， 1 行目には各プレーヤのカード枚数 n が書かれており， i + 1 行目（i = 1，2，... ，n）には A の左から i 枚目のカードの数字と B の左から i 枚目の カードの数字が，空白を区切り文字としてこの順で書かれている．すなわち，入力ファイルの 2 行目以降は，左側の列が A のカードの並びを，右側の列が B のカードの並びを，それぞれ表している．このとき，ゲーム終了後の A と B の得点は，それぞれ，対応する出力例に示したものとなる．

　入力ファイルに対応するゲームが終了したときの A の得点と B の得点を，この順に空白を区切り文字として 1 行に出力するプログラムを作成しなさい．ただし， n ≤ 10000 とする． 

 

  入力例１
   入力例２
   入力例３
 
 

333

9 19 19 1

5 45 45 5

0 81 01 8

  　

  出力例１
   出力例２
   出力例３

19 820 015 14

入力

入力は複数のデータセットからなる．n が 0 のとき入力が終了する．データセットの数は 5 を超えない．

出力

データセットごとに、A の得点と B の得点を１行に出力する．

入力例

3
9 1
5 4
0 8
3
9 1
5 4
1 0
3
9 1
5 5
1 8
0

出力例

19 8
20 0
15 14

各データセットの出力の後（Bの得点の後）に改行を入れること。

上記問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。



Sample input:
3
9 1
5 4
0 8
3
9 1
5 4
1 0
3
9 1
5 5
1 8
0


Sample output:
19 8
20 0
15 14

Submission status: Accepted

Solution code:


array_first = []
array_second = []
array_turns = []

input_str = input()

while True:
    turns = int(input_str)

    if turns == 0:
        break

    array_turns.append(turns)

    for turn in range(turns):
        input_str = input()

        first = ''
        second = ''

        flag_space = False
        for i in range(len(input_str)):
            if input_str[i] == ' ':
                flag_space = True
                continue
            if not flag_space:
                first += (input_str[i])
            else:
                second += (input_str[i])

        array_first.append(int(first))
        array_second.append(int(second))

    input_str = input()

scores_first = []
scores_second = []
passed_turns = 0

for turns in array_turns:
    score_first = 0
    score_second = 0

    for turn in range(turns):
        if array_first[turn + passed_turns] > array_second[turn + passed_turns]:
            score_first += array_first[turn + passed_turns] + array_second[turn + passed_turns]
        elif array_first[turn + passed_turns] < array_second[turn + passed_turns]:
            score_second += array_first[turn + passed_turns] + array_second[turn + passed_turns]
        else:
            score_first += array_first[turn + passed_turns]
            score_second += array_second[turn + passed_turns]

    scores_first.append(score_first)
    scores_second.append(score_second)
    passed_turns += turns

for idx, score in enumerate(zip(scores_first, scores_second)):
    print(score[0], score[1])

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    scores = [0, 0]
    for i in range(n):
        cards = list(map(int, input().split()))
        if cards[0] > cards[1]:
            scores[0] += cards[0] + cards[1]
        elif cards[0] < cards[1]:
            scores[1] += cards[0] + cards[1]
        else:
            scores[0] += cards[0]
            scores[1] += cards[1]
    print(' '.join([str(score) for score in scores]))

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    a_score = 0
    b_score = 0
    for i in range(0,n):
        a,b = map(int,input().split())
        if a > b :
            a_score += a+b
        elif a < b :
            b_score += a+b
        else:
            a_score += a
            b_score += a
    print(a_score,b_score)

Submission status: Accepted

Solution code:
while True:
  n = int(input())
  if n == 0:
    break
  a = 0
  b = 0
  for _ in range(n):
    s1,s2 = map(int,input().split())
    if s1 > s2:
      a += (s1 + s2)
    elif s2 > s1:
      b += (s1 + s2)
    else:
      a += s1
      b += s2
  print(a,b)

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    a = 0
    b = 0
    for i  in range(n):
        cardnum = [int(i) for i in input().split()]
        if cardnum[0] < cardnum[1]:
            b += sum(cardnum)
        elif cardnum[0] > cardnum[1]:
            a += sum(cardnum)
        else:
            a += cardnum[0]
            b += cardnum[1]
    print(a,b)

Submission status: Accepted

Solution code:
# AOJ 0500: Card Game
# Python3 2018.6.29 bal4u

while True:
	n = int(input())
	if n == 0: break
	sa = sb = 0
	for i in range(n):
		a, b = map(int, input().split())
		if a == b:
			sa += a
			sb += b
		elif a > b: sa += a+b
		else:       sb += a+b
	print(sa, sb)

Submission status: Accepted

Solution code:
while True:
  q = int(input())
  score1,score2 = 0,0
  if q == 0:break
  else:
    for p in range(q):
      w = map(int,raw_input().split())
      a,b = w[0],w[1]
      if a > b:
        score1 += a+b
        
      elif a < b:
       score2 += a+b
        
      elif a == b:
        score1+=a
        score2+=a
        
    print score1,score2

Submission status: Accepted

Solution code:
printlist = []
while True:
    n = input()
    if n == 0:
        break
    a = 0
    b = 0
    i = 0
    if n != 0:
        while i != n:
            set = raw_input().split()
            set[0] = int(set[0])
            set[1] = int(set[1])

            if set[0] == set[1]:
                a += set[0]
                b += set[1]

            elif set[0] > set[1]:
                a += ( set[0] + set[1] )
            else:
                b += ( set[0] + set[1] )

            i += 1

        printlist.append(a)
        printlist.append(b)
    else:
        break

#print 'hoge'
p = len(printlist)
i = 0
while i != p:
    print printlist[i],printlist[i+1]
    i += 2

Submission status: Accepted

Solution code:
while 1:
        n = input()
        if n == 0: break
        a,b = (0,0)
        for i in range(n):
                x = map(int, raw_input().split())
                if x[0] > x[1]:
                        a += x[0] + x[1]
                elif x[0] < x[1]:
                        b += x[0] + x[1]
                else:
                        a += x[0]
                        b += x[0]
        print str(a) + ' ' + str(b)

Submission status: Accepted

Solution code:
display = []
while True:
    a = map(int,raw_input().split(' '))
    if a[0]==0 and len(a) ==1:
        for di in display:
            print di[0],di[1]
        break
    elif a[0]!=0 and len(a) ==1:
        n = a[0]
        score = [0,0]
        for i in range(n):
            x = map(int, raw_input().split(' '))
            if x[0] < x[1]:
                score[1] = score[1] + x[0]+x[1]
            elif x[0] > x[1]:
                score[0] = score[0] + x[0]+x[1]
            elif x[0] == x[1]:
                score[0] = score[0] +x[0]
                score[1] = score[1] +x[1]

        display.append([score[0],score[1]])

Submission status: Accepted

Solution code:
def foo(infile, outfile, n):
    ax = 0
    bx = 0
    for i in range(n):
        a, b = infile.readline().split()
        a = int(a)
        b = int(b)
        if a > b:
            ax += (a + b)
        elif a < b:
            bx += (a + b)
        elif a == b:
            ax += a
            bx += b
        else:
            assert False
    print >> outfile, ax, bx


def run(infile, outfile):
    while True:
        n = int(infile.readline())
        if n == 0:
            break
        foo(infile, outfile, n)


if __name__ == "__main__":
    import sys
    run(sys.stdin, sys.stdout)

Submission status: Accepted

Solution code:
while 1:
    n = int(raw_input())
    if n == 0: break
    a = b = 0 
    for i in range(n):
        x, y = map(int, raw_input().split())
        if x > y:
            x += y
            y = 0
        elif x < y:
            y += x
            x = 0
        a += x
        b += y
    print a, b

Submission status: Accepted

Solution code:
while True:
    n=input()
    if n==0:break
    sa,sb=0,0
    for i in range(n):
        a,b=map(int,raw_input().split())
        if a>b:
            sa+=a+b
        elif a<b:
            sb+=a+b
        elif a==b:
            sa+=a
            sb+=b
    print "%d %d"%(sa,sb)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
while 1:
    n=int(raw_input())
    if n==0: break
    pa,pb=0,0
    a,b=[0]*n,[0]*n
    for i in range(n):
        a[i],b[i] = map(int,raw_input().split())

    ab=zip(a,b)
    for a,b in ab:
        if a<b:
            pb+=(a+b)
        elif a>b:
            pa+=(a+b)
        else:
            pa,pb=pa+a,pb+b

    print pa, pb

Submission status: Accepted

Solution code:

import sys

while True:
    n = int(sys.stdin.readline())

    if n == 0:
        break
    
    score_a = 0
    score_b = 0
    
    for i in range(n):
        a, b = map(int, sys.stdin.readline().strip().split())
        
        if a < b:
            score_b += b + a
        elif a > b:
            score_a += a + b
        else:
            score_a += a
            score_b += b
            
    print score_a, score_b

Submission status: Accepted

Solution code:
while 1:
    n = input()
    if n == 0:
        break
    player1 = 0
    player2 = 0
    for i in range(n):
        line = map(int, raw_input().split())
        if line[0] > line[1]:
            player1 += sum(line)
        elif line[0] == line[1]:
            player1 += line[0]
            player2 += line[1]
        else:
            player2 += sum(line)
    print "%d %d" % (player1, player2)

Submission status: Accepted

Solution code:
while 1:
        n=input()
        if n==0:
                break
        a=b=0
        for i in range(n):
                c=map(int,raw_input().split())
                if c[0]>c[1]:
                        a+=c[0]+c[1]
                elif c[0]<c[1]:
                        b+=c[0]+c[1]
                elif c[0]==c[1]:
                        a+=c[0]
                        b+=c[1]
        print a,b

Submission status: Accepted

Solution code:
while True:
    n = int(raw_input())
    if n == 0:
        break
    ap,bp = 0,0
    for _ in range(n):
        a,b = map(int, raw_input().split())
        if a > b:
            ap += a+b
        elif a < b:
            bp += a+b
        else:
            ap += a
            bp += b
    print ap, bp

Submission status: Accepted

Solution code:
#! c:/Python27/python.exe
# coding: UTF-8

def plusNum(x, y):
    x += y
    return x

n = input()
while(n):
    sumA = 0
    sumB = 0
    for i in range(n):
        A, B = map(int,raw_input().split())
        judgeAB = A - B
        if judgeAB > 0:
            sumA = plusNum(sumA, A+B)
        elif judgeAB < 0:
            sumB = plusNum(sumB, A+B)
        else:
            sumA = plusNum(sumA, A)
            sumB = plusNum(sumB, B)
    print "%d %d" % (sumA, sumB)
    n = input()

Submission status: Accepted

Solution code:
def solve():
	import sys
	while 1:
		n = int(raw_input())
		if n==0:
			break
		score_a=0
		score_b=0
		while n>0:
			(a,b)=map(int, raw_input().split())
			if a>b:
				score_a = score_a + a + b
			elif a<b:
				score_b = score_b + a + b
			else:
				score_a = score_a + a
				score_b = score_b + b
			n = n-1
		print score_a, score_b

if __name__ == '__main__':
	solve()

Submission status: Accepted

Solution code:
while 1:
	n=input()
	if n==0:break
	ap=bp=0
	for i in range(n):
		a,b=map(int,raw_input().split())
		if a>b:ap+=a+b
		elif a<b:bp+=a+b
		else:ap+=a;bp+=b
	print ap,bp

Submission status: Accepted

Solution code:

while(True):
  n = input()
  if(n == 0):
    break
  a = 0
  b = 0
  for i in range(n):
    (l, r) = map(int, raw_input().split())
    if(l > r):
      a += l + r
    elif(l < r):
      b += l + r
    else:
      a += l
      b += r
  print "%d %d" % (a, b)

Submission status: Accepted

Solution code:
while True:
    s1 = s2 = 0
    n = int(input())
    if n == 0: break
    for i in range(n):
        a, b = map(int, input().strip().split())
        if a > b:
            s1 += a + b
        elif b > a:
            s2 += a + b
        else:
            s1 += a
            s2 += b
    print(s1, s2)

Submission status: Accepted

Solution code:
while True:
    a = b = 0
    n = int(input())
    if n == 0:
            break
    for i in range(n):        
        c, d = map(int, input().split())
        if c > d:
            a+=c+d
        elif c < d:
            b+=c+d
        else:
            a+=c
            b+=d
    print(a, b)

Submission status: Accepted

Solution code:
while(True):
    n = int(input())
    if n == 0:
        break
    a_sum = 0
    b_sum = 0
    for i in range(n):
        a, b = map(int, input().split())
        if a == b:
            a_sum += a
            b_sum += b
        elif a > b:
            a_sum += (a+b)
        else:
            b_sum += (a+b)
    print(a_sum, b_sum)

Submission status: Accepted

Solution code:
# 3
# 9 1
# 5 4
# 0 8
# 3
# 9 1
# 5 4
# 1 0
# 3
# 9 1
# 5 5
# 1 8
# 0

while True:
	n = int(input())
	if n == 0:
		exit(0)
	a, b = 0, 0
	for i in range(n):
		A = list(map(int, input().split()))
		if A[0] > A[1]:
			a = a + A[0] + A[1]
		elif A[0] < A[1]:
			b = b + A[0] + A[1]
		elif A[0] == A[1]:
			a, b = a + A[0], b + A[1]
	print('{0} {1}'.format(a, b))

Submission status: Accepted

Solution code:
while True:
    num = int(input())
    if num == 0:
        break
    else:
        numa = 0
        numb = 0
        for j in range(num):
            a,b = input().split(" ")
            if int(a) > int(b):
                numa += int(a) + int(b)
                continue
            if int(a) < int(b):
                numb += int(a) + int(b)
                continue
            if int(a) == int(b):
                numa += int(a)
                numb += int(b)
                continue
    print(str(numa) + " " + str(numb))

Submission status: Accepted

Solution code:
while(True):
  loopNum = int(input())
  if loopNum == 0 :
    break
  firstScore = 0
  secondScore = 0
  for i in range(loopNum):
    scoreList = list(map(int,input().split()))
    firstNum, secondNum = scoreList
    if firstNum > secondNum:
      firstScore += firstNum + secondNum
    elif firstNum < secondNum:
      secondScore += firstNum + secondNum  
    else :
      firstScore += firstNum
      secondScore += secondNum
  print(firstScore,secondScore)

Submission status: Accepted

Solution code:
while 1:
    n=int(input())
    if n==0:
        break
    a=0
    b=0
    for i in range(n):
        x,y=map(int,input().split())
        if x > y:
            a+=(x+y)
        elif x < y:
            b+=(x+y)
        else:
            a+=x
            b+=x
    print(a,b)

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    a = 0
    b = 0
    for i in range(n):
        input_card = input().split()
        if int(input_card[0]) > int(input_card[1]):
            a += int(input_card[0]) + int(input_card[1])
        elif int(input_card[0]) < int(input_card[1]):
            b += int(input_card[0]) + int(input_card[1])
        else:
            a += int(input_card[0])
            b += int(input_card[1])
    print(f"{a} {b}")

Submission status: Accepted

Solution code:
while True:
	n = int(input())
	if n == 0: break
	A = B = 0
	for i in range(n):
		a, b = map(int, input().split())
		if a == b:
			A += a
			B += b
		elif a > b: A += a+b
		else:       B += a+b
	print(A, B)

Submission status: Accepted

Solution code:
while 1:
    A=[]
    B=[]
    n=int(input())
    
    if n==0:
        break

    else:
        for i in range(n):
            d=map(int,input().split(' '))
            D=list(d)


            if D[0]>D[1]:
                A.append(D[0])
                A.append(D[1])
                

            elif D[0]==D[1]:
                A.append(D[0])
                B.append(D[1])

            else:
                B.append(D[0])
                B.append(D[1])


    AP=sum(A)
    BP=sum(B)

    print(AP,BP)
                
                
                
            
    
    #print (A,B)

Submission status: Accepted

Solution code:
N=[]
T=[]
while True:
    n = input().split()
    for e in n:
        N += [int(e)]
    if len(n) == 1 and N[-1] == 0:
        break

T += [N.pop(0)]
while T[-1] != 0:
    T += [N.pop(sum(T)*2)]

for t in T:
    if t == 0:
        break
    A = 0
    B = 0
    f = N[:t*2]
    del N[:t*2]
    for n in range(t):
        g = 2*n
        if f[g] > f[g+1]:
            A += f[g]+f[g+1]
        elif f[g] < f[g+1]:
            B += f[g]+f[g+1]
        else:
            A += f[g]
            B += f[g+1]
    print (A,B)

Submission status: Accepted

Solution code:
N=[]
T=[]
while True:
    n = raw_input().split()
    for e in n:
        N += [int(e)]
    if len(n) == 1 and N[-1] == 0:
        break

T += [N.pop(0)]
while T[-1] != 0:
    T += [N.pop(sum(T)*2)]

for t in T:
    if t == 0:
        break
    A = 0
    B = 0
    f = N[:t*2]
    del N[:t*2]
    for n in range(t):
        g = 2*n
        if f[g] > f[g+1]:
            A += f[g]+f[g+1]
        elif f[g] < f[g+1]:
            B += f[g]+f[g+1]
        else:
            A += f[g]
            B += f[g+1]
    print A,B

Submission status: Accepted

Solution code:
while(True):
    A=[]
    B=[]
    a=int(input())
    for i in range(a):
     b,c=map(int, input().split(' '))
     d=int(b)+int(c)
     if int(b)>int(c):
        A.append(int(d))
      
     if int(b)<int(c):
         B.append(int(d))

     if int(b)==int(c):
         A.append(int(b))
         B.append(int(c))

    
    if int(a)==0:
        break
    print(sum(A),sum(B))

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    a = 0
    b = 0
    for i in range(n):
        a1,b1 = map(int,input().split())
        if a1 > b1:
            a += a1+b1
        elif a1 < b1:
            b += a1+b1
        else:
            a += a1
            b += b1
    print(a,b)

Submission status: Accepted

Solution code:
while 1:
    score=[0,0]
    n=int(input())
    if n==0:
        break
    else:
        for i in range(n):
            A,B=map(int,input().split())
            if A>B:
                score[0]+=A+B
            elif A==B:
                score[0]+=A
                score[1]+=B
            else:
                score[1]+=B+A
    print(*score)

Submission status: Accepted

Solution code:
while 1:
    n = int(input())
    scoreA = 0
    scoreB = 0

    if n == 0: break

    for i in range(n):

        A,B = map(int, input().split())

        if A > B:
            scoreA += A + B
        elif A < B :
            scoreB += A + B
        elif A == B:
            scoreA += A
            scoreB += B

    print(scoreA,scoreB)

Submission status: Accepted

Solution code:
def judge_game_set(game_num):
    a_point, b_point = 0, 0
    for _ in range(game_num):
        a_point, b_point = judge_game(a_point, b_point)
    print(a_point, b_point, sep=' ')

def judge_game(a_point, b_point):
    a_card, b_card = map(int, input().split(' '))

    if a_card > b_card:
        a_point += (a_card + b_card)
    elif a_card < b_card:
        b_point += (a_card + b_card)
    else:
        a_point += a_card
        b_point += b_card

    return a_point, b_point

def judge_game_sets():
    game_num = int(input())
    while game_num != 0:
        judge_game_set(game_num)
        game_num = int(input())

if __name__ == '__main__':
    judge_game_sets()

Submission status: Accepted

Solution code:
def main():
    while True:
        N = int(input())
        if N == 0:
            return
        ap, bp = 0, 0
        for i in range(N):
            a, b = map(int, input().split())
            if a > b:
                ap += a + b
            elif a < b:
                bp += a + b
            else:
                ap += a
                bp += b

        print(ap, bp)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
while 1:
    n=int(input())
    if n==0:break
    box=[list(map(int,input().split())) for i in range(n)]
    a,b=0,0
    for x,y in box:
        if x>y:a +=x+y
        elif y>x:b +=x+y
        elif x==y:
            a +=x
            b +=y
    print(a,b)

Submission status: Accepted

Solution code:
while True:
    x = int(input())
    if x != 0:
        resa = 0
        resb = 0
        for i in range(x):
            a, b = [int(i) for i in input().split()]
            if a > b:
                resa += a + b
            elif b > a:
                resb += a + b
            elif a == b:
                resa += a
                resb += b
        print(resa, resb)
    else:
        break

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    A, B = 0, 0
    for _ in range(n):
        x, y = map(int, input().split())
        if x > y:
            A += x + y
        elif x < y:
            B += x + y
        else:
            A += x
            B += y
    print(A, B)

Submission status: Accepted

Solution code:
while True:
    Ascore = 0
    Bscore = 0
    n = int(input())
    if n == 0:
        break 
    for _ in range(n):
        a,b = map(int,input().split())
        if a > b:
            Ascore += a+b
        elif a < b:
            Bscore += a+b
        else:
            Ascore += a
            Bscore += b
    print(Ascore,Bscore)

Submission status: Accepted

Solution code:
while True:
	N = int(raw_input())
	if N == 0: break
	asum = 0
	bsum = 0
	for i in range(0, N):
		a, b = map(int, raw_input().split())
		if a > b: asum += a+b
		elif a < b: bsum += a+b
		else:
			asum += a
			bsum += b
	print str(asum) + ' ' + str(bsum)

Submission status: Accepted

Solution code:
while(1):
	n = int(input())
	if n == 0: break
	ap = 0
	bp = 0
	for i in range(n):
		a,b = map(int,input().split())
		if a > b: ap = a + b + ap
		elif a < b: bp = a + b + bp
		elif a == b: ap = a + ap; bp = b + bp
	print(ap,bp)

Submission status: Accepted

Solution code:
while 1:
    n=int(input())
    if n==0:break
    ap=0
    bp=0
    for i in range(n):
        a,b=map(int,input().split())
        if a>b:
            ap+=a+b
        elif a<b:
            bp+=a+b
        elif a==b:
            ap+=a
            bp+=b
    print(ap,bp)

Submission status: Accepted

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

    pl_card = [input().split(" ") for i in range(card_num)]
    pl_l = 0
    pl_r = 0

    for i in pl_card:
        l = int(i[0])
        r = int(i[1])
        if l > r:
            pl_l = pl_l + (l+r)
        elif l < r:
            pl_r = pl_r + (l+r)
        elif l == r:
            pl_l = pl_l + l
            pl_r = pl_r + r
    print("{0} {1}".format(pl_l,pl_r))

Submission status: Accepted

Solution code:
n = int(input())
while (n != 0):
    A=0
    B=0
    for i in range(n):
        a,b = map(int, input().split())
        if (a>b):
            A+=(a+b)
        elif (b>a):
            B += (a+b)
        else:
            A+=a
            B+=b
    print("{} {}".format(A,B))
    n = int(input())

Submission status: Accepted

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

    score_a = 0
    score_b = 0
    for _ in range(n):
        a, b = map(int, input().split())
        if a > b:
            score_a += a + b
        elif a < b:
            score_b += a + b
        else:
            score_a += a
            score_b += b

    print(score_a, score_b)

Submission status: Accepted

Solution code:
while True:
  n = int(input())
  if n == 0:
    break
  ascore = 0
  bscore = 0
  for i in range(n):
    a,b = list(map(int,input().split()))
    if a < b:
      bscore += a + b
    elif a > b:
      ascore += a + b
    elif a == b:
      ascore += a
      bscore += b
  print(f"{ascore} {bscore}")

Submission status: Accepted

Solution code:
import sys

while True:
	num = int(input())
	if num == 0:
		break
	point = [0,0]
	for i in range(num):
		a, b = map(int, input().split())
		if a < b:
			point[1] += a+b
		elif b < a:
			point[0] += a+b
		else:
			point[0] += a
			point[1] += b

	print(point[0], point[1])

Submission status: Accepted

Solution code:
while True:
    n = input()
    if n == 0:
        break
    else:
        a = 0
        b = 0
        for i in range(n):
            lst = raw_input().split(' ')
            if lst[0] > lst[1]:
                a += int(lst[0]) + int(lst[1])
            elif lst[0] < lst[1]:
                b += int(lst[0]) + int(lst[1])
            else:
                a += int(lst[0])
                b += int(lst[1])
        print str(a) + ' ' + str(b)

Submission status: Runtime Error

Solution code:
import sys
while(True):
    N = raw_input()
    if N == '':
        sys.exit()
    else:
        a_score = 0
        b_score = 0
        for i in range(int(N)):
            x, y = raw_input().split(' ')
            if x > y:
                a_score += (x + y)
            elif x < y:
                b_score += (x + y)
            elif x == y:
                a_score += x
                b_score += y
        print a_score,b_score

Submission status: Runtime Error

Solution code:
import sys
while(True):
    N = raw_input()
    if N == '':
        sys.exit()
    else:
        a_score = 0
        b_score = 0
        for i in range(int(N)):
            x, y = [int(x) for x in raw_input().split(' ')]
            if x > y:
                a_score += (x + y)
            elif x < y:
                b_score += (x + y)
            elif x == y:
                a_score += x
                b_score += y
        print a_score,b_score

Submission status: Runtime Error

Solution code:
n = input()
a_cnt = 0
b_cnt = 0
for i in range(n) :
    arr = input().split(" ")
    num = [int(n) for n in arr]
    if num[0] > num[1] :
        a_cnt += sum(num)
    elif num[1] > num[0] :
        b_cnt += sum(num)
    else :
        a_cnt += num[0]
        b_cnt += num[0]
print(f"{a_cnt} {b_cnt}")

Submission status: Runtime Error

Solution code:
n = input()
a_cnt = 0
b_cnt = 0
for i in range(n) :
    arr = input().split(" ")
    num = [int(m) for m in arr]
    if num[0] > num[1] :
        a_cnt += sum(num)
    elif num[1] > num[0] :
        b_cnt += sum(num)
    else :
        a_cnt += num[0]
        b_cnt += num[0]
print(f"{a_cnt} {b_cnt}")

Submission status: Runtime Error

Solution code:
n = input()
a_cnt = 0
b_cnt = 0
for i in range(n) :
    arr = input().split(" ")
    num = [int(m) for m in arr]
    if num[0] > num[1] :
        a_cnt += sum(num)
    elif num[1] > num[0] :
        b_cnt += sum(num)
    else :
        a_cnt += num[0]
        b_cnt += num[0]

print(f"{a_cnt} {b_cnt}")

Submission status: Runtime Error

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

        sum_a = 0
        sum_b = 0
        
        for i in range(n):
            a,b = map(int, raw_input().split())

            if a > b:
                sum_a = sum_a + a + b
            elif a < b:
                sum_b = sum_b + a + b
            elif a == b:
                sum_a = sum_a + a
                sum_b = sum_b + b

        print("%s %s" %(sum_a,sum_b))
                
if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
while 1:
    n = input()
    if n == 0:
        break
    
    sum_a = 0
    sum_b = 0
    
    for i in range(n):
        a,b = map(int, raw_input().split())
        
        if a > b:
            sum_a = sum_a + a + b
        elif a < b:
            sum_b = sum_b + a + b
        elif a == b:
            sum_a = sum_a + a
            sum_b = sum_b + b

    print("%s %s" %(sum_a,sum_b))

Submission status: Runtime Error

Solution code:
while 1:
    n = int(input())
    if n == 0:
        break
    
    sum_a = 0
    sum_b = 0
    
    for i in range(n):
        a,b = map(int, raw_input().split())
        
        if a > b:
            sum_a = sum_a + a + b
        elif a < b:
            sum_b = sum_b + a + b
        elif a == b:
            sum_a = sum_a + a
            sum_b = sum_b + b

    print("%s %s" %(sum_a,sum_b))

Submission status: Runtime Error

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    
    sum_a = 0
    sum_b = 0
    
    for i in range(n):
        a,b = map(int, raw_input().split())
        
        if a > b:
            sum_a = sum_a + a + b
        elif a < b:
            sum_b = sum_b + a + b
        elif a == b:
            sum_a = sum_a + a
            sum_b = sum_b + b

    print("%s %s" %(sum_a,sum_b))

Submission status: Runtime Error

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    
    sum_a = 0
    sum_b = 0
    
    for i in range(n):
        a,b = map(int, raw_input().split())
        
        if a > b:
            sum_a = sum_a + a + b
        elif a < b:
            sum_b = sum_b + a + b
        elif a == b:
            sum_a = sum_a + a
            sum_b = sum_b + b

    print(sum_a,sum_b)

Submission status: Runtime Error

Solution code:
while True:
    n = int(input())
    if n == 0:break
    sum_a = sum_b = 0
    for i in range(n):
        a,b = map(int, raw_input().split())
        if a > b:sum_a = sum_a + a + b
        elif a < b:sum_b = sum_b + a + b
        else:
            sum_a = sum_a + a
            sum_b = sum_b + b
    print(sum_a,sum_b)

Submission status: Runtime Error

Solution code:
while 1:
    n = input()
    if n == 0:
        break
    
    sum_a = 0
    sum_b = 0
    
    for i in range(n):
        a,b = map(int, input().split())
        
        if a > b:
            sum_a = sum_a + a + b
        elif a < b:
            sum_b = sum_b + a + b
        elif a == b:
            sum_a = sum_a + a
            sum_b = sum_b + b

    print("%s %s" %(sum_a,sum_b))

Submission status: Runtime Error

Solution code:
x = int(input())
score_A = 0
score_B = 0
ans = []
while x:
    for i in range(x):
        y = [int(i) for  i in input().split()]
        if y[0] > y[1]:
            score_A += sum(y)
        elif y[0] < y[1]:
            score_B += sum(y)
        else:
            score_A += y[0]
            score_B += y[1]
    ans.append([score_A,score_B])
    score_A = 0 ; score_B = 0
    x = int(input()
for i in ans:
    print(*i)

Submission status: Runtime Error

Solution code:
def run(infile, outfile):
	n = int(infile.readline())
	if n == 0:
		break
	foo(infile,outfile,n)

def foo(infile, outfile, n):
	ax = 0 #a's point
	bx = 0
	for i in range(n):
		a , b = infile.readline().split()
		a = int(a)
		b = int(b)
		if a > b:
			ax += (a + b)
		elif b > a:
			bx += (a + b)
		else:
			assert False
	print >> outfile, ax , bx

if __name__ == "__main__":
	import sys
	run(sys.stdin, sys.stdout)

Submission status: Runtime Error

Solution code:
# coding: utf8

while True:
    n = int(raw_input())
    a_score, b_score = 0, 0
    
    for i in range(n):
        a, b = map(int, raw_input().split())
    
        if a > b:
            a_score += (a+b)
        elif a < b:
            b_score += (a+b)
        else:
            a_score += a
            b_score += b
            
    print a_score, b_score

Submission status: Runtime Error

Solution code:
a_score, b_score = 0, 0
while(True):
  input_list = map(int, raw_input(), split())
  if len(input_list) == 1 and input_list[0] == 0:
    break
  elif len(input_list) == 1:
    print a_score, b_score
    a_score, b_score = 0, 0
  elif len(input_list) == 2:
    a, b = input_list
    if a > b:
      a_score += a + b
    elif b > a:
      b_score += a + b
    else:
      a_score += a
      b_score += b