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 a, b[100] = { 0 }, c[100] = { 0 },d=0,e=0;
	cin >> a;
	for (int i = 0; i < a;i++){
		cin >> b[i] >> c[i];
	}
	for (int i = 0; i < a; i++){
		if (b[i]>c[i]){
			d = d + b[i] + c[i];
		}
		else if (b[i] < c[i]){
			e = e + b[i] + c[i];
		}
		else if (b[i] == c[i]){
			d = d + b[i];
			e = e + c[i];
		}
	}
	cout << d << " " << e;
	return 0;
}

C++: #include <bits/stdc++.h>

#define int long long int
#define main signed main()
#define bye return 0
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define each(p, v) for (auto p = (v).begin(); p != (v).end(); p++)
#define all(v) (v).begin(), (v).end()
#define prec(n) fixed << setprecision(n)
#define dump(x) cerr << "(L" << __LINE__ << ") " << #x << " = " << (x) << endl
#define clr(x, a) memset(x, a, sizeof(x))

#define sum(v) accumulate(all(v), 0)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define odd(n) ((n) % 2)
#define even(n) (!odd(n))

#define INF 1000000000
#define MOD 1000000007

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define vi vector<int>
#define vb vector<bool>
#define vc vector<char>
     
using namespace std;

main {
  int n;
  for(;;) {
    cin>>n;
    if(n==0)break;
    int a=0,b=0;
    rep(i,n) {
      int c,d;
      cin>>c>>d;
      if (c>d) a+=c+d; else if (c<d) b+=c+d; else {a+=c; b+=d;}
     }
    cout<<a<<' '<<b<<endl;
  }
  bye;
}

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

int main() {
	int num = 0;
	int a[10000] = { 0 };
	int	b[10000] = { 0 };
	cin >> num;
	while (num != 0) {
		int ap = 0;
		int	bp = 0;
		for (int i = 0; i < num; i++) {
			cin >> a[i] >> b[i];
			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;
		cin >> num;
	}
}

C++: #include<iostream>
int main() {
	int n;
	while (std::cin >> n, n) {
		int asum = 0, bsum = 0, a, b;
		for (int i = 0; i < n; i++) {
			std::cin >> a >> b;
			if (a > b)
				asum += a + b;
			else if(a < b)
				bsum += a + b;
			else {
				asum += a;
				bsum += b;
			}
		}
		std::cout << asum << " " << bsum << std::endl;
	}
	return 0;
}

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

int main(){
	int n;
	int a[10001] , b[10001];
	int scoreA=0 , scoreB=0;
	int i;
	while(1){
		cin>>n;
		if(n==0) break;
		for(i=0 ; i<n ; i++){
			cin >> a[i] >> b[i];
			if(a[i]>b[i]){
				scoreA+=a[i]+b[i];
			} else if (a[i]<b[i]){
				scoreB+=a[i]+b[i];
			} else {
				scoreA+=a[i];
				scoreB+=b[i];
			}
		}
		cout << scoreA << " " << scoreB << endl;
		scoreA=scoreB=0;
	}
	return 0;
}

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


//
int main(void){
	//FILE* fp_in = freopen("data.txt", "r", stdin);

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

	}

	//while(1){}
	return 0;
}

C++: #include<cstdio>
#include<iostream>
int main(){
    int n;
    while(1){
        int a,b,suma=0,sumb=0;
        scanf("%d",&n);
        if(n==0)
            break;
        for(int i=0;i<n;i++){
            scanf("%d%d",&a,&b);
            if(a>b)
                suma+=a+b;
            else if(a<b)
                sumb+=a+b;
            else
                suma+=a,sumb+=b;
        }
        printf("%d %d\n",suma,sumb);
    }
exit:
    return 0;
}

C++: #include<stdio.h>

int main(void){
	int a_point,b_point,i,a_card,b_card,n;
	while(0==0){
		scanf("%d",&n);
		if(n==0) break;
		a_point=0;
		b_point=0;
		for(i=0;i<n;i++){
			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 main(void){
  int a,b;
  int n;
  while(cin>>n,n){

    a = b = 0;
  while(n--){
    int c,d;
    cin>>c>>d;
    if(c==d){
      a += c + d;
      b += c + d;
    }else if(c>d)
      a += c + d;
    else
      b += c + d; 
  }
  cout<< a << " " << b << endl;
  }
}

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

int main() {

  while( true ) {

  long long int n;
  cin >> n;
  if ( n == 0 ) break;

  long long int a = 0, b = 0;
  for ( long long int i = 0; i < n; i++ ) {

    long long int in_a, in_b;
    cin >> in_a >> in_b;

    if ( in_a > in_b ) {
      a += in_a + in_b;
    }else if ( in_a < in_b ) {
      b += in_a + in_b;
    }else {
      a += in_a;
      b += in_b;
    }

  }

  cout << a << " " << b << endl;

  }

  return 0;

}

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


int main()
{
    int n, c1, c2;
    int p1, p2;
    while(std::cin >> n){
        if(n == 0){
            break; 
        }
        p1 = 0;
        p2 = 0;

        for(int i = 0; i < n; ++i){
            std::cin >> c1 >> c2;
            if(c1 == c2){
                p1 += c1;
                p2 += c2;
            }
            else if(c1 > c2){
                p1 += c1 + c2; 
            }
            else {
                p2 += c1 + c2;
            }
        } 
        std::cout << p1 << " " << p2 << std::endl;
    }
}

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

int main() {

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

    cout << A << " " << B << endl;
  }
}

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

using namespace std;

int main(void){

	int n,a,b,as,bs;

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

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

}

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

int main() {
	int score_a[] = { 0, 0, 0, 0, 0 };
	int score_b[] = { 0, 0, 0, 0, 0 };
	int cnt = 0;
	bool flg = true;
	
	while (flg) {
		int num;

		cin >> num;
		if ((cnt >= 5) || (num == 0)) {
			flg = false;
		}
		else {
			for (int i = 0; i < num; i++) {
				int a;
				int b;

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

	//while (1);

	return 0;
}