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;
  while(cin >> n && n>0){
  int a,b;
  int res_a=0,res_b=0;
  for(int i=0;i<n;i++){
    cin >> a >> b;
    if(a>b) res_a+=(a+b);
    else if(a<b) res_b+=(a+b);
    else{res_a+=a;res_b+=b;}
  }
  cout << res_a << res_b << endl;
}
}

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

int main()
{

	int n;
	int a=0,b=0;
	int ac,bc;

	cin >> n;

	while(n > 0){
		n--;
		cin >> ac >> bc;
		if(ac > bc)
			a += ac + bc;
		else if(ac < bc)
			b += ac + bc;
		else
			a += ac, b += bc;
	}
	printf("%d %d\n", a,b);


	return 0;
}

C++: #include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
    int a,b;
    int input;
    while(1)
    {
        scanf("%d",&input);
        if(input == 0) break;
        int suma = 0;
        int sumb = 0;
        for(int i = 0;i < input;i++)
        {
            scanf("%d%d",&a,&b);
            if(a>b)
            {
                suma = suma +a +b;
            }
            else if(b>a)
            {
                sumb = sumb +a +b;
            }
            else if(a == b)
            {
                suma = suma+a;
                sumb += sumb+b;
            }
        }
        printf("%d %d\n",suma,sumb);
    }
    return 0;
}

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

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

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

C++: #include<iostream>
using namespace std;
int main(){
	while (true){
		int n, A[10000] = {}, B[10000] = {}, tenA = 0, tenB = 0;
		cin >> n;
		if (n == 0) break;
		for (int i = 0; i < n; i++){
			cin >> A[i] >> B[i];
			if (A[i] > B[i]){
				tenA += A[i] + B[i];
			}
			if (A[i] == B[i]){
				tenA += A[i];
				tenB += B[i];
			}
			if (A[i] < B[i]){
				tenB += A[i] + B[i];
			}
		}
		cout << tenA << ' ' << tenB << 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;
	int a[10000] , b[10000];
	int scoreA=0 , scoreB=0;
	int i;
	while(1){
		cin>>n;
		if(n==0) break;
		for(i=0 ; i<n ; i++){
			cin >> a[i] >> b[i];
			if(a[i]>b[i]){
				scoreA+=a[i]+b[i];
			} else if (a[i]<b[i]){
				scoreB+=a[i]+b[i];
			} else {
				scoreA+=a[i];
				scoreB+=b[i];
			}
		}
		cout << scoreA << " " << scoreB << endl;
	}
	return 0;
}

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

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

int main(){
    int n;
    int a_point = 0, b_point = 0;

    while(cin >> n, n != 0){
        for(int i=1; i<=n; i++){
            int tmp1, tmp2;
            cin >> tmp1 >> tmp2;
            if(tmp1 > tmp2){
                a_point += tmp1 + tmp2;
            }else if (tmp1 < tmp2){
                b_point += tmp1 + tmp2;
            }else{
                a_point += tmp1;
                b_point += tmp2;
            }
        }
        cout << a_point << " " << b_point << endl;
    }
    return 0;
}

C++: #include <cstdio>

int main(){
	int A, B, N;
	int As, Bs;

	while (1){
		scanf("%d", &N);
		if (N == 0) break;
		As = 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);
	}

	return 0;
}

C++: #include <cstdio>

int main(void){
	int a, b, c;
	scanf("%d", a);
	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 i,n,a,b,apoint=0,bpoint=0;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> a;
		cin >> b;
		if(a>b){apoint+=a;apoint+=b;}
		else if(b>a){bpoint+=a;bpoint+=b;}
		else {apoint+=a;bpoint+=b;}
	}
	cout << apoint <<' ' << bpoint << endl;
	return 0;
}

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

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

int main(){
int a;
int uma;
int ushi;
int b;
int c;
int i;
while (true){
cin >> a;
if (a == 0){ break; }
else{
	while (true){
	if (i<a){
	cin >> b;
	cin >> c;
	if (b>c){
		uma = uma + b + c;
	}
	else if (b == c){
		uma = uma + b;
		ushi = ushi + c;
	}
	else{
	ushi = ushi + b + c;
	}
	i = i + 1;
}if (i == a){ break; }
}
cout << uma << " " << ushi << endl;
uma = 0;
ushi = 0;
i = 0;
}
}
}

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

int main() {
	int n,a,b,pa,pb;
	while(pa=pb=0,cin>>n,n){
		for(;n;--n){
			cin>>a>>b;
			if(a>b)pa+=(a+b);
			else if(a<b)pb+=(a+b);
			else pa+=a,pb+=b;
		}
		cout<<pa<<" "<<pb<<endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
	int n;
	int a,b;
	int sa,sb;//score
	
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a>>b;
		if(a<b){sb+=a+b;}
		else if(a>b){sa+=a+b;}
		else
		{
			sa+=a;
			sb+=b;
		}
	}
	cout<<a<<" "<<b<<"\n";
	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;

int main(){
	while (cin >> n&&n){
		int	suma = 0, sumb = 0;
		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;
	}
}