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 <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
	int n, card[2][10000];
	while (scanf("%d", &n), n)
	{
		for (int i = 0; i < n; ++i)
			scanf("%d%d", card[0] + i, card[1] + i);
		int A, B;
		A = B = 0;
		for (int i = 0; i < n; ++i)
		{
			if (card[0][i] > card[1][i])
				A += card[0][i] + card[1][i];
			else if (card[0][i] < card[1][i])
				B += card[0][i] + card[1][i];
			else
			{
				A += card[0][i];
				B += card[1][i];
			}
		}
		printf("%d %d\n", A, B);
	}

	return 0;
}

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

C++: #include<iostream>
int main(){int n,c,d;while(std::cin>>n){int a=0,b=0;if(!n)return 0;while (n--){std::cin>>c>>d;if(c>d)a+=c+d;if(c==d){a+=c;b+=c;}if(c<d)b+=c+d;}printf("%d %d\n",a,b);}}

C++: #include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
    
    int n,a,b,sumA = 0,sumB = 0;
    
    
    while(1){
        cin >> n;
        if(!n) return 0;
        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 <iostream>
using namespace std;
int main(void)
{
	int a,b,c,d;
	int e=0;
	int f=0;
	cin>>a;
	for (b=0;b<a;b++)
	{
		cin>>c>>d;
		if (c>d)
		{
			e=e+c+d;
		}
		else if (c<d)
		{
			f=f+d+c;
		}
		else if (c==d)
		{
			e=e+c+d;
			f=f+d+c;
		}
	}
	cout<<e<<" "<<f<<endl;
	return 0;
}

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

C++: #include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include <string.h>
using namespace std;
int main(){
	while(1){
		int n;
		cin>>n;
		if(n==0)break;
		int a=0,b=0;
		int x,y;
		for(int i=0;i<n;i++){
			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, at, bt;
	
loop:
	scanf("%d\n", &n);		// 各人のカード枚数
	if(n == 0) goto end_scope;
	at = 0;
	bt = 0;
	
labl_testloop:
	scanf("%d %d\n", a, b);
	if(a > b) at += a + b; else if(a == b){at += a; bt += b;}else bt += a + b;
	n--;
	if(n > 0) goto labl_testloop;
	
	printf("%d %d\n", at, bt);
	goto loop;
end_scope:
    return 0;
}

C++: #include <iostream>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main() {
    int n, a, b;
    while (cin >> n && n) {
        int apt = 0, bpt = 0;
        rep(i, n) {
            cin >> a >> b;
            if (a > b) {
                apt += a + b;
            }
            else if (a < b) {
                bpt += a + b;
            }
            else {
                apt += a;
                bpt += b;
            }
        }
        cout << apt << " " << bpt << endl;
    }
    return 0;
}

C++: #include <stdio.h>

void main() {
	int n, a, b;
	int suma = 0;
	int sumb = 0;
	bool endflg = false;
	while (1) {
		scanf_s("%d", &n);
		if (n == 0) {
			return;
		}
		int i;
		for (i = n; i > 0; i--) {
			scanf_s("%d %d", &a, &b);
			if (a > b) {
				suma = suma + a + b;
			}
			else if (b > a) {
				sumb = sumb + a + b;
			}
			else {
				suma = suma + a;
				sumb = sumb + b;
			}
		}
		printf("%d %d\n", suma, sumb);
		suma = 0;
		sumb = 0;
	}
	
}

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

using namespace std;

class Player
{	friend class Batler;
	vector<int> card;
	long long int point;
public:
	Player():point(0){}
};
class Batler
{
	Player *p1, *p2;
public:
	Batler(Player *P1, Player *P2):p1(P1),p2(P2){}

	void init();
	void input();
	void start();
};
void Batler::init()
{
	if(!p1->card.empty()){
		p1->card.clear();
		p2->card.clear();
	}
	p1->point = 0;
	p2->point = 0;
}
void Batler::input()
{
	int buf;
	cin>>buf;
	p1->card.push_back(buf);
	cin>>buf;
	p2->card.push_back(buf);
}
void Batler::start()
{
	for(unsigned int i = 0; i < p1->card.size(); i++){
		if( p1->card[i] > p2->card[i]){
			p1->point += p1->card[i] + p2->card[i];
		}else if( p1->card[i] < p2->card[i] ){
			p2->point += p1->card[i] + p2->card[i];
		}else{
			p1->point += p1->card[i];
			p2->point += p2->card[i];
		}
	}
	cout<<p1->point<<" "<<p2->point<<endl;
}
int main()
{
	int n;
	Player p1, p2;
	Batler batle(&p1,&p2);

	while(1){
		batle.init();
		cin>>n;
		if(n == 0) return 0;

		//üÍ
		for(int i = 0; i < n; i++){
			batle.input();
		}
		//ð
		batle.start();
	}
}

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

C++: #include<iostream>
#include<vector>
int main() {
	int i = 0;
	std::cin >> i;
	int A = 0, B = 0;
	std::vector<int> a{ 100000 }, b{ 100000 };
	for (int j = 0; j < i; ++j) {
		std::cin >> a[j] >> b[j];
	}
	for (int j = 0; j < i; ++j) {
		if (a[j] > b[j]) {
			A += (a[j] + b[j]);
		}
		else if (a[j] < b[j]) {
			B += (a[j] + b[j]);
		}
		else {
			A += a[j];
			B += b[j];
		}
	}
	std::cout << A << " " << B << std::endl;
}