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++: /*
 * 500.cpp
 *
 *  Created on: 2012/06/24
 *      Author: shimomire
 */
#include <iostream>
#include<string>
#include <complex>
#include<list>
#include<float.h>
#include <functional>
#include <vector>
#include <map>
#include <queue>

using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define REP0(i,n)   REP(i,0,n)
#define foreach(it,o) for(__typeof((o).begin()) it=(o).begin(); it!=(o).end(); ++it)
typedef complex<double> P;
bool operator <(const P& a, const P& b) {
	return abs(a) < abs(b);
}
int n;

int main(){
	while(true){
		cin >> n;
		if(n==0){
			break;
		}
		int ap=0,bp=0;
		REP0(i,n){
			int tmpa,tmpb;
			cin>> tmpa>> tmpb;
			if(tmpa>tmpb){
				ap+=tmpa+tmpb;
			}else if(tmpa< tmpb){
				bp+=tmpa+tmpb;
			}else{
				ap+=tmpa;
				bp+=tmpb;
			}
		}
		cout<< ap<< " "<< bp<< endl;
	}
}

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

int main(){
	int n,a,b;
	long suma=0,sumb=0;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a >> b;
		if(a>b) suma+=a+b;
		else sumb+=a+b;
	}
	cout << suma << " " <<  sumb << endl;
}

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

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

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

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

int main(){
  int n, a[10000], b[10000], asum = 0, bsum = 0;
  while(scanf("%d\n", &n)){
    if(n == 0) return 0;

    for(int i = 0;i < n;i++) scanf("%d %d\n", &a[i], &b[i]);
    for(int i = 0;i < n;i++){
      if(a[i] > b[i]) asum += a[i]+b[i];
      else if(a[i] < b[i]) bsum += a[i]+b[i];
      else {
         asum += a[i];
         bsum += b[i];
      }
   }
   printf("%d %d\n", asum, bsum);
  }
}

C++: #include <stdio.h>
#include <math.h>
#include <ctype.h>

int main(void)
{
  int i,j,k,l;
  int n,m;
  int a,b;
  int cnt_a,cnt_b;
  while(1) {
	scanf("%d",&n);
	if(n == 0) break;
	cnt_a = cnt_b = 0;
	for(i=0;i<n;i++) {
	  scanf("%d %d",&a,&b);
	  if(a > b) cnt_a += a+b;
	  else if(b > a) cnt_b = a+b;
	  else cnt_a += a ,cnt_b += b;
	}
	printf("%d %d\n",cnt_a,cnt_b);
  }
	
  return 0;
}

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

int main(void) {
	int i, n, a, b, as = 0, bs = 0;
	for(cin >> n ; n != 0 ; as = bs = 0, cin >> n) {
		for(i=0 ; i<n ; i++) {
			cin >> a >> b;
			if(a > b)		{ as += a+b; }
			else if(a < b)	{ bs += a+b; }
			else 			{ as += a; bs += b; }
		}
		cout << as << " " << bs << endl;
	}
	return 0;
}

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

struct player{
    int point;
    int card[10000];
    inline player(){point = 0;}
};

int main()
{
    int loop = 1;
    player a, b;
    while(loop) {
        cin >> loop;
        for(int c = 0; c < loop; c++)
        {
            cin >> a.card[c];
            cin >> b.card[c];
        }

        for(int c = 0; c < loop; c++)
        {
            if(a.card[c] < b.card[c])
            {
                b.point += a.card[c] + b.card[c];
                continue;
            }
            if(a.card[c] == b.card[c])
            {
                 a.point += a.card[c];
                 b.point +=b.card[c];
                 continue;
            }
            a.point += a.card[c] + b.card[c];
        }
        
    }
    cout << a.point << " " << b.point << endl;
    return EXIT_SUCCESS;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = (n)-1; i >= 0; i--)
#define FOR(i, l, r) for(int i = l; i < r; i++)
#define RFOR(i, l,r) for(int i= (l)-1; i>= (r) ; i--)

#define int64 int64_t
#define uint64 uint64_t
#define uint unsigned

short a[10000], b[10000];
int n;

int main()
{
    while(cin >> n){
        if(n <= 0) break;

        REP(i, n)
            cin >> a[i] >> b[i];
        uint ap = 0;
        uint bp = 0;

        REP(i, n){
            if(a[i] > b[i])
                ap += a[i] + b[i];
            else if(a[i] < b[i])
                bp += a[i] + b[i];
            else{
                ap += a[i];
                bp += b[i];
            }
        }
        cout << ap << ' ' << bp << endl;
    }
}

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

using namespace std;

int main() {
	int p1[10000], p2[10000], n, point1 = 0, point2 = 0, i;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> p1[i] >> p2[i];
	}
	for (i = 0; i < n; i++) {
		if (p1[i] == p2[i]) {
			point1 += p1[i];
			point2 += p2[i];
		}
		else if (p1[i] > p2[i]) {
			point1 += p1[i] + p2[i];
		}
		else {
			point2 += p1[i] + p2[i];
		}
	}
	cout << point1 << ' ' << point2 << endl;
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
int n;
int a[10000],b[10000];
while(cin>>n){
a[10000]={};
b[10000]={};
int ap=0,bp=0;
	for(int i=0;i<n;i++){
		cin>>a[n]>>b[n];
		sum=a[n]+b[n];
		if(a[n]>b[n]){
			ap+=sum;
		}else if(a[n]<b[n]){
			bp+=sum;
		}else{
			ap+=a[n];
			bp+=b[n];
		}
	}
	cout<<ap<<" "<<bp<<endl;
}

return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int n;
	while(cin >> n,n){
		int a,b,ar = 0,br = 0;
		while(n--){
			cin >> a >> b;
			ar += a>b?a+b:0;
			br += b>a?a+b:0;
		}
		cout << ar << " " << br << endl;
	}
}

C++: #include <stdio.h>

int main(void)
{

	int n;
	int a=0,b=0;
	int ac,bc;

	while(1){
	scanf("%d", &n);
if(n == 0)
break;
	for(int i = 0; i < n; i++){
		
		scanf("%d %d", &ac,&bc);
		if(ac > bc)
			a += (ac + bc);
		else if(ac < bc)
			b += (ac + bc);
		else {
			a += ac;
			b += bc;
		}
	}
	printf("%d %d\n", a,b);

	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
	int n;
	int a,b;
	int sa=0,sb=0;//score
	
	
	while(cin>>n&&n!=0){
	for(int i=0;i<n;i++)
	{
		cin>>a>>b;
		if(a<b){sb+=(a+b);}
		else if(a>b){sa+=(a+b);}
		else
		{
			sa+=a;
			sb+=b;
		}
	}
	cout<<sa<<" "<<sb<<"\n";
	}
	return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  long long n,a,b,x=0,y=0;
  cin>>n;
  rep(i,n){
    cin>>a>>b;
    if(a==b){
      x+=a;
      y+=b;
    }
    else if(a==max(a,b))x+=a+b;
    else if(b==max(a,b))y+=a+b;
  }
  cout<<x<<" "<<y<<endl;
}

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