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 A, B, card[10000][2];

int main(){

	while(1){

		int n, i;

		cin >> n;
		if(n==0){break;}

		A = 0;
		B = 0;

		for(i=0; i<n; i++){
			cin >> card[i][0] >> card[i][1];
		}

		for(i=0; i<n; i++){
			if(card[i][0]==card[i][1]){
				A += card[i][0];
				B += card[i][0];
			}
			else if(card[i][0] > card[i][1]){
				A += card[i][0] + card[i][1];
			}
			else{
				B += card[i][0] + card[i][1];
			}
		}

		cout << A << ' '<< B << endl;

	}

	return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{ int n,x=0,y=0,a,b;
cin>>n;
for(int i=1;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<<"\n";
 return 0;
}

C++: #include<iostream>
using namespace std;
int main() {
	int n = 0;
	cin >> n;
	int a[10000] = {};
	int b[10000] = {};
	int i = 0;
	int aa, bb = 0;
	while(cin >> a[i] >> b[i]) {
		i++;
	}
	for (int j = 0; j >= i; j++) {
		if (a[j] > b[j]) {
			aa += a[j] + b[j];
		}
		else if (a[j] < b[j]) {
			bb += a[j] + b[j];
		}
		else if (a[j] == b[j]) {
			aa += a[j];
			bb += b[j];
		}
	}
	cout << aa << bb << endl;
	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

int n, a, b, suma = 0, sumb = 0;

int main(){
	cin >> n;
	REP(i, n){
		cin >> a >> b;
		if (a > b){
			suma += a + b;
		}
		else if (a < b){
			sumb += a + b;
		}
		else {
			sumb += b;
			suma += a;
		}
	}
	cout << suma << " " << sumb << endl;
}

C++: #include<stdio.h>

int main(){
	int n;
	int A=0;
	int B=0;
	int i=0;
	while(1){
	scanf("%d", &n);
	if(n==0){
	return 0;
	}
	int x[10000];
	int y[10000];
	while(i<n){
	scanf("%d", &x[i]);
	if(0>x[i] || 9<x[i]){
	return 0;
	}
	scanf("%d", &y[i]);
	if(0>y[i] || 9<y[i]){
	return 0;
	}
	++i;
}
	i=0;
	while(i<n){
	if(x[i]>y[i]){
	A=A+x[i]+y[i];
}else {
	if(x[i]<y[i]){
	B=B+x[i]+y[i];
}else{
	A=A+x[i];
	B=B+y[i];
			}
		}
	++i;
	}
	printf("%d %d\n", A, B);
	}
}

C++: #include<iostream>
using namespace std;
int main(){
    int n;
    int as[5];
    int bs[5];
    int l = 0;
    while(cin >> n){
        as[l] = bs[l] = 0;
        for(int i = 0;i < n;i++){
            int a;
            int b;
            cin >> a >> b;
            if(a > b){
                as[l] += a + b;
            }
            else if(a == b){
                as[l] += a;
                bs[l] += b;
            }
            else{
                bs[l] += a + b;
            }
        }
        l++;
    }
    for(int i = 0;i < l - 1;i++){
        cout << as[i] << " " << bs[i] <<endl;
    }
    return 0;
}

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

int main(void){
  int a,b;
  int n;
  while(cin>>n,n){
  while(n--){
    a = b = 0;
    int c,d;
    cin>>c>>d;
    if(c>d)
      a += c + d;
    else
      b += c + d; 
  }
  cout<< a << " " << b << endl;
  }
}

C++: #include<algorithm>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

template<typename T>
bool chmax(T &a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T &a, T b){
    if(b < a){
        a = b;
        return true;
    }
    return false;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    while(cin >> n, n){
        lint ascore = 0, bscore = 0;
        rep(i, n){
            lint a, b;
            cin >> a >> b;
            if(a == b){
                ascore += a;
                bscore += b;
            }else if(a < b){
                bscore += a + b;
            }else{
                ascore += a + b;
            }
        }

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

    return 0;
}

C++: #include <stdio.h>
int n,i,j,k;
int A[1]=0,B[1]=0;
int main(){
  for(;;){
    scanf("%d",&n);
    if(n==0){
      return 0;
    }
      for(i=0;i<n;i++){
      scanf(" %d %d",&j,&k);
      if(j>k){
        A[0]+=(j+k);
      } else if(j<k){
        B[0]+=(j+k);
      } else if(j==k){
        A[0]+=j;
        B[0]+=k;
      }
      printf("%d %d\n",A[0],B[0]);
      A[0]=0,B[0]=0;
    }
  }
}

C++: #include <stdio.h>

const int MAX_N=10000;
int a[MAX_N];
int b[MAX_N];
int n;
int A=0;int B=0;
void solve(){
	for(int i=0;i<n;i++){
		if(a[i]>b[i]){
			A+=a[i]+b[i];
		}
		else if(a[i]<b[i]){
			B+=a[i]+b[i];
		}
	}
}
int main(){
 while(1){
	scanf("%d",&n);
	if(n==0){
		break;
	}
	for(int i=0;i<n;i++){
	scanf("%d%d",&a[i],&b[i]);
	}
	solve();
	printf("%d %d\n",A,B);
	A=0;
	B=0;
 }
   return 0;
}

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

using namespace std;


int main() {
	int n, ka, kb;
	int a, b;
	vector<pair<int, int> > dst;
	while (cin >> n && n != 0) {
		a = b = 0;
		while (n-->0 && cin >> ka >> kb) {
			if (ka > kb)
				a += (ka + kb);
			else if (ka < kb)
				b += (ka + kb);
			else {
				a += ka;
				b += kb;
			}
		}
		dst.push_back(pair<int, int>(a, b));
	}
	for (vector<pair<int, int> >::iterator it = dst.begin(); it < dst.end(); it++)
		cout << (*it).first << " " << (*it).second << endl;
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <iostream>

using namespace std;

void main(){
  int n;
  int a,b;
  while(cin >> n, n){
    int asum = 0;
    int bsum = 0;
    for(int i=0; i<n; i++){
      cin >> a >> b;
      if(a > b) asum += a+b;
      else if(a < b) bsum += a+b;
      else{
        asum += a;
        bsum += b;
      }
    }
    cout << asum << " " << bsum << endl;
  }
  return;
}