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++: #include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <cstdio>
#include <string.h>
using namespace std;

#define FOR(i, n) for(int i = 0; i < n; i++)
#define bit(i) static_cast<bitset<8> >(i)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long>PLL;
typedef queue<int> QI;
typedef priority_queue<int> maxpq;
typedef priority_queue<int, vector<int>, greater<int> > minpq;

struct edge{int to, cost;};

void begin(){cin.tie(0); ios::sync_with_stdio(false);};
int gcd(int a, int b){if(a%b==0){return(b);}else{return(gcd(b,a%b));}};
int lcm(int m, int n){if((0 == m)||(0 == n)){return 0;} return ((m / gcd(m, n)) * n);};
unsigned long long comb(long n, long m){unsigned long long c = 1; m = (n - m < m ? n - m : m);
    for(long ns = n - m + 1, ms = 1; ms <= m; ns ++, ms ++){c *= ns; c /= ms;} return c;};

// ワーシャルフロイド法
void warshallFloyd(int d[100][100], int n){
    for(int k = 0; k < n; ++k)
        for(int i = 0; i < n; ++i)
            for(int j = 0; j < n; ++j)
                if(d[i][k] != -1 && d[k][j] != -1){
                    if(d[i][j] == -1){
                        d[i][j] = d[i][k] + d[k][j];
                    }else{
                        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
                    }
                }
};


// d:隣接行列  n:グラフのサイズ  s:始点  dist:始点からの距離が入る配列
void dijkstra(int d[1000][1000], int n, int s, int dist[1000]){
    FOR(i, n) dist[i] = -1;
    dist[s] = 0;
    priority_queue<PII, vector<PII>, greater<PII> > q;
    q.push(PII(0, s));
    while (!q.empty()) {
        PII p = q.top(); q.pop();
        int i = p.second;
        if(dist[i] < p.first) continue;
        for(int j = 0; j < n; j++){
            if(d[i][j] == -1) continue;
            if(dist[j] == -1){
                dist[j] = dist[i] + d[i][j];
                q.push(PII(dist[j], j));
            }else if(dist[j] > dist[i] + d[i][j]){
                dist[j] = dist[i] + d[i][j];
                q.push(PII(dist[j], j));
            }
        }
    }
};

// 線分の交差判定
bool isCross(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4){
    // 並行な場合
    int m = (x2-x1)*(y4-y3)-(y2-y1)*(x4-x3);
    if(m == 0) return false;
    // 媒介変数の値が0より大きく1以下なら交差する、これは問題の状況によって変わるかも。
    double r =(double)((y4-y3)*(x3-x1)-(x4-x3)*(y3-y1))/m;
    double s =(double)((y2-y1)*(x3-x1)-(x2-x1)*(y3-y1))/m;
    return (0 < r && r <= 1 && 0 < s && s <= 1);
};

/**
 * start
 * @author yoshikyoto
 */
void solve(int n){
    int sumA = 0, sumB = 0, a, b;
    FOR(i, n){
        cin >> a >> b;
        if(a > b){
            sumA += a + b;
        }else if(a < b){
            sumB += a + b;
        }else{
            sumA += a;
            sumB += b;
        }
    }
    cout << sumA << " " << sumB << endl;
}

int main(int argc, const char * argv[]){
    while(true){
        int n;
        cin >> n;
        if(n == 0) return 0;
        solve(n);
    }
}

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

int main () {
    int n, i,A,B, resa =0, resb =0;
    while(cin >> n,n){
        for(i=0;i<n;i++){
           　cin >> A >> B;
             (A > B)? resa +=A:resb+=B;
             if(A==B) {resa += A; resb +=B};
        }
　　　　cout << resa << " " << resb << endl;
    }
}

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

int main()
{	
	int n, a, b;

	cin >> n;
	
	while (n > 0) {
		a = 0;
		b = 0;

		for (int i = 0; i < n; i++) {
			int pa, pb;
			cin >> pa >> pb;

			if (pa > pb)
				a += pa + pb;
			else if (pa < pb)
				b += pa + pb;
			else {
				a += pa;
				b += pb;
			}
		}
		cout << a << " " << b << endl;

		cin >> n;
	}

	return 0;
}

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

int main()
{
	int x,y,n;
	while(cin>>n, n)
	{
		int a=0, b=0;
		while(n--)
		{
			cin>>x>>y;
			if(x<y) { b+=x+y;}
			else if(x>y) { a+=x+y;}
			else if(x==y) {a+=a; b+=b;}
		}
	}
		cout<<x<<y<<endl;
	return 0;
}

C++: 
int main(void){
  int n,a,b;
  int score[2];

  while(1){
    scanf("%d",&n);
    if(!n) break;
    score[0]=score[1]=0;
    while(n--){
      scanf("%d%d",&a,&b);
      if(a<b){
        score[1] += a+b;
      }
      else if(a>b){
        score[0] += a+b;
      }
      else{
        score[0] += a;
        score[1] += b;
      }
    }
    printf("%d %d\n",score[0],score[1]);
  }

  return 0;
}

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

int n, a, b, ca, cb;

int main()
{
	while (cin >> n && n > 0) {
		a = b = 0;
		for (int i = 0; i < n; i++) {
			cin >> ca >> cb;
			if (ca > cb)
				a += ca + cb;
			else if (ca < cb)
				b += ca + cb;
			else {
				a += ca;
				b += cb;
			}
		}
		cout << a << " " << b << endl;
	}
	return 0;
}

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

int n;
int solve(){
    vector<int> a(n),b(n);
    for(int i=0;i<n;i++){
        cin >> a[i] >> b[i];
    }

    int pa = 0, pb = 0;
    for(int i=0;i<n;i++){
        if(a[i] > b[i]) pa += a[i]+b[i];
        else if(a[i] < b[i]) pb += a[i]+b[i];
        else{
            pa += a[i];
            pb += b[i];
        }
    }
    cout << pa << " " << pb << endl;
}

int main(){
    while(1){
        cin >> n;
        if(n==0) break;
        solve();
    }
}

C++: #include<iostream>

using namespace std;
int A=0,B=0,a,b,n;
int main(){
cin >> n;

for(int i=0;i<n;i++){
    cin >> a >> b;
    if(a==b){
        A+=a;
        B+=b;
    }else if(a>b)A+=a+b;
    else B+=a+b;
}
cout << A <<' '<< B << endl;

return 0;
}

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

int main(){
	int n, x, y, sumx=0, sumy=0;
	cin >> n;

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

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

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

C++: #include <bits/stdc++.h>

using namespace std;

int main(){
    while(true){
    int n;
    scanf("%d", &n);
    if(n==0) return 0;
    vector<int> a(n), b(n);
    for(int i=0;i<n;++i) scanf("%d %d", &a[i],&b[i]);
    int as=0, bs=0;
    for(int i=0;i<n;++i){
        if(a[i]>b[i])as+=a[i]+b[i];
        else if(a[i]<b[i])bs+=a[i]+b[i];
        else {as+=a[i];bs+=b[i];}
    }
    printf("%d %d\n", as,bs);
    }
}

C++: #include <stdio.h>
 
int main(void){
    int n;
    int a,b;
    int aSum, bSum;
    
    while (scanf("%d", &n), n!=0){
        aSum = bSum=0;
        for (int i=0; i<n; i++){
            scanf("%d %d", &a, &b);
            if (a>b) aSum += (a+b);
            else if (a<b) bSum += (a+b);
            else aSum += a, bSum += b;
        }
        printf("%d %d\n", aSum, bSum);
    }
    
    return 0;
}