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<stdio.h>
int main()
{
	int a = 0, b = 0, x, y, n, i;
	for (;;){
		scanf("%d", &n);
		if (n == 0)
			break;
		for (i = 0; i < n; i++){
			scanf("%d %d", &x, &y);
			if (x > y){
				a += x + y;
			}
			else if (x == y){
				a += x;
				b += y;
			}
			else
				b += x + y;
		}
		printf("%d %d\n", a, b);
		a = 0;
		b = 0;
	}
	return 0;
}

C++: #include <stdio.h>
int main(){
  for(;;){
    int n,i,j,k;
    int A={0},B={0};
    scanf("%d",&n);
    if(n==0){
      return 0;
    }
      for(i=0;i<n;i++){
      scanf(" %d %d",&j,&k);
      if(j>k){
        A+=(j+k);
      } else if(j<k){
        B+=(j+k);
      } else if(j==k){
        A+=j;
        B+=k;
      }
    }
    printf("%d %d\n",A,B);
  }
}

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];
            else if(v[i] < v2[i])
                    ans2 += v[i]+v2[i];
            else{
                ans1+=v[i]; ans2= v2[i];}
        }
        cout << ans1 << " " << ans2 << endl;
    }
}

C++: #include<iostream>

int main(){

	int n;

	int a=0, b=0;

	int x, y;

	f:

	std::cin >> n;

	if (n == 0)
		goto flag;

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

	goto f;

flag:

	std::cout << a <<' '<< b << std::endl;

	return 0;

}

C++: #include <cstdio>

using namespace std;

int main(){

  while(1){

  int n,a=0,b=0;

  scanf("%d",&n);

  if(n == 0) break;

  for(int i = 0;i < n;i++){
    int t1,t2;

    scanf("%d%d",&t1,&t2);

    if(t1 > t2){
      a += (t1+t2);
    }else if(t1 < t2){
      b += (t1+t2);
    }else{
      a += t1;
      b += t2;
    }
  }

  printf("%d %d\n",a,b);

  }

  return 0;

}

C++: #include<iostream>
using namespace std;
int main(){
	while (1){
		int n, a[1000] = {0}, b[1000] = {0}, A = 0, B = 0;
		cin >> n;
		if (n == 0){ break; }
		for (int i = 0; i < n; i++){
			cin >> a[i] >> b[i];
			if (a[i] > b[i]){
				A = A + a[i] + b[i];
			}
			else if (a[i] < b[i]){
				B = B + a[i] + b[i];
			}
			else if(a[i]==b[i]){
				A = A + a[i];
				B = B + b[i];
			}
		}
		cout << A << " " << B << endl;
	}
	return 0;
}

C++: #include<iostream>
int A,B;
int main(void)
{
using namespace std;
int n,C,D;
while(1)
{
cin>>n;
if(!n)break;
A=0;
B=0;
for(;n>0;n--){
cin>>C;
cin>>D;
if(C>D){
A+=(C+D);
}else if(C<D){
B+=(C+D);
}else{
A+=C;
B+=D;
}
}
cout<<A<<" "<<B<<endl;
}
return 0;
}

C++: #include <iostream>

using namespace std;

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

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

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

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

C++: #include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  int c1,c2,p1 = 0,p2 = 0;
  while(scanf("%d",&n)){
    if(n == 0)break;
    while(n--){
      scanf("%d %d",&c1,&c2);
      if(c1 > c2)p1 += c1+c2;
      else if(c1 < c2)p2 += c1+c2;
      else{
	p1 += c1;
	p2 += c2;
      }
    }
  }
  printf("%d %d\n",p1,p2);
}

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

int main(void)
{
    int i;
    int num, x, y;
    int p1 = 0;
    int p2 = 0;

    for (;;) {
        scanf("%d", &num);
        if (num == 0) {
            break;
        }

        for (i = 0; i < num; i++) {
            scanf("%d %d", &x, &y);
            if (x > y) {
                p1 += (x+y);
            }
            else if (x < y) {
                p2 += (x+y);
            }
            else {
                p1 += x;
                p2 += y;
            }
        }
        printf("%d %d\n", p1, p2);
        p1 = p2 = 0;
    }

    return 0;
}

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

int main(){
	int n,a,b,Ares=0,Bres=0;
	while(1){
	cin>>n;
	if(n==0)
		break;
	for(int i=0;i<n;i++){
		cin>>a>>b;
		if(a==b){
			Ares+=a+b;
			Bres+=a+b;
		}else if(a<b){
			Bres+=a+b;
		}else if(a>b){
			Ares+=a+b;
		}
	}
	cout<<Ares<<" "<<Bres<<endl;
	Ares=0;
	Bres=0;
	}
}

C++: //30
#include<iostream>

using namespace std;

int main(){
  for(int n;cin>>n,n;){
    int a=0,b=0;
    for(int i=0;i<n;i++){
      int ta,tb;
      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;
  }
  return 0;
}

C++: #include<stdio.h>

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

C++: #include<cstdio>
#include<iostream>
using namespace std;
int q[6][3];
int main()
{
	int i,j,n,s,m,a,b,p=1;
	while(cin>>s)
	{
		a=0;b=0;
		if(s==0)break;
	for(i=1;i<=s;i++)
	{
		cin>>n>>m;
		if(n>m)a=a+n+m;
		else if(n<m)b=b+n+m;
		else
		{
			a=a+n;
			b=b+m;
		}
	}
	q[p][1]=a;
	q[p][2]=b;
	p++;
    }
    for(i=1;i<p;i++)cout<<q[i][1]<<" "<<q[i][2]<<endl;
	return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<string>
#include<functional>
#include<queue>
#include<stack>
#include<math.h>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	int n;
	while (cin >> n) {

		int a, b;
		int ascore = 0, bscore = 0;
		vector<P>card;
		for (int i = 0; i < n; i++) {
			cin >> a >> b;
			if (a > b)ascore += a + b;
			else if (b < a)bscore += a + b;
			else {
				ascore += a;
				bscore += b;
			}
		}
		cout << ascore << " " << bscore << endl;
	}


	return 0;
}