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: 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:
    break
  elif len(input_list) == 1 and input_list != 0:
    if a_score != 0 or b_score != 0:
      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

Submission status: Runtime Error

Solution code:
import sys
for i in sys.stdin:
    n = int(raw_input())
    num_a = 0
    num_b = 0
    for j in range(n):
        ta, tb = map(int,raw_input().split())
        if ta > tb:
            num_a += (ta+tb)
        elif ta < tb:
            num_b += (ta+tb)
        else:
            num_a += ta
            num_b += tb
    print "%d %d" % (num_a, num_b)

Submission status: Runtime Error

Solution code:
import sys
for i in sys.stdin:
    n = int(i)
    num_a = 0
    num_b = 0
    for j in range(n):
        ta, tb = map(int,raw_input().split())
        if ta > tb:
            num_a += (ta+tb)
        elif ta < tb:
            num_b += (ta+tb)
        else:
            num_a += ta
            num_b += tb
    print "%d %d" % (num_a, num_b)

Submission status: Runtime Error

Solution code:
__Author__ = 'Anomino'
# coding:UTF-8


def AskUser(number) : 
    player_A, player_B = [], []
    for value in range(0, number) : 
        answer = raw_input()
        answer = answer.split( )
        player_A.append(int(answer[0]))
        player_B.append(int(answer[1]))

    return player_A, player_B
    
def CalcScore(player_A, player_B) : 
    score_A, score_B = 0, 0

    for value in range(0, len(player_A)) : 
        if player_A[value] < player_B[value] : 
            score_B = score_B + player_A[value] + player_B[value]
        elif player_A[value] > player_B[value] : 
            score_A = score_A + player_A[value] + player_B[value]
        else : 
            score_A = score_A + player_A[value]
            score_B = score_B + player_B[value]

    return score_A, score_B

if __name__ == '__main__' : 
    total_A, total_B = [], []

    while (number = int(raw_input())) != 0 :
        player_A, player_B = AskUser(number)
        score_A, score_B = CalcScore(player_A, player_B)
        total_A.append(score_A)
        total_B.append(score_B)

    for value in range(0, len(total_A)) : 
        print total_A[value], total_B[value]

Submission status: Runtime Error

Solution code:
a=[0]*10000
b=[0]*10000
ct=0
a_scores=[]
b_scores=[]
while True:
    a_score=0
    b_score=0
    n=input()
    if n==0:
        break
    else :
        for i in xrange(n):
            a[ct+i],b[ct+i]=map(int,raw_input().split())
            if a[ct+i]>b[ct+i]:
                a_score+=a[ct+i]+b[ct+i]
            elif a[ct+i]==b[ct+i]:
                a_score+=a[ct+i]
                b_score+=b[ct+i]
            else:
                b_score+=b[ct+i]+a[ct+i]
        a_scores.append(a_score)
        b_scores.append(b_score)
        ct+=n
for i in xrange(len(a_scores)):
    print a_scores[i],b_scores[i]

Submission status: Runtime Error

Solution code:
a=[0]*10000
b=[0]*10000
ct=0
a_scores=[]
b_scores=[]
while True:
    a_score=0
    b_score=0
    n=input()
    if n==0:
        break
    else :
        for i in xrange(n):
            a[ct+i],b[ct+i]=map(int,raw_input().split())
            if a[ct+i]>b[ct+i]:
                a_score+=a[ct+i]+b[ct+i]
            elif a[ct+i]==b[ct+i]:
                a_score+=a[ct+i]
                b_score+=b[ct+i]
            else:
                b_score+=b[ct+i]+a[ct+i]
        a_scores.append(a_score)
        b_scores.append(b_score)
        ct+=n
for i in xrange(len(a_scores)):
    print a_scores[i],b_scores[i]

Submission status: Runtime Error

Solution code:
a=[0]*10000
b=[0]*10000
ct=0
a_scores=[]
b_scores=[]
while True:
    a_score=0
    b_score=0
    n=input()
    if n==0:
        break
    else :
        for i in xrange(n):
            a[ct+i],b[ct+i]=map(int,raw_input().split())
            if a[ct+i]>b[ct+i]:
                a_score+=a[ct+i]+b[ct+i]
            elif a[ct+i]==b[ct+i]:
                a_score+=a[ct+i]
                b_score+=b[ct+i]
            else:
                b_score+=b[ct+i]+a[ct+i]
        print a_score,b_score
        ct+=n

Submission status: Runtime Error

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 a < b:
   B += a + b
  else:
   A += a
   B += b
  print("{0} {1}".format(A, B))
  n = int(input())

Submission status: Runtime Error

Solution code:
while true:
  n = input()
  if == 0: break
  score_a, score_b = 0, 0
  for i in xrange(n):
    a, b = map(int, raw_input().split(" "))
    if a > b:
      score_a += a + b
    elif a < b:
      score_b += a + b
    else:
      score_a += a
      score_b += b
  print "%d %d", (score_a, score_b)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
