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 <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const ll MOD = (ll) (1e9 + 7);
//const ll MOD = 998244353;
const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

void finish() {
    cout << -1 << endl;
    exit(0);
}

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << setiosflags(ios::fixed);


    int n;
    int a_sum, b_sum;

    while (1) {
        cin >> n;
        if (n == 0) break;
        a_sum = 0, b_sum = 0;

        rep(i, n) {
            int a, b;
            cin >> a >> b;
            if (a > b) a_sum += a + b;
            else if (a < b) b_sum += a + b;
            else a_sum += a, b_sum += b;
        }
        cout << a_sum << " " << b_sum << endl;
    }

    return 0;
}

C++: #include<iostream>
using namespace std;
int i, n, pA, pB, tA = 0, tB = 0;
int main(){
while(cin >> n) {
if(n == 0) { break; }
for (i=1; i<=n; i++) {
cin >> pA >> pB;
if (pA > pB) {
tA += pA + pB;
} else {
if (pA < pB) {
tB += pA + pB;
} else {
tA += pA;
tB += pB;
}
}
}
cout << tA << "" << tB << endl;
tA = 0; tB = 0;
}
return 0;
}

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

C++: #include<iostream>
using namespace std;
int main() {
	int a[100] = { 0 }, b[100] = { 0 };
	int x;
	int n, m;
	int j = 0;
	int length;
	while (true) {
		cin >> x;
		if (x == 0){
			length = j;
			break;
		}
		for (int i = 0; i < x; i++) {
			cin >> n >> m;
			if (n > m) {
				a[j] += n + m;
			}
			else  if (n < m) {
				b[j] += n + m;
			}
			else {
				a[j] += n;
				b[j] += m;
			}
		}
		j++;
	}
	for (int i = 0; i < length; i++){
		cout << a[i] << " " << b[i] << endl;
	}
	char c;
	cin >> c;
}

C++: #include <iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	while(n!=0){
		int point[2];
		enum {
			A,
			B,
		};
		int sum[2] = {0,0};
		for (int i = 0; i < n; i++) {
			cin>>point[A]>>point[B];
			if (point[A]>point[B]) {
				for (auto j : point) {
					sum[A]+=j;
				}
			} else if(point[A] == point[B]) {
				for (auto j : sum) {
					j+=point[A];
				}
			} else {
				for (auto j : point) {
					sum[B]+=j;
				}
			}
		}
		cout<<sum[A]<<" "<<sum[B]<<endl;
		cin>>n;
	}
	return 0;
}

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

int A = 0, B = 0, j;

int main(){
    for(;;){
        if(cin >> j){
            if(j == 0){
                break;
            }
            for(int i = 0; i < j; i++){
                int as, bs;
                cin >> as >> bs;
                if(as > bs){
                    A += as + bs;
                }else if(as < bs){
                    B += as + bs;
                }else{
                    A += as;
                    B += bs;
                }
            }
            cout << A << " " << B << endl;
        }else{
            break;
        }
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)

int main() {
    int n, a, b;
    while(cin >> n, n){
        a = 0;
        b = 0;
        REP(i,n){
            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;
    }
    return 0;
}

C++: #include<iostream>

using namespace std;

int main()
{
	int n;
	int a[10000], b[10000];
	int a_score = 0;
	int b_score = 0;
	int i;
	
	cin >> n;		//J[hÌ
	
	for(i = 0;i < n; i++){
		cin >> a[i];
		cin >> b[i];
		if((a[i] == 0)||(b[i] == 0)){
			break;
		}
	}
	
	for(; i > -1; i--){
		if(a[i] > b[i]){
			a_score += a[i] + b[i];
		}
		else if(a[i] < b[i]){
			b_score += a[i] + b[i];
		}
		else{
			a_score += a[i];
			b_score += b[i];
		}
	}
	cout << a_score << " " << b_score << endl;
}

C++: #include <stdio.h>

int main(void)
{

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

	scanf("%d", &n);

	for(int i = 0; i < n; i++){
		
		if(scanf("%d %d", &ac,&bc) == EOF)
			break;
		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>

using namespace std;

int main()
{
	int n;
	int a[20000], b[20000];
	int a_score;
	int b_score;
	int score_stock[20000][2];
	int i, j;
	for(j = 0;;j++){
		a_score = 0;
		b_score = 0;
		cin >> n;		//J[hÌ
		if(n == 0){
			break;
		}
		
		for(i = 0;i < n; i++){
			cin >> a[i];
			cin >> b[i];
		}
		
		for(; i > -1; i--){
			if(a[i] > b[i]){
				a_score += a[i] + b[i];
			}
			else if(a[i] < b[i]){
				b_score += a[i] + b[i];
			}
			else{
				a_score += a[i];
				b_score += b[i];
			}
		}
		score_stock[j][0] = a_score;
		score_stock[j][1] = b_score;
	}
	for(i = 0; i < j; i++){
		cout << score_stock[i][0] << " "<<score_stock[i][1] << endl;
	}
}

C++: #include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i;
  int a,b,c,d,n;
  while(cin>>n&&n){
    c=d=0;
    for(i=0;i<n;i++){
      cin>>a>>b;
      if(a>b)
	c+=a+b;
      else if(a<b)
	d+=a+b;
      else{
	c+=a;
	d+=b;
      }
    }
    cout<<c<<" "<<d<<endl;
  }
  return 0;
}

C++: #include<iostream>
int main() {
	int n;
	while (std::cin >> n, n) {
		int asum = 0, bsum = 0, a, b;
		for (int i = 0; i < n; i++) {
			std::cin >> a >> b;
			if (a > b)
				asum += a + b;
			else if(a < b)
				bsum += a + b;
		}
		std::cout << asum << " " << bsum << std::endl;
	}
	return 0;
}

C++: #include <cstdio>

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