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;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  while (true) {
    int n; cin >> n;
    if (n == 0) break;
    V<> a(n), b(n); for (int i = 0; i < n; ++i) cin >> a[i] >> b[i];
    int sa = 0, sb = 0;
    for (int i = 0; i < n; ++i) {
      if (a[i] == b[i]) {
        sa += a[i];
        sb += b[i];
      } else {
        (a[i] > b[i] ? sa : sb) += a[i] + b[i];
      }
    }
    cout << sa << ' ' << sb << '\n';
  }
}

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

C++: #include <iostream>
using namespace std;
int main(){

	int n, a, b, ap = 0, bp = 0;

	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a >> b;

		//?????°?????´??°
		if (a > b)
			ap += a + b;
		else if (a < b)
			bp += a + b;
		else{
			ap += a;
			bp += b;
		}
	}

	cout << ap << ' ' << bp << endl;
}

C++: #include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cfloat>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define EACH( v, c ) for ( auto &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

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

	while ( true )
	{
		int n;
		cin >> n;

		if ( !n )
		{
			break;
		}

		int res1 = 0, res2 = 0;

		REP( i, 0, n )
		{
			int a, b;
			cin >> a >> b;

			if ( a == b )
			{
				res1 += a;
				res2 += b;
			}
			else if ( a < b )
			{
				res2 += a + b;
			}
			else
			{
				res1 += a + b;
			}
		}
		
		cout << res1 << ' ' << res2 << endl;
	}

	return 0;
}

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

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

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

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

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

int main() {
	int suma, sumb, a, b, n;
	while (1) {
		suma = sumb = 0;
		cin >> n;
		if (n == 0) break;
		
		while (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;
	}
	
	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]);
    }
  }
}

C++: #include<iostream>
using namespace std;
 
int main(){
	int a;
	int uma;
	int ushi;
	int b;
	int c;

	cin >> a;
	for (int i; i < a; i++){
		cin >> b;
		cin >> c;
		if (b>c){
			uma = uma + 2;
		}
		if(b=c){
			uma = uma + 1;
			ushi = ushi + 1;
		}
		else{
			ushi = ushi + 2;
		}
	}
	cout << uma << ushi;

}

C++: #include <cstdio>

int main(){
	int n = 1;
	
	while(n){
		scanf("%d", &n);
		if(n == 0)break;
		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;
}

C++: #include<iostream>
using namespace std;
int main(){
    int n;
    while(cin>>n,n){
        int A=0,B=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;
    }
}

C++: #include<stdio.h>

int main(){

int N;int A,B,SA=0,SB=0;
while(1){
SA=0,SB=0;

scanf("%d",&N);
if(N==0)break;
for(int i=0;i<N;i++){
scanf("%d %d",&A,&B);
if(A>B)SA=SA+A+B;
else if(B>A)SB=SB+A+B;
else SA+=A;SB+=B;
}

printf("%d %d\n",SA,SB);
}
return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	while(true){
  int a=0,b=0,N,Card[2];
  cin >> N;
  if(N==0)
 	break;
  for(int i=0;i<N;i++){
  	cin >> Card[0] >> Card[1];
  	int sum=Card[0]+Card[1],truth=(Card[0]>Card[1]);
  	a+=sum*truth;
  	b+=sum*!(truth);
  }
  cout << a << " "<< b << endl;
	}
  return 0;
}

C++: #include <iostream>
#include <vector>

#define FOR(i,begin,end) for(int i = (begin); i < (end); ++i)

using namespace std;

struct Data {
    int A, B;
    Data(int a, int b) : A(a), B(b) {}
};

int N;
vector<Data> inputs;

void solve() {
    int A_sum = 0, B_sum = 0;
    FOR(i, 0, N) {
        int A = inputs[i].A;
        int B = inputs[i].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;
    }
}

int main() {
    cin >> N;
    while (N > 0) {
        inputs.clear();

        FOR(i, 0, N) {
            int A, B;
            cin >> A >> B;
            inputs.push_back(Data(A, B));
        }

        solve();
        cin >> N;
    }

    return 0;
}