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>
#include <iostream>
using namespace std;
int main (){
while (1){
int i,ny[100]={0},ny2[100]={0},sum=0,sum2=0;
scanf ("%d",&i);
if (i==0)break;
for (int s=0;s<i;s++){
        scanf ("%d%d",&ny[s],&ny2[s]);
}
for (int s=0;s<i;s++){
        if (ny[s]==ny2[s]){
        sum=sum+ny[s];
        sum2=sum2+ny2[s];
        }
        else if (ny[s]>ny2[s]){
                sum=sum+ny[s]+ny2[s];
        }
        else {
                sum2=sum2+ny[s]+ny2[s];
        }
}
printf ("%d %d\n",sum,sum2);
}
return -1;
}

C++: #include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n, a, b;
    int as = 0, bs = 0;
    while(cin >> n){
        rep(i,n){
            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;
    }
}

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

C++: #include <iostream>

int main(int argc, char **argv)
{
	int a, b;
	int n;
	int acards[10000],bcards[10000];
	while(true){
		a = 0;
		b = 0;
		std::cin >> n;
		if(n == 0){
			break;
		}
		for(int i = 0; i < n; i++){
			std::cin >> acards[i] >> bcards[i];
			if(acards[i] < bcards[i]){
				b += bcards[i] + acards[i];
			}
			if(acards[i] > bcards[i]){
				a += bcards[i] + acards[i];
			}
			if(acards[i] == bcards[i]){
				a += acards[i];
				b += bcards[i];
			}
		}
		std::cout << a << " " << b << std::endl;
	}
	return 0;
}

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

C++: //Volume5 -> 0501

#include <iostream>
#include <vector>
//#include <math.h>
//#include <string>
#include <cmath>
#include <iomanip>

int main();

int main(){
	std::vector<int> totalAPoint;		//Aの得点
	std::vector<int> totalBPoint;		//Bの得点
	int dataSetCount = 0;				//ゲーム数

	while (1){
		int n = 0;		//1ゲームの入力数

		std::cin >> n;
		//n=0で終了
		if (n == 0){
			break;
		}

		dataSetCount++;

		int aPoint = 0;		//1ゲームにおけるAの得点
		int bPoint = 0;		//1ゲームにおけるBの得点

		for (int i = 0; i < n; i++){
			int tempA;
			int tempB;

			std::cin >> tempA >> tempB;
			if (tempA > tempB){
				aPoint += (tempA + tempB);
			}
			else if (tempA < tempB){
				bPoint += (tempA + tempB);
			}
			//引き分け
			else{
				aPoint += tempA;
				bPoint += tempB;
			}
		}

		totalAPoint.push_back(aPoint);
		totalBPoint.push_back(bPoint);
	}

	//結果出力
	for (int i = 0; i < dataSetCount; i++){
		std::cout << totalAPoint[i] << " " << totalBPoint[i] << std::endl;
	}

	//while (1);
	return 0;
}

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

C++: #include <stdlib.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int a[10000];
int b[10000];
int main(){
	while(1){
	int n;
	cin>>n;
	if(n==0)break;
	REP(i,n)cin>>a[i]>>b[i];
	int ans_a=0,ans_b=0;
	REP(i,n){
		if(a[i]>b[i]){
			ans_a+=(a[i]+b[i]);
		}else if(a[i]<b[i]){
			ans_b+=(a[i]+b[i]);
		}else{
			ans_a+=a[i];
			ans_b+=b[i];
		}
	}
	cout<<ans_a<<" "<<ans_b;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int result[200] = { 0 };
int main(){
		int num;
		int tmp1, tmp2, sc1 = 0, sc2= 0;
		while (cin >> num){
			sc1 = sc2 = 0;
			if (num == 0)break;
			for (int i = 0; i < num; i++){
				cin >> tmp1 >> tmp2;
				if (tmp1 == tmp2){
					sc1 += tmp1;
					sc2 += tmp2;
				}
				else if (tmp1 > tmp2)
					sc1 += tmp1 + tmp2;
				else if (tmp1 < tmp2)
					sc2 += tmp1 + tmp2;
			}
			cout << sc1 << " " << sc2 << endl;
		}
}

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

int main(void) {
	int i, n, a, b, as = 0, bs = 0;
	cin >> n;
	for(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++: #include <bits/stdc++.h>
using namespace std;

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