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 <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <map>
#include <set>
#include <stack>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()
 
#define REP(i,s,e)	for(int i=(s); i<(e); i++)
#define rep(i,n)	REP(i,0,n)
#define REPE(i,s,e)	for(int i=s; i>e; i--)
#define repe(i,n)	REPE(i,n,-1)


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<vi> vvi;
 
const int IMAX=((1<<30)-1)*2+1;
const int INF=100000000;
const double EPS=1e-10;
//int mod=1000000007
 


int main(){
	int n;
	while(cin >> n && n>0){
		int a,b,sa=0,sb=0;
		rep(i,n){
			cin>>a>>b;
			if(a>b) sa+=(a+b);
			else if(a==b) sa+=a,sb+=b;
			else sb+=(a+b);
		}
		cout<<sa<<" "<<sb<<endl;
	}
}

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

#define times(n, i)      uptil(0, n, i)
#define upto(f, t, i)    for(decltype(t) _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(decltype(t) _##i = (t), i = (f); i < _##i; i++)
#define downto(f, t, i)  for(decltype(t) _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(decltype(t) _##i = (t), i = (f); i > _##i; i--)
#define unless(c) if(!(c))
#define until(c) while(!(c))
#define loop while(true)

#define all(v) v.begin(), v.end()
#define ln << "\n"

struct line{};

template<class T> istream& operator>>(istream& in, vector<T>& v) {
    times(v.capacity(), i) in >> v[i];
    return in;
}

template<class T> const ostream& operator<<(ostream& out, const vector<T>& v) {
    times(v.size(), i) out << (i ? " " : "") << v[i];
    return out;
}

template<class T, class...U> typename enable_if<is_same<T, line>::value, string>::type next(istream& in, const U&... args) {
    string s;
    getline(in, s, args...);
    return move(s);
}

template<class T, class...U> typename enable_if<!is_same<T, line>::value, T>::type next(istream& in, const U&... args) {
    T t(args...);
    in >> t;
    return move(t);
}
template<class T, class...U> auto next(const U&... args) -> decltype(next<T>(cin)) {
    return next<T>(cin, args...);
}

template<class T> T sum(const vector<T>& v) {
    T ans = T();
    for(const T& t : v) ans += t;
    return ans;
}

template<class T> T sum(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    T ans = T();
    for(typename vector<T>::iterator t = begin; t != end; t++) ans += *t;
    return ans;
}

template<class T> T min(const vector<T>& v) {
    return *min_element(v.begin(), v.end());
}

template<class T> T min(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    return *min_element(begin, end);
}

template<class T> T max(const vector<T>& v) {
    return *max_element(v.begin(), v.end());
}

template<class T> T max(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    return *max_element(begin, end);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    loop {
        int a = 0, b = 0, N = next<int>();
        unless(N) break;

        times(N, _) {
            int x = next<int>(), y = next<int>();
            if(x >= y) a += x;
            else       b += x;
            if(x <= y) b += y;
            else       a += y;
        }
        cout << a << " " << b ln;
    }

    return 0;
}

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

C++: #include <stdio.h>
int n,i,j,k;
int A[1],B[1];
int main(){
  for(;;){
    scanf("%d",&n);
    if(n==0){
      return 0;
    }
      for(i=0;i<n;i++){
      scanf(" %d %d",&j,&k);
      if(j>k){
        A[0]+=(j+k);
      } else if(j<k){
        B[0]+=(j+k);
      } else if(j==k){
        A[0]+=j;
        B[0]+=k;
      }
      printf("%d %d\n",A[0],B[0]);
      A[0]={0},B[0]={0};
    }
  }
}

C++: #include<iostream>

using namespace std;

int main()
{
	while (1){
		int kaisu, ten1 = 0, ten2 = 0;
		cin >> kaisu;
		if (kaisu == 0)break;
		while (kaisu--)
		{
			int x, y;
			cin >> x >> y;
			if (x > y)
			{
				ten1 += x + y;
			}
			else if (x < y)
			{
				ten2 += x + y;
			}
			else
			{
				ten1 += x;
				ten2 += y;
			}
		}
		cout << ten1 << " " << ten2 << endl;;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main() {
	int n = 0;
	int aa, bb = 0;
	while (cin >> n, n != 0) {
		aa = 0;
		bb = 0;
		int a[10000] = {};
		int b[10000] = {};


		for (int i = 0; i < n; i++) {
			cin >> a[i] >> b[i];
		}
		for (int j = 0; j < n; j++) {
			if (a[j] > b[j]) {
				aa += a[j] + b[j];
			}
			else if (a[j] < b[j]) {
				bb += a[j] + b[j];
			}
			else if (a[j] == b[j]) {
				aa += a[j];
				bb += b[j];
			}
		}
		cout << aa << " " << bb << endl;

	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main() {
	int n,a,b;
	while (cin >> n && n) {
		int suma = 0, sumb = 0;
		for (int i = 1; i <= n; ++i) {
			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;
	}
	return 0;
}

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

int main() {
	int num;
	int score_a = 0;
	int score_b = 0;
	
	cin >> num;
	while (num != 0) {
		for (int i = 0; i < num; i++) {
			int a;
			int b;

			cin >> a >> b;
			if (a > b) {
				score_a += a + b;
			}else if (b > a) {
				score_b += a + b;
			}else {
				score_a += a;
				score_b += b;
			}
		}
		cout << score_a << " " << score_b << endl;
		score_a = 0;
		score_b = 0;
	}

	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) { a+=x+y;}
			else if(x>y) { b+=x+y;}
			else if(x==y) {a+=a; b+=b;}
		}
cout<<a<<" "<<b<<endl;
            }
	return 0;
}

C++: #include<iostream>
using namespace std;
int i, n, pA, pB, tA = 0, tB = 0;
int main () {
    whole(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<iostream>
using namespace std;
int main(){
  int n,m,t,mt,tt;
  while(cin>>n){
    if(n==0) break;
    mt = 0;
    tt = 0;
    for(int i=0;i<n;i++){
      cin >> m >> t;
      if(m>t) mt += (m+t);
      else if(t>m) tt += (m+t);
      else{
	mt += m;
	tt += t;
      }
    }
    cout << mt << ' ' << tt << endl;
  }
  return 0;
}