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 i,n,a,b;
	long apoint=0,bpoint=0;
	while(1){
		cin >> n;
		if(!n) break;
		for(i=0;i<n;i++){
			cin >> a;
			cin >> b;
			if(a>b){apoint+=a;apoint+=b;}
			else if(b>a){bpoint+=a;bpoint+=b;}
			else {apoint+=a;bpoint+=b;}
		}
		cout << apoint <<' ' << bpoint << endl;
	}
	return 0;
}

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

int main() {
	int n; //何枚ずつのカードを使うか
	int a_score; //Aの得点
	int b_score; //Bの得点
	int a, b;
	int ab_score[200]; //AとBの得点を入れておく箱
	int count = 0;
	while (true) {
		a_score=0;//初期化
		b_score=0;//初期化
		cin >> n;
		if(n==0)break;
		for (int i = 0; i < n; i++) {
			cin >> a >> b; //a,bに入力させる
			if (a > b)
				a_score += a + b;
			else if (b > a)
				b_score += a + b;
			else {
				a_score += a;
				b_score += b;
			}
		}
		ab_score[count] = a_score;
		ab_score[count + 1] = b_score;
		count += 2;
	}
	for (int i = 0; i < count - 1; i+=2) {
		cout << ab_score[i] << " " << ab_score[i + 1] << "\n";
	}
	return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
	int n, left = 0, right = 0, stage, stage2, i;

	while (true) {
		cin >> n;
		if(n == 0) break;
		for(i = 0; i < n; i ++){
			cin >> stage >> stage2;
			if(stage > stage2) left += stage + stage2;
			else if(stage < stage2) right += stage + stage2;
			else{
				left += stage;
				right += stage2;
			}
		}
		cout << left << " " << right << endl;
	}
	return 0;
}

C++: #include<bits\stdc++.h>
using namespace std;
int main(void){
	int n,asum,bsum,a,b,i;
	while(1){
		cin>>n;
		if(n==0)break;
		asum=0; bsum=0;
		for(i=0;i<n;i++){
			cin>>a>>b;
			if(a==b)asum+=a,bsum+=b;
			if(a>b)asum+=a+b;
			if(b>a)bsum+=a+b;
		}
		cout<<asum<<' '<<bsum;
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n, ans[11][3], an;
	an = 0;
	while (1) {
		cin >> n;
		if (n == 0) {
			goto a;
		}
		an = an + 1;
		int a, b;
		ans[an][1] = 0;
		ans[an][2] = 0;
		for (int i = 1; i <= n; i++) {
			cin >> a >> b;
			if (a == b) {
				ans[an][1] = ans[an][1] + a;
				ans[an][2] = ans[an][2] + b;
				goto b;
			}
			if (a > b) {
				ans[an][1] = a + b + ans[an][1];
			}
			if (a < b) {
				ans[an][2] = a + b + ans[an][2];
			}
		b:;
		}
	}
a:;
	for (int i = 1; i <= an; i++) {
		cout << ans[i][1] << " " << ans[i][2] << endl;
	}
}

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

#define FOR(i,begin,end) for(int i = (begin); i < (end); ++i)

using namespace std;

struct Data {
    int A, B;
    Data(int a, int b) : A(a), B(b) {}
};

int N;
vector<Data> inputs;

void solve() {
    int A_sum = 0, B_sum = 0;
    FOR(i, 0, N) {
        int A = inputs[i].A;
        int B = inputs[i].B;
        if (A > B) {
            A_sum += A + B;
        } else if (A < B) {
            B_sum += A + B;
        } else {
            A_sum += A;
            B_sum += B;
        }

        cout << A_sum << " " << B_sum << endl;
    }
}

int main() {
    cin >> N;
    while (N > 0) {
        inputs.clear();

        FOR(i, 0, N) {
            int A, B;
            cin >> A >> B;
            inputs.push_back(Data(A, B));
        }

        solve();
        cin >> N;
    }

    return 0;
}

C++: #include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
  int a,b,n;
  int ai,bi;
  while(cin>>n,n){
	  a=b=0;
	  for(int i=0;i<n;i++)
	  {
		  cin>>ai>>bi;
		  if(ai>bi) a+=ai+bi;
		  else if(bi>ai) b+=ai+bi;
		  else{
			  a+=ai;
			  b+=bi;
		  }
	  }
	 cout<<a<<' '<<b<<endl;
  }
    return 0;
}

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

int main(){
  int n,i, a,b;
  int x=0, y=0;
  cin >> n;
  if ( n <= 10000){
  for( i = 0 ; i < n ; i++){
    cin >> a >> b ;
    if ( a > b ){
      x =x+ (a+b); 
    }
    else if ( a == b){
      x = x+a;
      y = y+b;
    }
    
    else{
      y =y+(a+b);
    }
  }
  }
  cout << x << " " << y <<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 <bits/stdc++.h>
using namespace std;

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) {
      break;
    }
    vector<int> A(n), B(n);
    for (int i = 0; i < n; ++i) {
      cin >> A[i] >> B[i];
    }

    int ans_A = 0, ans_B = 0;
    for (int i = 0; i < n; ++i) {
      if (A[i] > B[i]) {
        ans_A += A[i] + B[i];
      } else if (A[i] == B[i]) {
        ans_A += A[i], ans_B += B[i];
      } else {
        ans_B += A[i] + B[i];
      }
    }

    cout << ans_A << ' ' << ans_B << endl;
  }
}

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;
    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<cstdio>

int main(void){
	int n,i,j,k,m=0;
	int a[10000],b[10000];
	int x[5]={0},y[5]={0};
	while(true){
		scanf("%d",&n);
		if(n==0)break;
		
		for(i=0;i<n;i++){
			scanf("%d%d",&a[i],&b[i]);
			if(a[i]>b[i]){
				x[m]=x[m]+a[i]+b[i];
			}else if(a[i]<b[i]){
				y[m]+=a[i]+b[i];
			}else{
				x[m]+=a[i];
				y[m]+=b[i];
			}
		}
		
		
		m++;
	}
	
	for(i=0;i<m;i++){
		printf("%d %d\n",x[i],y[i]);
	}
		
	return 0;
}

C++: #include<iostream>

using namespace std;
#define MAX_N 10000

int N;//カードの枚数
int A[MAX_N],B[MAX_N];
int PA[MAX_N],PB[MAX_N];
int Cou = 0;//何回目の勝負か記憶しておく

int main(){
  while(true){
  scanf("%d",&N);//配られるカードの枚数
  if(N==0)
    break;
  for(int i = 0;i < N;i++){
    scanf("%d %d",&A[i],&B[i]);
    if(A[i] > B[i])
      PA[Cou] += A[i]+B[i];
    else if(A[i] < B[i])
      PB[Cou] += A[i]+B[i];
    else{
      PA[Cou] += A[i];
      PB[Cou] += B[i];
    }
  }
  Cou++;
  }
  for(int j = 0;j < Cou;j++){
      printf("%d %d\n",PA[j],PB[j]);
  }
  return 0;
 
}