while 1:
 a=b=0;n=int(input())
 if n:
  for i in[0]*n:
   s,t=map(int,input().split())
   if s>t:a+=s+t
   elif s<t:b+=s+t
   else:a+=s;b+=t
  print(a,b)

Submission status: Runtime Error

Solution code:
while 1:
 a=b=0;n=int(input())
 if n==0:break
 for i in[0]*n:
  s,t=map(int,input().split())
  b+=s if s<t else a+=s
  a+=t if s>t else b+=t
 print(a,b)

Submission status: Runtime Error

Solution code:
import sys
e=iter(sys.stdin)
while 1:
 a=b=0;n=int(e)
 if n==0:break
 for i in[0]*n:
  s,t=map(int,e.split())
  if s>t:a+=s+t
  elif s<t:b+=s+t
  else:a+=s;b+=t
 print(a,b)

Submission status: Runtime Error

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    a_score = 0
    b_score = 0
    for i in range(0,3):
        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: Runtime Error

Solution code:
import string
a = 0
b = 0
while True:
    n = input()
    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

        print a,b
    else:
        n=0

Submission status: Runtime Error

Solution code:
a = 0
b = 0
while True:
    n = input()
    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

        print a,b
    else:
        n=0

Submission status: Runtime Error

Solution code:
while 1:
        n = input()
        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: Runtime Error

Solution code:
#include <stdio.h>

int main(){
	int a[1000], b[1000];
	int sumA=0, sumB=0;
	int n;
	int i;
	
	while(1){
		scanf("%d", &n);
		
		if(n==0) break;
		
		for(i=0; i<n; i++){
			scanf("%d %d", &a[i], &b[i]);
		}
		
		/*
		for(i=0; i<n; i++){
			printf("%d %d\n", a[i], b[i]);
		}
		*/
		
		for(i=0;i<n;i++){
			if(a[i] > b[i]) sumA += a[i]+b[i];
			if(a[i] < b[i]) sumB += a[i]+b[i];
			if(a[i] == b[i]){
				sumA += a[i];
				sumB += b[i];
			}
		}
		
		printf("%d %d\n", sumA, sumB);
		
		sumA = 0;
		sumB = 0;
		
	};
	
}

Submission status: Runtime Error

Solution code:
#include <stdio.h>

int main(void){
	int a[1000], b[1000];
	int sumA=0, sumB=0;
	int n;
	int i;
	
	while(1){
		scanf("%d", &n);
		
		if(n==0) break;
		
		for(i=0; i<n; i++){
			scanf("%d %d", &a[i], &b[i]);
		}
		
		/*
		for(i=0; i<n; i++){
			printf("%d %d\n", a[i], b[i]);
		}
		*/
		
		for(i=0;i<n;i++){
			if(a[i] > b[i]) sumA += a[i]+b[i];
			if(a[i] < b[i]) sumB += a[i]+b[i];
			if(a[i] == b[i]){
				sumA += a[i];
				sumB += b[i];
			}
		}
		
		printf("%d %d\n", sumA, sumB);
		
		sumA = 0;
		sumB = 0;
		
	};
	
}

Submission status: Runtime Error

Solution code:
def solve():
	while 1:
		n = int(input())
		if n==0:
			break
		score_a=0
		score_b=0
		while n>0:
			(a,b)=map(int, 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: Runtime Error

Solution code:
n = 1
while n!=0:
  A = 0
  B = 0
  n = int(input())
  if n == 0:
    break
  for i in range(n):
    [a, b] = map(int, input().split(' '))
    if a > b:
      A += a+b
    elif a < b:
      B += a+b
    else:
      A += a
      B += b
  print('%d%s%d'%(A,' ',B))

Submission status: Runtime Error

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

Submission status: WA: Presentation Error

Solution code:
while True:
    card_num = int(input())
    if(card_num == 0):
        break
    a = 0
    b = 0
    for i in range(card_num):
        comp = input()
        if(int(comp[0]) == int(comp[2])):
            a += int(comp[0])
            b += int(comp[0])
        elif(int(comp[0]) > int(comp[2])):
            a += int(comp[0]) + int(comp[2])
        elif(int(comp[0]) < int(comp[2])):
            b += int(comp[0]) + int(comp[2])
    print(str(a)+' '+ str(b) + '\n')

Submission status: WA: Presentation Error

Solution code:
while True:
    n = int(input())
    if n == 0:break
    sumA = sumB = 0
    for i in range(n):
        c = list(map(int,input().split()))
        if c[0]==c[1]:
            sumA = sumA+c[0]
            sumB = sumB+c[1]
        else:
            sumA = sumA + (c[0]+c[1] if c[0]>c[1] else 0)
            sumB = sumB + (c[0]+c[1] if c[1]>c[0] else 0)
    print(sumA, " " , sumB)

Submission status: WA: Presentation Error

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 score_f, score_s in zip(scores_first, scores_second):
    print(score_f, ' ', score_s)