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 n, cards[2][10000], score[2];
	while (cin >> n, n) {
		for (int i = 0; i < n; ++i)
			cin >> cards[0][i] >> cards[1][i];
		
		score[0] = 0, score[1] = 0;
		for (int i = 0; i < n; ++i)
			if (cards[0][i] > cards[1][i]) score[0] += cards[0][i] + cards[1][i];
			else if (cards[0][i] < cards[1][i]) score[1] += cards[0][i] + cards[1][i];
			else score[0] += cards[0][i], score[1] += cards[1][i];

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

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

#define loop(i,a,b) for(int i=a; i<b; i++)
#define rep(i,b)
 
int main(void){
    int n;
    while(cin >> n, n){
        int a = 0;
        int b = 0;    
        rep(i,n){
            int ta,tb;
            cin >> ta >> tb;
            int sum = ta + tb;
            if(ta > tb) a += sum;
            if(ta < tb) b += sum;
            if(ta == tb){
                a += ta; b += tb;
            }
        }
        cout << a << " " << b << endl;
    }
}

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

C++: #include <iostream>

using namespace std;

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

int main(void){
	int n;
	int a = 0, b = 0;
	while(true){
		cin >> n;
		if(c == 0) break;
		rep(i, n){
			int x, y;
			cin >> x >> y;
			if(x > y){
				a += x + y;
			}
			if(y > x){
				b += x + y;
			}
			if(y == x){
				a += x;
				b += y;
			}
		}
		cout << a << " " << b << endl;
	}
	return 0;
}

C++: #include <stdio.h>

void main() {
	int n, a, b;
	int suma = 0;
	int sumb = 0;
	bool endflg = false;
	while (1) {
		scanf_s("%d", &n);
		if (n == 0) {
			return 0;
		}
		int i;
		for (i = n; i > 0; i--) {
			scanf_s("%d %d", &a, &b);
			if (a > b) {
				suma = suma + a + b;
			}
			else if (b > a) {
				sumb = sumb + a + b;
			}
			else {
				suma = suma + a;
				sumb = sumb + b;
			}
		}
		printf("%d %d\n", suma, sumb);
		suma = 0;
		sumb = 0;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

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

int main(void){
	int n;
	int a = 0, b = 0;
	while(true){
		cin >> n;
		if(n == 0) break;
		rep(i, n){
			int x, y;
			cin >> x >> y;
			if(x > y){
				a += x + y;
			}
			if(y > x){
				b += x + y;
			}
			if(y == x){
				a += x;
				b += y;
			}
		}
		cout << a << " " << b << endl;
	}
	return 0;
}

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

int main(){
	int count;
	int aSum, bSum;
	int aCard, bCard;

	while(1){
		aSum = bSum = 0;
		cin >> count;
		if(!count) break;

		for(int i=0; i < count; i++){
			cin >> aCard >> bCard;
			if(aCard > bCard) aSum += aCard + bCard;
			else if(aCard < bCard) bSum += aCard + bCard;
			else {
				aSum += aCard;
				bSum += bCard;
			}
		}
		cout << aSum << " " << bCard << endl;
	}
}

C++: #include<string>
#include<vector>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<sstream>
#include<functional>
#include<map>
#include<stack>
#include<set>
#include<cmath>

#define REP(i,s,e) for(int i=int(s);i<int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)

#define EPS 1e-6

using namespace std;

int main(){

	int n,a,b;

	cin >> n;

	int p=0; int q=0;
	rep(i,n){

	cin >> a >> b;

	if(a>b) p+=a+b;
	else if(a<b) q+=a+b;
	else{ p+=a; q+=b; }

	}

	cout << p << " " << q << endl;

    return 0;

}

C++: #include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n,a[10000],b[10000],countA=0,countB=0;
    while(cin>>n,n!=0){
        for(int i=0;i<n;i++){
            cin>>a[i]>>b[i];
            if(a>b){
                countA+=(a[i]+b[i]);
            }else if(a<b){
                countB+=(a[i]+b[i]);
            }else{
                countA+=a[i];
                countB+=b[i];
            }
        }
        cout<<countA<<" "<<countB<<endl;
    }
    return(0);
}

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

int main () {
    int n, i,A,B, resa =0, resb =0;
    while(cin >> n,n){
        for(i=0;i<n;i++){
            cin >> A >> B;
            (A > B)? resa +=A:resb+=B;
            if(A==B) {resa += A; resb +=B;};
        }
　　　　cout << resa << " " << resb << endl;
    }
}

C++: #include <iostream>

using namespace std;

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

    int ans1=0, ans2=0;
    for(int i=0;i<n;i++){
      int a, b;
      cin >> a >> b;
      if(a>b){
	ans1+=a+b;
      }else if(a<b){
	ans2+=a+b;
      }else{
	ans1+=a;
	ans2+=b;
      }
    }
    printf("%d %d\n", ans1, ans2);
  }
  return 0;
}

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

int main() {
  int n;

  while (true) {
    cin >> n;
    int score_a = 0;
    int score_b = 0;

    if (n == 0) break;

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

      if (a == b) {
        score_a += a;
        score_b += b;
      } else if (a > b) {
        score_a += a + b;
      } else {
        score_b += a + b;
      }
    }

    cout << score_a << " " << score_b << endl;
  }
  
  return 0;
}

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

C++: // http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0500
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    while (true) {
        int N;
        cin >> N;
        if (N == 0) {
            break;
        }
        int sumA = 0, sumB = 0;
        while (N--) {
            int a, b;
            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;

struct Game {
    int a = 0, b = 0;
    Game() {}

    void score(int card_a, int card_b) {
        if (card_a > card_b)
            a += card_a + card_b;
        else if (card_a < card_b)
            b += card_a + card_b;
        else {
            a += card_a;
            b += card_b;
        }
    }
    void board() {
        cout << a << " " << b << endl;
    }
};

int main()
{
    for (int n; cin >> n && n;) {
        Game game;
        for (int a, b; n-- && cin >> a >> b;)
            game.score(a, b);
        game.board();
    }

    return 0;
}