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>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PA;
using namespace std;
#define MAX 1e7
int main(){
    int n;
    while(cin >> n,n){
        vi v(n+1,0);
        vi v2(n+1,0);
        int ans1 = 0; int ans2 =0;
        rep(i,n){
            cin >> v[i] >> v2[i];
            if(v[i]>v2[i])
                ans1+=v[i]+v2[i];
             if(v[i] < v2[i])
                ans2 += v[i]+v2[i];
             if(v[i] == v2[i]){
                ans1+=v[i]; ans2= v2[i];}
        }
        cout << ans1 << " " << ans2 << endl;
    }
}

C++: #include<iostream>
using namespace std;
int main(void){
  int n;
  cin>>n;
  int sumA=0,sumB=0,a,b;
  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;
  return 0;
}

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

int main() {
	int num;
	int score_a = 0;
	int score_b = 0;
	int cnt = 0;
	
	cin >> num;
	while (num != 0) {
		for (int i = 0; i < num; i++) {
			int a;
			int b;

			cin >> a >> b;
			if (a > b) {
				score_a += a + b;
			}else if (b > a) {
				score_b += a + b;
			}else {
				score_a += a;
				score_b += b;
			}
		}
		cout << score_a << " " << score_b << endl;
		score_a = 0;
		score_b = 0;
		cnt++;
	}

	cnt = 0;
	return 0;
}

C++: #include <stdio.h>

int main(void) {
	int n, i, po[2] = {0}, ca[2];
	
	while(scanf("%d", &n)){
		if(!n)break;
	po[0] = 0;
	po[1] = 0;
	for(i = 0; n > i; i++){
		scanf("%d%d", &ca[0], &ca[1]);
		if(ca[0] > ca[1]) po[0] += ca[0]+ca[1];
		else if(ca[0] < ca[1]) po[1] += ca[0]+ca[1];
		else{ po[0] += ca[0]; po[1] += ca[1];}
	}
	printf("%d %d\n",po[0],po[1]);
	}
	return 0;
}

C++: #include<stdio.h>
int main()
{
	int n,a,b,x,y;
	while(scanf("%d",&n),n)
	{
		for(a=b=0;n--;)scanf("%d%d",&x,&y),x==y?a+=x,b+=y:((x>y?a:b)+=x+y);
		printf("%d %d\n",a,b);
	}
	return 0;
}

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

int main(){
	int z;
	int a=0;
	int b=0;
	std::cin>>z;
	std::vector<int> vec1(z);
	std::vector<int> vec2(z);
	for(int i=0;i<z;i++){
		std::cin>>vec1[i];
		std::cin>>vec2[i];
	}
	for(int i=0;i<z;i++){
		if(vec1[i]>vec2[i])a=a+vec1[i]+vec2[i];
		if(vec2[i]>vec1[i])b=b+vec1[i]+vec2[i];
		if(vec1[i]==vec2[i]){
			a=a+vec1[i];
			b=b+vec2[i];
		}
	}
	std::cout<<a<<" "<<b<<std::endl;
	return 0;
}

C++: #include<cstdio>
int main(){
    int a,b,n;
    while(scanf("%d",&n)!=EOF){
        int asum=0,bsum=0;
        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 <iostream>

using namespace std;

int main(){
	int n,a,b;
	while(cin >> n,n){
		int ta=0,tb=0;
		while(n--){
			cin >> a >> b;
			if(a>b)ta+=(a+b);
			else if(b>a)tb+=(a+b);
			else{
				ta+=a;tb+=b;
			}
		}
		cout << ta <<" "<< tb << endl;
	}
	return 0;
}

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

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

int main()
{
	int a;
	int r, l;
	int rsum, lsum;
	rsum = 0;
	lsum = 0;
	do{
		cin >> a;
		for (int i = a; i > 0; i--){

			cin >> r;
			cin >> l;
			if (r > l){
				rsum += r + l;
			}
			else if (l > r){
				lsum += r + l;
			}
			else{
				rsum += r;
				lsum += l;
			}
		}
		cout << r << ' ' << l << endl;
	} while (a != 0);
}

C++: 
#include <cstdio>

using namespace std;

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

int main( void )
{
	int point_a = 0;
	int point_b = 0;

	while( 1 )
	{

	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 <iostream>

using namespace std;

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

C++: #include<iostream>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,a=0,b=0,da,db;
  while(1){
  cin>>n;
  if(n==0) break;
  for(int i=0;i<n;i++){
    cin>>da>>db;
    if(da>db) a+=da+db;
    if(da<db) b+=db+da;
    if(da==db){
      a+=da;
      b+=db;
    }
  }
  cout<<a<<" "<<b<<endl;
  a=0;
  b=0;
  }
  return 0;
}

C++: #include<cstdio>
int main(){
    int ai,bi,as=0,bs=0,n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d%d",ai,bi);
        if(ai>bi) as+=ai+bi;
        else if(ai<bi) bs+=ai+bi;
        else{
            as+=ai;
            bs+=bi;
        }
    }
    printf("%d %d\n",as,bs);
}

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

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

C++: #include <iostream>
using namespace std;
 
int main() {
    int n;
    cin >> n;
    int num[10000][2] = {};
    int score[2] = {};

    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < 2; ++j){
            cin >> num[i][j];
        }
        if (num[i][0] > num[i][1])
        {
            score[0] += num[i][0] + num[i][1];
        } else if (num[i][0] == num[i][1])
        {
            score[0] += num[i][0];
            score[1] += num[i][1];
        } else{
            score[1] += num[i][0] + num[i][1];
        }
    }

    cout << score[0] << " " << score[1] << endl;

    return 0;
}

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

using namespace std;

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