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++: #define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

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

C++: #include<iostream>
using namespace std;
int main(){
	int n;
	int a,b;
	int A,B;
	cin>>n;
	if(n=0){break;}
	for(int j=0;j<5;j++){
	for(int i=0;i<10000;i++){
		cin>>a>>b;
	if(a>b){
		A+=a+b;
	}
	else if(a<b){
		B+=a+b;
	}
	else {
		A+=a;
		B+=b;
	}
	}
	}
	cout<<A<<" "<<B<<endl;
	return 0;
}

C++: #include<stdio.h>
int main()
{
  int a,aa;
  int cou,n,i;
  while(1){
    scanf("%d",&n);
    if(n==0){
      break;
    }
    a=i/2;
    aa=n/i;
    cou=0;
    for(i=2;i<=n/2;i++){
      if((double)i%2.000000==0.000000&&(double)n%(double)i==0.000000){
	continue;
      }
      if((double)i%2.000000!=0.000000&&(double)n%(double)i!=0.000000){
	continue;
      }
      if((double)i%2.000000==0.000000&&(double)n%(double)i!=0.000000){
	cou++;
      }
      if((double)i%2.000000!=0.000000&&(double)n%(double)i==0.000000){
	cou++;
      }
    }
    printf("%d",cou);
  }
  return 0;
}

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

int main() {
	int q[10001], w[10001];
	
	int x = 1;
	while (1) {
		int n;
		int a = 0;
		int b = 0;
		cin >> n;
		if (n == 0) {
			break;
		}

		for (int i = 1; i <= n; ++i) {
			int c, d;
			cin >> c >> d;
			if (c == d) {
				a = a + c;
				b = b + d;
			}
			else if (c > d) {
				a = a + c + d;
			}
			else {
				b = b + c + d;
			}
		}
		q[x] = a;
		w[x] = b;
		x = x + 1;
	}
	for (int j = 1; j <= x-1; ++j) {
		cout << q[j]<< w[j] << endl;
	}
}

C++: #include <stdio.h>

int main(){
	int a, b, as, bs, n;
	scanf("%d", &n);
	while(n != 0){
		as = 0;
		bs = 0;
		for(int i = 0; i < n; i++){
			scanf("%d %d", &a, &b);
			if(a > b){
				as += a + b;
			}else if(a < b){
				bs += a + b;
			}else{
				as += a;
				bs += b;
			}
			printf("%d %d\n", as, bs);
		}
		scanf("%d", &n);
	}
	return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <string>
#include <algorithm>
#include <string>
#include <climits>
#include <utility>

#define REP(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define REG(i, a, b) for (int (i) = ((int)(a)); (i) < ((int)(b)); i++)
#define ALL(V) (V).begin(), (V).end()
#define PRINT(STR) cout << (STR) << endl
#define ROUNDED(N) fixed << setprecision(N)
#define SPACE " "

typedef long long ll;
using namespace std;

int nextInt() { int n; cin >> n; return n; }
double nextDouble() { double d; cin >> d; return d; }
string nextString() { string str; cin >> str; return str; }

int main() {
	cin.tie(0); //対話型には使えない
	ios::sync_with_stdio(false); //printfと共には使えない
	while (true) {
		int n = nextInt();
		if (!n) break;
		int a_sum = 0, b_sum = 0;
		for (int i = 0; i < n; i++) {
			int a = nextInt(), b = nextInt();
			if (a > b) a_sum += a + b;
			else if (a == b) a_sum += a, b_sum += b;
			else b_sum += a + b;
		}
		cout << a_sum << SPACE << b_sum << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<sstream>
#include<cstdlib>

using namespace std;

int main(){
	string str;
	getline(cin,str);
	int scoreA = 0, scoreB = 0;
	while(getline(cin,str)){
		stringstream ss(str);
		string tmp;
		getline(ss,tmp,' ');
		int a = atoi(tmp.c_str());
		getline(ss,tmp);
		int b = atoi(tmp.c_str());
		if(a>b)scoreA+=(a+b);
		else scoreB+=(a+b);
	}
	cout<<scoreA<<" "<<scoreB<<endl;
	return 0;
}

C++: #include <cstdio>
using namespace std;
int main()
{
	int a=0,b=0,n,x,y;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d %d",&x,&y);
		if(x>y) a+=x+y;
		else if(x<y) b+=x+y;
		else{
			a+=x;
			b+=y;
		}
	}
	printf("%d %d\n",a,b);
}

C++: #include<stdio.h>
int main(void)
{
	int n,a,b,A,B,i;
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		A=0; B=0;
		for(i=0;i<n;i++){
			scanf("%d %d",&a,&b);
			if(a==b){
				A+=a; B+=b;
			}	
			else if(a>b) A+=a+b;
			else if(b>a) B+=a+b;
		}
		printf("%d %d\n",A,B);
	}
	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;
    else
      b += c + d; 
  }
  cout<< a << " " << b << endl;
  }
}

C++: #include <bits/stdc++.h>
using namespace std;

int main(void){
    int n,ascore,bscore;
    while(true){
        cin >> n;
        if(n==0) break;
        ascore = 0;
        bscore = 0;
        int a[n],b[n];
        for(int i=0;i<n;i++){
            cin >> a[i] >> b[i];
            if(a[i]>b[i]) ascore += (a[i]+b[i]);
            else if(a[i]<b[i]) bscore += (a[i]+b[i]);
            else {
                ascore += a[i];
                bscore += b[i];
            }
        }
        cout << ascore << " " << bscore << endl;
    }
    return 0;
}

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

C++: #include <iostream>
using namespace std;
 
int main() {
  int n, a, b, pointA, pointB;

  cin >> n;
  while(n != 0) {
    

    pointA = 0;
    pointB = 0;

    for(int i = 0; i < n; i++) {
      cin >> a >> b;
 
      if(a > b) {
        pointA += (a + b);
      } else if(a < b) {
        pointB += (a + b);
      } else {
        pointA += a;
        pointB += b;
      }
    }

    cout << a << ' ' << b << endl;
    cin >> n;
  }   
 
  return 0;
}

C++: #include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
int main(void){
int n,a,b,a1,b1;
while(1){
scanf("%d",&n);
a1=0;
b1=0;
if(n==0){break;}
for(int i=0;i<n;i++){
scanf("%d%d",&a,&b);
if(a>b){
a1=a+b;
}else if(b>a){
b1=a+b;
}else{
a1+=a;
b1+=b;
}
}
printf("%d %d\n",a1,b1);
}
return 0;
}