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>
int rounds;
int Ascore, Bscore;
int Acard,Bcard;
int main(){
	while (true){
		std::cin >> rounds;
		if (rounds == 0)break;
		for (int i = 0; i < rounds; i++){
			std::cin >> Acard>> Bcard;
			if (Acard > Bcard){
				Ascore += (Acard + Bcard);
			}
			else if (Acard < Bcard){
				Bscore += (Acard + Bcard);
			}
			else{
				Ascore += Acard;
				Bscore += Bcard;
			}
		}
		std::cout << Ascore << " " << Bscore << "\n";
		Ascore = 0, Bscore = 0;
	}
	return 0;
}

C++: #include <cstdio>
int main(void)
{
  while(1){
    int n;
    scanf("%d",&n);
    if(!n) break;
    int ap=0,bp=0;
    for(int i=0;i<n;i++){
      int a,b;
      scanf("%d %d",&a,&b);
      if(a > b) ap+=a+b;
      else if(a < b) bp+=a+b;
      else { 
	ap += a;
	bp += b;
      }
    }
    printf("%d %d",ap,bp);
  }
}

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

int main() {
	while(true){
		int n;
		cin>>n;
		
		if(n==0){
			break;
		}
		
		int sum_a=0,sum_b=0;
		for(int i=0;i<n;i++){
			int a,b;
			cin>>a>>b;
			
			if(a>b){
				sum_a+=a+b;
			} else if(a<b){
				sum_b+=a+b;
			} else{
				sum_a+=a;
				sum_b+=b;
			}
		}
	
		cout<<sum_a<<" "<<sum_b<<endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

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

C++: #include <iostream>
using namespace std;
int main(void){
	int n;
	while( cin >> n, n){
		int ap=0,bp=0,at,bt;
		for(int i=0;i<n;i++){
			cin >> at  >> bt;
			if(at>bt)
				ap+=at+bt;
			else if(bt>at)
				bp+=at+bt;
			else{
				ap+=at;
				bp+=bt;
			}
		}
	cout << ap << ' ' << bp << endl;
	}
	
return 0;
}

C++: #include<stdio.h>
#include<iostream>
using namespace std;
int main(){
int card[100],i,j,a=0,b=0,c=1,n;
cin>>n;
for(i=0;i<2*n;i++){
cin>>card[i];
}
for(i=0;i<2*n;i=i+2){
if(card[i]>card[c]){
a=a+card[i]+card[c];
}
else if (card[i]==card[c]){
a=a+card[i];
b=b+card[c];
}
else{
b=b+card[i]+card[c];
}
c=c+2;
}
cout<<a<<" "<<b<<endl;
return 0;
}

C++: #include<iostream>
#define rep(i,a) for(int i = 0; i < a; i++)
using namespace std;

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

C++: #include<iostream>
#include<string>
#include<sstream>
#include<cstdlib>

using namespace std;

int main(){
	while(1){
		string str;
		getline(cin,str);
		int n = atoi(str.c_str());
		if(n==0)break;
		int scoreA = 0, scoreB = 0;
		while(n--){
			getline(cin,str);
			stringstream ss(str);
			string tmp;
			getline(ss,tmp,' ');
			int a = atoi(tmp.c_str());
			getline(ss,tmp);
			int b = atoi(tmp.c_str());
			if(a>b)scoreA+=(a+b);
			else scoreB+=(a+b);
		}
		cout<<scoreA<<" "<<scoreB<<endl;
	}
	return 0;
}

C++: #include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
 
using namespace std;
 
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
 
const int INF=1<<29;
const double EPS=1e-9;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main(){
	int n;
	while(true){
		int a=0,b=0;
		cin >> n;
		if(n == 0){
			break;
		}
		rep(i,n){
			int buf,buf2;
			cin >> buf >> buf2;

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

C++: #include <cstdio>
using namespace std;
int n,a[10000],b[10000],x,y;
int main()
{
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%d %d",&a[i],&b[i]);
}
for(int i=0;i<n;i++){
if(a[i]==b[i]){x+=a[i]; y+=b[i];}
if(a[i]>b[i]) x+=a[i]+b[i];
if(a[i]<b[i]) y+=a[i]+b[i];
}
printf("%d %d",x,y);
}

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

int main()
{
  int n;
  int j, k;
  int suma, sumb;
  
  suma = sumb = 0;
  while (cin >> n){
    if (n == 0){
      break;
    }
    for (int i = 0; i < n; i++){
      cin >> j >> k;

      if (j < k){
        sumb += j + k;
     }
      else if (j > k){
        suma += j + k;
      }
     else {
        suma += j;
       sumb += k;
      }
    }
   cout << suma << " " << sumb << endl;
  }
  return 0;
}

C++: #include<iostream>

int main() {

	int n;

	int a[1000];

	int b[1000];

	for (int i = 0; i < 1000; i++){
		a[i] = 0;
	b[i] = 0;
}

	int x, y;

	int j=0;

	f:

	std::cin >> n;

	if (n == 0)
		goto flag;

	for (int i = 0; i < n; i++) {
		std::cin >> x >> y;
		if (x > y)
			a[j] += (x + y);
		if (x < y)
			b[j] += (x + y);
		if (x == y){
			a[j] += x;
		b[j] += y;
	}
	}

	j++;

	goto f;

flag:

	for(int i=0;i<j;i++)
	std::cout << a[i] << ' ' << b[i] << std::endl;

	return 0;

}

C++: #include<iostream>
using namespace std;
int main(){while(1){int n,a=0,b=0,c,d,s;cin>>n;if(n==0)break;for(int i=0;i<n;i++){cin>>c>>d;s=c+d,b+=s;if(c>d)a+=s;if(c==d)a+=c;}cout<<a<<" "<<b-a<<endl;}return 0;}

C++: #include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<long long,int> P;
static const int INF=1<<24;

int n;
int a[1010],b[1010];

int main(){
	while(cin>>n,n){
		rep(i,n){
			cin>>a[i]>>b[i];
		}
		int ans1=0,ans2=0;
		rep(i,n){
			if(a[i]<b[i]){
				ans2+=a[i]+b[i];
			}
			else if(a[i]==b[i]){
				ans1+=a[i];
				ans2+=b[i];
			}
			else{
				ans1+=a[i]+b[i];
			}
		}
		cout<<ans1<<" "<<ans2<<endl;
	}
	return 0;
}

C++: #include<cstdio>

using namespace std;

int A=0,B=0;

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