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)
}

C++: // aoj-5000.cpp

#include <cstdio>

int main() {
	int i;
	int cards, a, b, scoreA = 0, scoreB = 0;

	// read number of cards
	scanf("%d", &cards);

	for (i=0; i<cards; ++i) {
		scanf("%d %d", &a, &b);
		if (a > b) {
			scoreA += (a + b);
		} else if (b > a) {
			scoreB += (a + b);
		} else {
			scoreA += a;
			scoreB += b;
		}
	}

	printf("%d %d\n", scoreA, scoreB);

	return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#define MAX 10000
using namespace std;
int n,m,a[MAX],b[MAX];
string S;

int main(){
    while (1) {
        int p;
        cin >> p;
        if (p!=0) {
            int suma=0,sumb=0;
            for (int i = 0; i<p; i++){
                cin >> n >> m;
                if (n>m) {
                    suma += (n+m);
                }
                if (n<m){
                    sumb += (n+m);
                }
                if (n==m) {
                    suma += n;
                    sumb += m;
                }
            }
            cout << suma << " "<<sumb <<"\n";
        }else{
            break;
        }
    }
    
}

C++: #include<stdio.h>
void judge(int n, int a[], int b[], int *result1, int *result2) {
	while (--n >= 0) {
		if (a[n] > b[n]) {
			*result1 += a[n] + b[n];
		}
		else if (a[n] < b[n]) {
			*result2 += a[n] + b[n];
		}
		else if (a[n] == b[n]) {
			*result1 += a[n];
			* result2 += b[n];
		}
	}
}
int main() {
	int a[10];
	int b[10];
	int n, t = 0;
int i;
	int result1 = 0, result2 = 0;
	int result[10][2];
	do {
		scanf("%d", &n);
		for (i = 0; i < n; i++) {
			scanf("%d %d", &a[i], &b[i]);
		}
		judge(n, a, b, &result1, &result2);
		result[t][0] = result1;
		result[t][1] = result2;
		result1 = 0;
		result2 = 0;
		t++;
	} while (n != 0);

	for (i = 0; i < t-1;i++) {
		printf("%d %d\n", result[i][0], result[i][1]);
	}

	return 0;
}

C++: #include <iostream>
using namespace std;

int N;
const int MAX_N = 10000;
int a[MAX_N];
int b[MAX_N];

int main()
{
	cin >> N;
	while(N){
		int geta=0,getb=0;
		for(int i=0;i<N;i++){
			cin >> a[i] >> b[i];
			if(a[i] > b[i])
				geta += a[i] + b[i];
			else if(a[i] < b[i])
				getb += a[i] + b[i];
			else{
				geta += a[i];
				getb += b[i];
			}
		}
		cout << geta << " " << getb << endl;
		cin >> N;
	}
	return 0;
}

C++: #include <iostream>
#include <stdio.h>
using namespace std;

int main()
{

	int n;
	int a=0,b=0;
	int ac,bc;

	cin >> n;

	while(n > 0){
		n--;
		cin >> ac >> bc;
		if(ac > bc)
			a += ac + bc;
		else if(ac < bc)
			b += ac + bc;
		else
			a += ac, b = bc;
	}
	printf("%d %d\n", a,b);


	return 0;
}

C++: #include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int main(){
    ios::sync_with_stdio(false);

    START:

    int n;
    int a = 0;
    int b = 0;
    cin >> n;
    if(n == 0) return 0;
    for(int i=0; i<n; i++){
        int x,y;
        cin >> x >> y;
        if(x > y){
            a += x + y;
        }
        else if(x < y){
            b += x + y;
        }
        else{
            a += x;
            b += y;
        }
    }
    cout << a << " " << b << endl;

    goto START;

    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
    while(1){
        int N,suma=0,sumb=0,x,y;
        cin >> N;
        if(N==0)    break;
        while(N--){
            cin >> x >> y;
            if(x>y) suma=suma+x+y;
            else    sumb=sumb+x+y;
        }
        cout << suma << " " << sumb << "\n";
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main() {
	int n;
	int a,b;
	int ta,tb;
	scanf("%d",&n);
	while(n){
		ta=tb=0;
		for(int i=0;i<n;i++){
			scanf("%d %d",&a,&b);
			if(a>b){
				ta+=a+b;	
			}else if(a<b){
				tb+=a+b;
			}else{
				ta+=a;
				tb+=b;
			}
		}
		printf("%d %d\n",ta,tb);
		scanf("%d",&n);
	}
	return 0;
}

C++: #include <cstdio>
int main(){
 int asum,bsum,a,b,n,i;
 scanf("%d",&n);
 while(n>0){
 asum=bsum=0;
 for(i=0;i<n;i++){
  scanf("%d %d",&a,&b);
  if (a>b) asum += a+b;
  if (a<b) bsum += a+b;
  if (a==b) { asum += a; bsum += b; }
 };
 printf("%d %d\n",asum,bsum);
 scanf("%d",&n);
 }
 return 0;
};

C++: #include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n,a,b,countA=0,countB=0;
    cin>>n;
    if(n!=0){
    do{
        for(int i=0;i<n;i++){
            cin>>a>>b;
            if(a>b){
                countA+=(a+b);
            }else if(a<b){
                countB+=(a+b);
            }//a==b
        }
        cout<<countA<<" "<<countB;
        cout<<"\n";
        countA=0,countB=0;
        cin>>n;
        if(n==0)break;
    }while(1);
    }
    cout<<endl;
}

C++: #include <stdio.h>

int main() {
    while (1) {
        int n;
        scanf("%d", &n);
        if (n == 0) {
            break;
        }

        int a, b;
        a = 0;
        b = 0;
        while (n--) {
            int _a, _b;
            scanf("%d%d", &_a, &_b);
            if (_a > _b) {
                a += _a + _b;
            } else if (_a < _b) {
                b += _b + _a;
            } else {
                a += _a;
                b += _b;
            }
        }
        printf("%d %d\n", a, b);
    }
}

C++: #include<iostream>
using namespace std;
int main(){
int n,sum;
int a[10000],b[10000];
while(cin>>n){
a[10000]={};
b[10000]={};
int ap=0,bp=0;
	for(int i=0;i<n;i++){
		cin>>a[n]>>b[n];
		sum=a[n]+b[n];
		if(a[n]>b[n]){
			ap+=sum;
		}else if(a[n]<b[n]){
			bp+=sum;
		}else{
			ap+=a[n];
			bp+=b[n];
		}
	}
	cout<<ap<<" "<<bp<<endl;
}

return 0;
}

C++: #include <stdio.h>
#include <iostream>
using namespace std;
int main (){
while (1){
int i,ny[100]={0},ny2[100]={0},sum=0,sum2=0;
scanf ("%d",&i);
if (i==0)break;
for (int s=0;s<i;s++){
        scanf ("%d%d",&ny[s],&ny2[s]);
}
for (int s=0;s<i;s++){
        if (ny[s]==ny2[s]){
        sum=sum+ny[s];
        sum2=sum2+ny2[s];
        }
        else if (ny[s]>ny2[s]){
                sum=sum+ny[s]+ny2[s];
        }
        else {
                sum2=sum2+ny[s]+ny2[s];
        }
}
printf ("%d %d\n",sum,sum2);
}
return -1;
}

C++: #include <iostream>
#include <string>
using namespace std;
int main(){
int n;
int a;
int b;
int c;
int d;
int e;
while(cin >>n){
c=0;
d=0;
e=0;
while(e<n){
cin >>a;
cin >>b;
if(a>b){c=c+a+b;}
if(a==b){c=c+a; d=d+b;}
if(a<b){d=d+a+b;}
e=e+1;}
cout << c <<" "<<d<<endl;
}

}