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<bits/stdc++.h>
using namespace std;


class sai{
public:
  int ue,sita,mae,ushiro,migi,hidari;

  sai(int top=1,int front=3,int ue=1,int sita=6,int mae=3,int ushiro=4,int migi=5,int hidari=2):ue(ue),sita(sita),mae(mae),ushiro(ushiro),migi(migi),hidari(hidari) {
    for(int i=0;i<6;i++){
      if(ue==top && mae==front){break;}
      for(int t=0;t<4;t++){
	move(5);
	if(ue==top && mae==front){break;}
      }
      if(ue==top && mae==front){break;}
      if(i<4){move(1);}
      if(i==4){move(2);}
      if(i==5){move(2); move(2);}
    }

  }

  int move(int i){
    int ued=ue,sitad=sita,maed=mae,ushirod=ushiro,migid=migi,hidarid=hidari;
    if(i==1){
      ushiro=ued;
      ue=maed;
      mae=sitad;
      sita=ushirod;
    }
    if(i==2){
      migi=ued;
      ue=hidarid;
      hidari=sitad;
      sita=migid;
    }
    if(i==3){
      ushiro=sitad;
      ue=ushirod;
      mae=ued;
      sita=maed;
    }
    if(i==4){
      migi=sitad;
      ue=migid;
      hidari=ued;
      sita=hidarid;
    }
    if(i==5){
      migi=maed;
      mae=hidarid;
      hidari=ushirod;
      ushiro=migid;
    }
    return ue;
  }

  int where(int me){
    if(ue==me){return 0;}
    if(mae==me){return 3;}
    if(ushiro==me){return 1;}
    if(migi==me){return 2;}
    if(hidari==me){return 4;}
    return 0;
  }

  
};


vector<int> me[1000][1000];
int h[1000][1000];

int main(){ 
  for(int i=0;i<100;i++){
    for(int t=0;t<100;t++){
      h[i][t]=0;
      me[i][t].clear();
    }
  }
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int x=500,y=500;
    int top,front;
    cin>>top>>front;
    h[x][y]++;
    me[x][y].push_back(top);
    sai saikoro(top,front);
    while(1){
      int to=0;
      bool done=false;
      for(int t=4;t<=6;t++){
	to=saikoro.where(t);
	if(to==0){continue;}
	if(to==1 && h[x][y]>h[x][y+1]+1){me[x][y].erase(--me[x][y].end()); h[x][y]--; y++; h[x][y]++; me[x][y].push_back(saikoro.move(to)); done=true; break;}
	if(to==2 && h[x][y]>h[x+1][y]+1){me[x][y].erase(--me[x][y].end()); h[x][y]--; x++; h[x][y]++; me[x][y].push_back(saikoro.move(to)); done=true; break;}
	if(to==3 && h[x][y]>h[x][y-1]+1){me[x][y].erase(--me[x][y].end()); h[x][y]--; y--; h[x][y]++;  me[x][y].push_back(saikoro.move(to)); done=true; break;}
	if(to==4 && h[x][y]>h[x-1][y]+1){me[x][y].erase(--me[x][y].end()); h[x][y]--; x--; h[x][y]++;  me[x][y].push_back(saikoro.move(to)); done=true; break;}
      }
      if(!done){break;}
    }

      
  }
  int ans[7]={};
  for(int i=0;i<1000;i++){
    for(int t=0;t<100;t++){
      ans[me[i][t][me[i][t].size()-1]]++;
    }
  }
  for(int i=1;i<=6;i++){
    cout<<ans[i];
    if(i!=6){cout<<" ";}
  }
  cout<<endl;
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	while (1){
		int a[15] = {}, b[15] = {}, A = 0, B = 0;
		double n;
		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 <cstdio>

int n,an,bn,i,j;
int a[10000],b[10000];
int main (){
	n=1;
	while(n){
		scanf("%d",&n);
		if(n==0) break;
		an=0;
		bn=0;
		for (i=0;i<n;i++){
			scanf("%d %d",&a[i],&b[i]);
		}
		for(j=0;j<n;j++){
			if(a[j]>b[j]) an=an+(a[j]+b[j]);
			else if(a[j]<b[j]) bn=bn+(a[j]+b[j]);
			else if (a[j]==b[j]) { 
				an=an+a[j];
				bn=bn+b[j];
			}
		}
		printf("%d %d\n",an,bn);
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
    int num;

    while(true)
    {
        cin >> num;
        if(num == 0) break;

        int score1 = 0;
        int score2 = 0;
        int card1;
        int card2;
        for(int i = 0; i < num; ++i)
        {
            cin >> card1 >> card2;
            if(card1 > card2)
            {
                score1 += card1 + card2;
            }
            else if(card1 < card2)
            {
                score2 += card1 + card2;
            }
            else
            {
                score1 += card1;
                score2 += card2;
            }
        }
        cout << score1 << ' ' << score2 << endl;
    }
}

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

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

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b,aa=0,ab=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a>>b;
    if(a>b){
      aa+=a+b;
    }
    if(a<b){
      ab+=a+b;
    }
    if(a==b){
      aa+=a;
      ab+=b;
    }
  }
  cout<<aa<<' '<<ab<<endl;
  return(0);
}

C++: #include<iostream>
#include<string>
using namespace std;
int N, S, i, cnt, R, num;
string str, s;
string ring[101];
int main(){
    cin >> str >> N;
    S = str.size();
    for (i=0; i<N; i++){
        cin >> s;
        ring[i] = s + s;
    }
    cnt = 0;
    for (i=0; i<N; i++){
        R = ring[i].size();
        for (num = 0; num < R-S+1; num++){
            if( ring[i].substr(num,S) == str ){
                cnt++; break;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
  int n;
  cin >> n;
  int a,b;
  int res_a=0,res=b=0;
  for(int i=0;i<n;i++){
    cin >> a >> b;
    if(a>b)res_a+=(a+b);
    else if(a<b)res_b+=(a+b);
    else{res_a+=a;res_b+=b;}
  }
  cout << res_a << res_b << endl;
  return 0;
}

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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int main(){
  int n, p[2], c[2];
  while(scanf("%d", &n) && n){
    p[0] = p[1] = 0;
    while(n--){
      scanf("%d%d", c, c+1);
      if(c[0] > c[1]) p[0] += c[0]+c[1];
      else if(c[0] < c[1]) p[1] += c[0]+c[1];
      else p[1] += c[1], p[0] += c[1];
    }
    printf("%d %d\n", p[0], p[1]);
  }
  return 0;
}