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>
#include<vector>
int main() {
	std::vector<int> a, b;
	while (true) {
		int n;
		int as = 0, bs = 0;
		std::cin >> n;
		if (!n) {
			break;
		}
		for (int i = 0; i < n; ++i){
			int n, m;
			std::cin >> n >> m;
			if (n == m) { as += n;
			bs +=  m;
			}
			else if (n > m) {
				as += n + m;
			}
			else if (m > n) {
				bs += n+ m;
			}
		}
		a.push_back(as);
		b.push_back(bs);
	}
	for (int i = 0; i < a.size(); ++i) {
		std::cout << a[i] << " " << b[i] << std::endl;
	}
	return 0;
}

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

int main(){

	while(true){

		int n;
		cin >> n;

		if(n == 0){
			break;
		}

		int* a = new int[n];
		int* b = new int[n];

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

		int a_total = 0;
		int b_total = 0;

		for(int i = 0; i < n; i++){
			if(a[i] > b[i]){
				a_total += a[i] + b[i];
			}
			else if(a[i] < b[i]){
				b_total += a[i] + b[i];
			}
			else{
				a_total += a[i];
				b_total += b[i];
			}
		}

		cout << a_total << " " << b_total << endl;

	}
}

C++: #include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <queue>
#include <algorithm>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const double pi=acos(-1);

int n,A=0,B=0;

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		int a,b;
		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;
}

C++: #include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 

using namespace std;

int main()
{
	int n,ca,cb,A,B;

	cin>>n;
	while(n>0){
		ca=cb=A=B=0;
		for(int i=0;i<n;i++){
			cin>>ca>>cb;
			if(ca>cb) A+=ca+cb;
			else if(cb>ca) B+=ca+cb;
			else{A+=ca;B+=cb;}
		}
		cout<<A<<" "<<B<<endl;
		cin>>n;
	}

	return 0;
}

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

int main()
{	
	int n,a[10000]={},b[10000]={},ascore=0,bscore=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		cin>>b[i];
		if(a[i]>b[i]){
			ascore+=a[i]+b[i];
		}else if(a[i]<b[i]){
			bscore+=a[i]+b[i];
		}else if(a[i]==b[i]){
			ascore+=a[i];
			bscore+=b[i];
		}
	}

	cout<<ascore<<" "<<bscore<<endl;
	return 0;
}

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

C++: // tsukasa_diary's programing contest code template
#include <bits/stdc++.h>
using namespace std;
// define
#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) (int)a.size()
// typedef
typedef long long lint;
typedef double Double;
typedef pair<int, int> pii;
//
typedef vector< int > Array;
typedef vector< Array > Matrix;
typedef vector< Double > DArray;
typedef vector< DArray > DMatrix;
typedef vector< string > SArray;
typedef vector< pii > PArray;
// popcount
inline int POPCNT(int _x) { return __builtin_popcount(_x); }
inline int POPCNT(lint _x) { return __builtin_popcountll(_x); }
// inf
const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
// eps
Double EPS = 1e-9;
// in range
inline bool in_range(int _v, int _mx, int _mi) { return _mi <= _v && _v < _mx; }
inline bool in_range(Double _v, Double _mi, Double _mx) { return -EPS < _v - _mi && _v - _mx < EPS; }
inline bool in_range(int _x, int _y, int _W, int _H) { return 0 <= _x && _x < _W && 0 <= _y && _y < _H; }
// neighbor clockwise
const int DX[4] = {0,1,0,-1}, DY[4] = {-1,0,1,0};
const int DX_[8] = {0,1,1,1,0,-1,-1,-1}, DY_[8] = {-1,-1,0,1,1,1,0,-1};
// variable update
inline void modAdd(int& _a, int _b, int _m) { _a = (_a + _b) % _m; }
inline void modAdd(lint& _a, lint _b, lint _m) { _a = (_a + _b) % _m; }
inline void minUpdate(int& _a, int _b) { _a = min(_a, _b); }
inline void minUpdate(lint& _a, lint _b) { _a = min(_a, _b); }
inline void maxUpdate(int& _a, int _b) { _a = max(_a, _b); }
inline void maxUpdate(lint& _a, lint _b) { _a = max(_a, _b); }

int n;

void solve() {
	int A = 0, B = 0;
	
	for_(i,0,n) {
		int a, b; 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;
}

int main() {
	while (cin >> n, n) {
		solve();
	}
	return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n,a,b,x=0,y=0;
  cin>>n;
  rep(i,n){
    cin>>a>>b;
    if(a==b){
      x+=a;
      y+=b;
    }
    else if(a>b)x+=(a+b);
    else if(b>a)y+=(a+b);
  }
  cout<<x<<" "<<y<<endl;
}

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

int main(){
	int a=0,b=0;
	int na,nb;
	int nc;
	cin>>nc;
	if(nc==0) return 0;
	for(int i=0;i<nc;i++){
		cin>>na>>nb;
		if(na>nb) a+=(na+nb);
		else if(na<nb) b+=(na+nb);
		else {a+=na;b+=nb;}
	}
	cout<<a<<" "<<b<<endl;
	return 0;
}

C++: #include<cstdio>
#include<algorithm>
#include<functional>
#include<cstring>
#include<iostream>
#include<cmath>
#include<queue>
#include<cctype>
#include<string>
#define rep(i,a,b) for(i=a;i<b;i++)
using namespace std;
int main(void)
{
	int n,i,j,k,suma,sumb,a,b;
	while(1) {
		cin>>n;if(n==0) break;
		suma=0,sumb=0;
		rep(i,0,n) {
			cin>>a>>b;
			if(a>b) suma+=a+b;
			else if(b>a) sumb+=a+b;
			else suma+=a,sumb+=b;
		}
		cout<<suma<<" "<<sumb<<endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define p_q priority_queue
#define MN 1000000009

int n, a, b, c, d;
int main(){
    while(cin >> n){
        if (n==0) return 0;
        c=d=0;
        for (int l=0; l<n; ++l){
            cin >> a >> b;
            if (a>b) c+=a+b;
            else if (b>a) d+=a+b;
            else {c+=a; d+=a;}
        }
        cout << c << ' ' << d << endl;
    }
    return 0;
}

C++: #include<iostream>

using namespace std;

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

	while(cin >> n){
		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++: eeee