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>
using namespace std;
int main(){
	int n;
	int a,b;
	int A,B;
	cin>>n;
	if(n==0){break;}
	while(true){
	for(int i=0;i<n;i++){
		cin>>a>>b;
	if(a>b){
		A+=a+b;
	}
	else if(a<b){
		B+=a+b;
	}
	else {
		A+=a;
		B+=b;
	}
	}
	}
	cout<<A<<" "<<B<<endl;
	return 0;
}

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

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

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

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

int main(){
int n,a,b;
int sumA=0,sumB=0;
while(cin>>n){
for(int i=0;i<n;i++){
cin>>a>>b;
if(a>b){
sumA+=a;
sumA+=b;
}
if(a==b){
sumA+=a;
sumB+=b;
}
if(a<b){
sumB+=a;
sumB+=b;
}}}

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

C++: #include<stdio.h>
int main()
{
	int i1, i2, b, k, n, m[2], **c, max[2], min[2];
	scanf("%d", &n);
	m[0] = n;
	m[1] = n;
	c    = new int * [2];
	c[0] = new int [n];
	c[1] = new int [n];
	for (i1 = 0; i1 < n; i1++)
		scanf("%d", &c[0][i1]);
	qsort(c[0], n, sizeof(int), compare);
	min[0] = 0;
	max[0] = n - 1;
	k = 0;
	for (i1 = 1; i1 < c[0][0]; i1++) {
		c[1][k] = i1;
		k++;
	}
	for (i1 = 0; i1 < n-1; i1++) {
		for (i2	= c[0][i1]+1; i2 < c[0][i1+1]; i2++) {
			c[1][k] = i2;
			k++;
		}
	}
	min[1] = 0;
	max[1] = n - 1;
	k       = 1;
	b       = c[0][0];
	min[0]  = 1;
	c[0][0] = 0;
	m[0]--;
	while (m[0] > 0 && m[1] > 0) {
		if (b > c[k][max[k]])
			b = -1;
		else {
			for (i1 = min[k]; i1 <= max[k]; i1++) {
				if (c[k][i1] > b) {
					b        = c[k][i1];
					c[k][i1] = 0;
					m[k]--;
					if (i1 == min[k]) {
						for (i2 = min[k]+1; i2 <= max[k]; i2++) {
							if (c[k][i2] > 0) {
								min[k] = i2;
								break;
							}
						}
					}
					else if (i1 == max[k]) {
						for (i2 = max[k]-1; i2 >= min[k]; i2--) {
							if (c[k][i2] > 0) {
								max[k] = i2;
								break;
							}
						}
					}
					break;
				}
			}
		}
		k = (k + 1) % 2;
	}
	printf("%d\n%d\n", m[1], m[0]);

	return 0;
}

C++: #include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <time.h>
#include <stdlib.h>
using namespace std;

int main(){
	while(1){
		int a,b,n,aa,bb;
		cin >> n;
		if(n==0) return 0;
		aa=0;
		bb=0;
		for(int i=0;i<n;i++){
			cin >> a;
			cin >> b;
			if(a>b) aa+= a+b;
			else if(b>a) bb += a+b;
			else{
				aa+=a;
				bb+=b;
			}
		}
		printf("%d %d\n",aa,bb);
	}
	return 0;
}

C++: #include<stdio.h>
#include<iostream>

using namespace std;

int main(){

int n;
while(cin>>n,n){
int Ac[10001];
int Bc[10001];
int Ap=0;
int Bp=0;

for(int i=0;i<n;i++)cin>>Ac[i]>>Bc[i];

for(int i=0;i<n;i++){

  if(Ac[i]>Bc[i])Ap+=Ac[i]+Bc[i];
  else if(Ac[i]<Bc[i])Bp+=Ac[i]+Bc[i];
  else if(Ac[i]==Bc[i]){
   Ap+=Ac[i];
   Bp+=Bc[i];
  }
 }

cout<<Ap<<' '<<Bp<<endl;

}

return 0;

}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<math.h>

using namespace std;

int n,a,b,asum,bsum;

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

C++: #include<iostream>
using namespace std;
int main(){
  int n,i,asum,bsum,a_card,b_card;
  cin >> n;
  while(n!=0){
    asum=0; bsum=0;
    for(i=0;i<n;i++){
      cin >>a_card>>b_card;
      if(a_card>b_card){
	asum+=a_card+b_card;
      }else if(a_card<b_card){
	bsum+=a_card+b_card;
      }else{
	asum+=a_card;
	bsum+=b_card;
      }
    }
      cout << asum<<" "<<bsum<<endl;
      cin >>n;
  }
}

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

int main(){
  int n;
  int Acard,Bcard;
  int Atotal,Btotal;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>Acard>>Bcard;
    if(Acard>Bcard){
      Atotal+=Acard+Bcard;
    }else if(Bcard>Acard){
      Btotal+=Acard+Bcard;
    }else{
      Atotal+=Acard;
      Btotal+=Bcard;
    }
  }

  cout<<Atotal<<' '<<Btotal;
  return 0;
}

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

C++: #include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 1 << 30
#define LLINF LLONG_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll fact(ll a){ll b=1;FOR(i,1,a)b*=i;return b;}
ll power(ll x,ll n){ll a=1;REP(i,n)a*=x;return a;}

int n,x,y;

int main()
{
  while(1)
  {
    scanf("%d",&n);
    if(n==0) return 0;
    int A = 0;
    int B = 0;
    REP(i,n)
    {
      scanf("%d %d",&x,&y);
      if(x>y) A+=(x+y);
      else if(x<y) B+=(x+y);
      else
      {
        A+=x;
        B+=y;
      }
    }
    printf("%d %d\n",A,B);
  }
}

C++: #include <iostream>
#include <string>
using namespace std;
   
#define MAX_PLAY 2
#define MAX_ROUNDS 10000
   
int rounds[MAX_ROUNDS][MAX_PLAY];
int total_a = 0, total_b = 0;
   
void cards(int i) {
    if(rounds[i][0] > rounds[i][1]) {
        total_a += (rounds[i][0] + rounds[i][1]);
    }
    else if (rounds[i][0] < rounds[i][1]) {
        total_b += (rounds[i][0] + rounds[i][1]);
    }
    else {
        total_a += rounds[i][0];
        total_b += rounds[i][1];
    }
}
  
void card_counter()
{
    int n;
    while(cin >> n) {
      if(n == 0) {
          break;
      }
      for(int i = 0; i < n; i++) {
          cin >> rounds[i][0] >> rounds[i][1];
      }
      for(int j = 0; j < n; j++) {
          cards(j);
      }
      cout << total_a << " " << total_b << endl;
      total_a = 0, total_b = 0;
    }
}
  
int main() {
card_counter();
return 0;
}