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 aten = 0,bten = 0,a,b;
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a >> b;
		if(a > b){
			aten = aten + a + b;
		}
		else if(a == b){
			aten = aten + a;
			bten = bten + b;
		}
		else{
			bten = bten + a + b;
		}


	}
	cout << aten << " " << bten << endl;
	return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;
#define pi 3.141592653589793283462
int main(){
	int n;
	int ca=0;
	int cb=0;
	int ia,ib;
	while(1){
		cin>>n;
		if(n==0)
			break;
		for(int i=0;i<n;i++){
		cin>>ia>>ib;
		if(ia>ib)
			ca+=(ia+ib);
		else if(ia<ib)
			cb+=(ia+ib);
		else{
			ca+=ia;
			cb+=ib;
		}
	}
		cout<<ca<<" "<<cb<<endl;
   }
	return 0;
}

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

C++: #include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<string>
using namespace std;


int main() {

	int n;
	int a, b;
	int ascore = 0, bscore = 0;
	for (;;) {
		cin >> n;
		if (n == 0) break;

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

			if (a > b) ascore += (a + b);
			else if (a < b)bscore += (a + b);
			else {
				ascore += a;
				bscore += b;
			}



		}

		printf("%d %d\n", ascore, bscore);
		ascore = 0;
		bscore = 0;
	}

	//system("pause");
	return 0;
}

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

int main(){

	int n, x, y, pt1, pt2;

	while(cin >> n){
		pt1 = 0;
		pt2 = 0;
	
		if(n == 0) break;
		
		for(int i=0; i<n; i++){
			cin >> x >> y;
			
			if(x > y) pt1 += x + y;
			else if(x < y) pt2 += x + y;
			else {
				pt1 += x;
				pt2 += y;
			}
		}
		
		cout << pt1 << " " << pt2 << endl;
	}

	return 0;

}

C++: #include<iostream>

using namespace std;
#define MAX_N 10000

int N;//カードの枚数
int A[MAX_N],B[MAX_N];
int PA[MAX_N],PB[MAX_N];
int Cou = 0;//何回目の勝負か記憶しておく

int main(){
  while(true){
  scanf("%d",&N);//配られるカードの枚数
  if(N==0)
    break;
  for(int i = 0;i < N;i++){
    scanf("%d %d",&A[i],&B[i]);
    if(A[i] > B[i])
      PA[Cou] += A[i]+B[i];
    else if(A[i] < B[i])
      PB[Cou] += A[i]+B[i];
  }
  Cou++;
  }
  for(int j = 0;j < Cou;j++){
      printf("%d %d\n",PA[j],PB[j]);
  }
  return 0;
 
}

C++: #include <cstdio>
int main(){
	int a, b, c;
	scanf("%d", a);
	int n_a[a];
	int n_b[a];
	for(int i=0; i<a; i++){
		scanf("%d %d", n_a[i], n_b[i]);
	}
	for(int i=0; i<a; i++){
		if(n_a[i] > n_b[i]){
			b += n_a[i]+n_b[i];
		}else if(n_a[i] < n_b[i]){
			c += n_a[i]+n_b[i];
		}else if(n_a[i] == n_b[i]){
			b += n_a[i];
			c += n_b[i];
		}
	}
	printf("%d %d", b, c);
	return 0;
}

C++: #include <stdio.h>

int main () {
    int a, b, n, scorea, scoreb;
    while (1) {
        scanf("%d", &n);
        if (n == 0) break;
        while (n--) {
            scanf("%d %d", &a, &b);
            if (a == b) {
                scorea += a;
                scoreb += b;
            }
            else if (a > b) {
                scorea += a + b;
            } else {
                scoreb += a + b;
            }
        }
        printf("%d %d\n", scorea, scoreb);
    }

    return 0;
}

C++: #include<iostream>

using namespace std ;

