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 n=0;
	while(cin>>n){
		int a=0,b=0;
		while(n-->0){
			int x=0,y=0;
			cin>>x>>y;
			if(x>y){
				a+=x+y;
			}
			if(x==y){
				a+=x;
				b+=y;
			}
			if(x<y){
				b+=x+y;
			}
		}
		cout<<a<<' '<<b<<endl;
	}
	return 0;
}

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

int main(){
int n,a,b;
int sumA=0,sumB=0;
while(cin>>n){
for(int i=0;i<n;i++){
cin>>a>>b;
if(a>b){
sumA+=a;
sumA+=b;
}
if(a==b){
sumA+=a;
sumB+=b;
}
if(a<b){
sumB+=a;
sumB+=b;
}}}

C++: #include<iostream>
using namespace std;
int main(){
    int n=1,A=0,B=0;
    while(n!=0){
        cin>>n;
        if(n==0){break;}
        for(int i=0;i<n;i++){
            int ap=0,bp=0;
            cin>>ap;
            cin>>bp;
            if(ap<bp){
                B=B+ap+bp;
            }
            if(ap>bp){
                A=A+ap+bp;
            }
            if(ap==bp){
                A=A+ap;
                B=B+bp;
            }
        }
        cout<<A<<" "<<B<<endl;
        A=0;B=0;
    }
    return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
	int n;
	int a[10000],b[10000];
	
	while(cin>>n && n!=0){
		int point_a=0;
		int point_b=0;

		for(int i=0;i<n;i++){
			cin>>a[i]>>b[i];
			if(a[i] > b[i]){
				point_a+=(a[i] + b[i]);
			}else if(a[i] == b[i]){
				point_a+=a[i];
				point_b+=b[i];
			}else{
				point_b+=(a[i] + b[i]);
			}
		}
		cout<<point_a<<" "<<point_b<<endl;
	}
	return 0;
}

C++: #include <iostream>

int main() {
	int n, a_s, b_s, *a, *b;
	std::cin >> n;
	while (n) {
		a_s = b_s = 0;
		a = new int[n];
		b = new int[n];
		for (int i; i<n; i++) {
			std::cin >> a[i] >> b[i];
		}
		for (int i; i<n; i++) {
			if (a[i] > b[i]) {
				a_s += a[i] + b[i];
			} else if (a[i] < b[i]) {
				b_s += a[i] + b[i];
			} else {
				a_s += a[i], b_s += b[i];
			}
		}
		std::cout << a_s << " " << b_s << std::endl;
		delete a;
		delete b;
		std::cin >> n;
	}
}

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;

ll 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 <iostream>
#include <vector>
using namespace std;

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

  int n;
  int a_score;
  int b_score;
  while(true) {
    a_score = 0;
    b_score = 0;
    cin >> n;
    if(n == 0) break;
    for(int i=0;i<n;i++) {
      int a_card,b_card;
      cin >> a_card >> b_card;
      if( a_card > b_card ) {
        a_score += a_card + b_card;
      }
      else if( b_card > a_card) {
        b_score += a_card + b_card;
      }
      else {
        // if a_card == b_card
        a_score += a_card;
        b_score += b_card;
      }
    } // end for
    cout << a_score << " " << b_score << "\n";
  } // end while
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  ll a,b,A=0,B=0;
  rep(i,n){
    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 <iostream>
using namespace std;

int main() {
	int n;
	int a = 0;
	int b = 0;
	int x = 0;
	while (1) {

		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;
			}
		}
		cout << a << endl;
		cout << b << endl;
	}
}

C++: #include <cstdio>
int main(){
	int a, b, c;
	scanf("%d", &a);
	b = 0;
	c = 0;
	int n_a[a];
	int n_b[a];
	for(int i=0; i<a; i++){
		scanf("%d %d", &n_a[i], &n_b[i]);
	}
	for(int i=0; i<a; i++){
		if(n_a[i] > n_b[i]){
			b += n_a[i]+n_b[i];
		}else if(n_a[i] < n_b[i]){
			c += n_a[i]+n_b[i];
		}else if(n_a[i] == n_b[i]){
			b += n_a[i];
			c += n_b[i];
		}
	}
	printf("%d %d", b, c);
	return 0;
}

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

int main() {
	int num;
	int score_a = 0;
	int score_b = 0;
	
	cin >> num;
	for (int i = 0; i < num; i++) {
		int a;
		int b;

		cin >> a >> b;
		if (a > b) {
			score_a += a + b;
		}else if (b > a) {
			score_b += a + b;
		}else {
			score_a += a;
			score_b += b;
		}
	}
	cout << score_a << " " << score_b << endl;
	score_a = 0;
	score_b = 0;

	return 0;
}

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 + m;
			}
			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;
}