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;
 
int main() {
    int n,a,b,countA,countB;
    do{
        countA=0,countB=0;
        cin>>n;
        if(n==0)break;
        for(int i=0;i<n;i++){
            cin>>a>>b;
            if(a>b){
                countA+=(a+b);
            }else if(a<b){
                countB+=(a+b);
            }//a==b
        }
        cout<<countA<<" "<<countB<<"\n";
    }while(1);
}

C++: #include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <queue>
#include <algorithm>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const double pi=acos(-1);

int n,A=0,B=0;

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

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

typedef long long ll;

using namespace std;

int main(void){
	int pa, pb, n;

	while(cin >> n){
		pa = pb = 0;
		if(!n) break;
		for(int i=0; i<n; ++i){
			int c1, c2;
			cin >> c1 >> c2;
			if(c1 > c2){
				pa += c1 + c2;
			}else if(c1 < c2){
				pb += c1 + c2;
			} else {
				pa += c1, pb += c1;
			}
		}

		cout << pa << " " << pb << endl;
	}

	return 0;
}

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

int main(){
	for (;;){
		int n;
		cin >> n;
		if (n == 0) return 0;

		int p0=0, p1=0;

		for (int i = 0; i < n; ++i){
			int a, b;
			cin >> a >> b;
			if (a>b) p0 += a + b;
			if (a == b){}
			if (a<b) p1 += a + b;
		}
		cout << p0 << ' ' << p1 << endl;
	}
}

C++: #include<stdio.h>

int main(void){
	int a_point,b_point,i,a_card,b_card,n;
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		a_point=0,b_point=0;
		for(i=0;i<n;n++){
			scanf("%d %d",&a_card,&b_card);
			if(a_card>b_card) a_point+=a_card+b_card;
			else if(a_card<b_card) b_point+=a_card+b_card;
			else {
				a_point+=a_card;
				b_point+=b_card;
			}
		}
		printf("%d %d\n",a_point,b_point);
	}
	return 0;
}

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

int a,b,n,ta,tb;

int main(){
	while(true){
		a=0; b=0;
		cin >> n;
		if(!n)
			return 0;
		for(int i=0; i<n; i++){
			cin >> ta >> tb;
			if(ta>tb)
				a+=ta+tb;
			else if(ta==tb){
				a+=ta;
				b+=tb;
			}else
				b+=ta+tb;
		}
		cout << a << ' ' << b << endl;
	}
}

C++: #include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
	long long int a,b,n,x,y;
	a=0;
	b=0;
	scanf("%lld",&n);
	for(long long int i=0;i<n;i++){
		scanf("%lld %lld",&x,&y);
		if(x>y) {a+=(x+y);}
		if(x<y) {b+=(x+y);}
		if(x==y){
			a+=x;
			b+=y;
		}
	}
	if(n!=0) printf("%lld %lld\n",a,b);
	return 0;
}

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

class game{
	int length;
	int cur;
	int *r,*l;
	int r_score,l_score;
public:
	game(int _l){
		length = _l;
		r = new int [length];
		l = new int [length];
		r_score = 0;
		l_score = 0;
		cur = 0;
	}
	~game(){
		delete [] r;
		delete [] l;
	}
	void run();
	void insert(int,int);
};

void game::run(){
	for(int i = 0;i < length;i++){
		if(r[i] < l[i]){
			l_score += r[i] + l[i];
		}else if(r[i] > l[i]){
			r_score += r[i] + l[i];
		}else{
			l_score += l[i];
			r_score += r[i];
		}
	}
	cout<<l_score<<" "<<r_score<<endl;
}

void game::insert(int l_card,int r_card){
	r[cur] = r_card;
	l[cur] = l_card;
	cur++;
}

int main(){
	list<game*> lst;
	while(1){
		int read;
		cin>>read;
		if(read == 0){
			break;
		}
		game *g = new game(read);
		for(int i = 0; i < read;i++){
			int r_card,l_card;
			cin>>l_card>>r_card;
			//cout<<l_card<<","<<r_card<<endl;
			g->insert(l_card,r_card);
		}
		lst.push_back(g);
	}

	for(auto it = lst.begin();it != lst.end();it++){
		(*it)->run();
		delete (*it);
	}
	return 0;
}

C++: #include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
int main(void){
int n,a,b,a1,b1;
while(1){
scanf("%d",&n);
a1=0;
b1=0
if(n==0){break;}
for(int i=0;i<n;i++){
scanf("%d%d",&a,&b);
if(a>b){
a1=a+b;
}else if(b>a){
b1=a+b;
}else{
a1+=a;
b1+=b;
}
}
printf("%d %d\n",a1,b1);
}
return 0;
}

C++: #include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
  int a,b,n;
  int ai,bi;
  while(cin>>n,n){
	  a=b=0;
	  for(int i=0;i<3;i++)
	  {
		  cin>>ai>>bi;
		  if(ai>bi) a+=ai+bi;
		  else if(bi>ai) b+=ai+bi;
		  else{
			  a+=ai;
			  b+=bi;
		  }
	  }
	  cout<<a<<' '<<b<<endl;
  }
    return 0;
}

C++: 
#include <cstdio>

using namespace std;

#define FOR( i, n ) for( int i = 0; i < n; ++i )

int main( void )
{

	while( 1 )
	{

		int point_a = 0;
		int point_b = 0;

		int n;
		scanf( "%d", &n );

		if( n == 0 )
			break;

		FOR( i, n )
		{
			int a, b;
			scanf( "%d %d", &a, &b );

			if( a > b )
			{
				// AÌ¿
				point_a += a+b;
			}
			else
			{
				if( a == b )
				{
					// ø«ª¯
					point_a += a;
					point_b += b;
				}
				else
				{
					// BÌ¿
					point_b += a+b;
				}
			}

		}

		// Ê
		printf( "%d %d\n", point_a, point_b );

	}

	return 0;
}

C++: #include <cstdio>
int main(){
 long asum,bsum,a,b,n,i;
 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\n",asum,bsum);
 return 0;
};

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"
int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		int as = 0, bs = 0;
		for (int i = 0; i < N; ++i) {
			int a, b; cin >> a >> b;
			if (a > b) {
				as += a + b;

			}
			else if (b > a) {
				bs += a + b;
			}
			else {
				as += a;
				bs += b;
			}

		}
		cout << as << " " << bs << endl;
	}
	
	return 0;
}