Go: package main

import (
	"fmt"
)

// Game is one game.
type Game struct {
	pointA, pointB int
}

func main() {
	var n int
	game := &Game{0, 0}
	fmt.Scanf("%d", &n)
	for n != 0 {
		game.initGame()
		game.execGame(n)
		game.printResult()
		fmt.Scanf("%d", &n)
	}
}

func (game *Game) execGame(n int) {
	var a, b int
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a)
		fmt.Scanf("%d", &b)
		switch {
		case a == b:
			game.pointA += a
			game.pointB += b
		case a > b:
			game.pointA += a + b
		case b > a:
			game.pointB += a + b
		}
	}
}

func (game *Game) initGame() {
	game.pointA = 0
	game.pointB = 0
}

func (game *Game) printResult() {
	fmt.Println(game.pointA, game.pointB)
}

Python: def main():
    while True:
        n = int(input())
        if n:
            aa,ba = 0,0
            a,b = [None]*n,[None]*n
            for i in range(n):
                a[i],b[i] = map(int, input().split())
                if a[i] > b[i]:
                    aa += (a[i]+b[i])
                elif a[i] < b[i]:
                    ba += (a[i]+b[i])
                else:
                    aa += a[i]
                    ba += b[i]
            print(aa,ba)
        else:
            break

if __name__ == '__main__':
    main()

Python: #coding: utf-8

n = int(input())
s = [list(map(int, input().split(' '))) for i in range(n)]

win = {True: 0, False: 0}
for a, b in s:
    win[a>b] += (a + b)

print(win[True], win[False])

Python: while 1:
 a=b=0;n=int(input())
 if n==0:break
 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)

Python: 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)

Python: 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)

Python: while True:
    try:
        n = int(input())
        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]))
    except EOFError:
        exit()

Python: 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)

Python: import sys
def main():
    for line in sys.stdin:
        n = int(line)
        if n == 0:
            break
        else:
            A = []
            B = []
            for _ in range(n):
                hoge, fuga = map(int, input().split())
                A.append(hoge)
                B.append(fuga)

            a, b = 0, 0
            for x in range(n):
                if A[x] == B[x]:
                    a += A[x]
                    b += B[x]
                else:
                    piyo = A[x] + B[x]
                    if A[x] > B[x]:
                        a += piyo
                    else:
                        b += piyo
            print(a, b)


if __name__ == "__main__":
    main()

Python: def input_n(inputfile,outputfile):
	while True:
		n = inputfile.readline()
		n = int(n)
		if n == 0:
			break
		battle(inputfile,outputfile,n)

def battle(inputfile,outputfile,n):
	apoint = 0
	bpoint = 0
	for i in range(n):
		a , b = inputfile.readline().split()
		a = int(a)
		b = int(b)
		if a > b:
			apoint += (a + b)
		elif b > a:
			bpoint += (a + b)
		else:
			apoint += a
			bpoint += b
		print >> outputfile, apoint, bpoint

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

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

Python: 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)

Python: while True:
    n = int(input())
    if n == 0:
        break
    pointA, pointB = 0, 0
    for i in range(n):
        cardA, cardB = map(int, input().split())
        if cardA == cardB:
            pointA += cardA
            pointB += cardB
        elif cardA > cardB:
            pointA += cardA + cardB
        else:
            pointB += cardA + cardB
    print(pointA, pointB)

C++: #include<iostream>
using namespace std;
int main(){
	while (1){
		int n, a[15] = {}, b[15] = {}, A = 0, B = 0;
		cin >> n;
		if (n == 0){ break; }
		for (int i = 0; i < n; i++){
			cin >> a[i] >> b[i];
			if (a[i] > b[i]){
				A = A + a[i] + b[i];
			}
			else if (a[i] < b[i]){
				B = B + a[i] + b[i];
			}
			else if(a[i]==b[i]){
				A = A + a[i];
				B = B + b[i];
			}
		}
		cout << A << " " << B << endl;
	}
	return 0;
}

C++: #include <stdio.h>

int main(){
	int a[10000], b[10000];
	int sumA, sumB;
	int n;
	int i;
	
	sumA = 0;
	sumB = 0;
	
	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;
		
	};
	
	return 0;
}

C++: #include <stdio.h>

int main(){
int n,i;
int a,b,f,t;

while(1){
scanf("%d",&n);
if(n==0)break;
a=0;
b=0;
f=0;
t=0;
for(i=0;i<n;i++){
scanf("%d %d",&a,&b);
if(a==b){
f+=a;
t+=b;
}
else if(a>b){
f+=a+b;
}
else if(a<b){
t+=a+b;
}
}
printf("%d %d\n",f,t);
}

return 0;
}

C++: #include<iostream>
#include<vector>
int main() {
	int n;
	int g = 0;
	int s = 0;
	int a, b;
	while (true)
	{
		std::cin >> n;
		if (n == 0)
			break;
		for (int i = 0; i < n; ++i) {
			std::cin >> a >> b;
			if (a == b)g += a, s += b;
			if (a > b) g += a + b;
			if (a < b) s += b + a;
		}
		std::cout << g << " " << s << std::endl;
	}
	return 0;
}

C++: #include <stdio.h>

int main(void)
{
	int i;
	int a[10000], b[10000];
	int n;
	int ans_a, ans_b;
	
	while (1){
		
		ans_a = 0;
		ans_b = 0;
		
		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++){
			if (a[i] > b[i]){
				ans_a += (a[i] + b[i]);
			}
			else if (a[i] < b[i]){
				ans_b += (a[i] + b[i]);
			}
			else {
				ans_a += a[i];
				ans_b += b[i];
			}
		}
		printf("%d %d\n", ans_a, ans_b);
	}
	return (0);
}