int main()
{
	int n ;
	while( cin >> n , n )
	{
		int a ,b ;
		int acnt = 0 , bcnt = 0 ;
		while( n )
		{
			n-- ;
			cin >> a >> b ;
			if( a == b )
			{
				acnt += a ;
				bcnt += b ;
			}
			else
			{
				a > b ? acnt += a + b : bcnt += a + b ;
			}
		}
		cout << acnt << ' ' << bcnt << endl ;
	}
	return 0 ;
}

C++: #include <stdio.h>
#include<math.h>
using namespace std;



int main(){
	int A,B,a,b,n;

	while(true){
		scanf("%d",&n);
		if(n == 0)break;
		A = B = 0;
		for(int i=0;i < n; i++){
			scanf("%d %d",&a,&b);
			if(a > b){
				A += (a+b);
			}else if(a < b){
				B += (a+b);
			}else{
				A += a;
				B += b;
			}
		}

		printf("%d %d\n",A,B);
	}

    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
int n,a,b,pa,pb;
cin>>n;
for(;n!=0;){
pa=0;pb=0;
for(int i=0;i<n;i++){
cin>>a;
cin>>b;
if(a==b){pa+=a; pb+=a;}
if(a>b){pa+=a+b;}
if(a<b){pb+=a+b;}
}
cout<<pa<<" "<<pb<<endl;
}
return 0;
}

C++: 
    #include<iostream>
using namespace std;
int main(){
  int n, a, b;
  while(cin >> n, n){
      int as =0, bs =0;
      for(int 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++: // aoj-5000.cpp

#include <cstdio>

int main() {
	int i;
	int cards, a, b, scoreA = 0, scoreB = 0;

	// read number of cards
	scanf("%d", &cards);

	for (i=0; i<cards; ++i) {
		scanf("%d %d", &a, &b);
		if (a > b) {
			scoreA += (a + b);
		} else if (b > a) {
			scoreB += (a + b);
		} else {
			scoreA += a;
			scoreB += b;
		}
	}

	printf("%d %d", scoreA, scoreB);

	return 0;
}

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

int main() {
  int k;
  while(1) {
    cin >> k;
    if(k == 0) break;
    int a,b;
    int A = 0;
    int B = 0;
    for(int c = 0; c < k; ++c) {
      cin >> a >> b;
      if(a > b) {
        A += a + b;
      }else if(a == b) {
        A += a;
        B += b;
      }else if(a < b) {
        B += a + b;
      }
      cout << A << " " << B << endl;
    }
  }
}

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


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

	for(int n; 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;
	}

	return EXIT_SUCCESS;
}

C++: #include <stdio.h>

int n, A[11234], B[11234];
int ans[2];

int main(void) {
	while (true) {
		ans[0] = ans[1] = 0;
		scanf("%d", &n);
		if (n == 0) { break; }
		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]) { ans[0] += A[i] + B[i]; }
			else if (A[i] < B[i]) { ans[1] += A[i] + B[i]; }
			else { ans[0] += A[i], ans[1] += B[i]; }
		}

		printf("%d %d\n", ans[0], ans[1]);
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdio>
#include<string>
#include<cmath>
typedef long long int ll;
#define VI vector<int>

#define rep(i,a) for(int i=0;i<(a);i++)
#define all(i) i.begin(),i.end()
#define INF 1000000000


using namespace std;


/**/
VI y;
pair<int,int> x[31];


int main(){
	int n;
	int a,b;
	int suma=0,sumb=0;
	cin>>n;
	rep(i,n){
		cin>>a>>b;
		if(a>b){
			suma+=a+b;
		}else if(a<b){
			sumb+=a+b;
		}else if(a==b){
			suma+=a;
			sumb+=b;
		}

	}
	cout<<suma<<" "<<sumb<<endl;

	return 0;
}

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

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

	cin >> n;

	while (n != 0){

		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;

		ap = 0;
		bp = 0;

		cin >> n;

	}
}