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>

int main(){
	int i=0,n,a=0,b=0;
	std::cin>>n;
	while(i<n){
		int ca,cb;
		std::cin>>ca>>cb;
		if(ca>cb)a+=ca+cb;
		else if(cb>ca)b+=ca+cb;
		else if(ca==cb)a+=ca,b+=cb;
		i++;
	}
	std::cout<<a<<" "<<b<<std::endl;
	return 0;
}

C++: #pragma GCC optimize("O3")
#pragma GCC target("avx")
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
#define repr(i ,n) for(int i=n;i>(int)(n);--i)
#define rep1(i ,n) for(int i=1;i<=(int)(n);++i)
#define ALL(a) a.begin(), a.end()
#define RSORT(a) sort(ALL(a),greater<>())
#define SORT(a) sort(ALL(a))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define PRINT(x) printf("%d\n",(x));
#define ENDL printf("\n");
using namespace std;
typedef long long int i64;
typedef unsigned long long u64;
template<class T> using V = vector<T>;
using VI = V<int>;
const int INF = 2e9;
const i64 MOD = 1e9 + 7;

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

signed main(){
    int n;
    while( cin >> n && n){
        vector<pair<int,int>> crd(n);
        rep(i ,n) cin >> crd[i].first >> crd[i].second;
        u64 score_A = 0 , score_B = 0;
        rep(i , n){
            if(crd[i].first > crd[i].second) score_A += crd[i].first + crd[i].second;
            else if ( crd[i].first == crd[i].second) { score_A += crd[i].first; score_B += crd[i].second; }
            else if ( crd[i].first < crd[i].second) score_B += crd[i].first +crd[i].second;
        }
        cout << score_A << " " << score_B << endl;
    }
}

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

using namespace std;
int main() {
	int n, a, b,aa=0,bb=0;
	for (;;) {
		cin >> n;
		if (n == 0) return 0;

		for (int i = 0; i < n; i++) {
			cin >> a >> b;
			if (a > b)aa += a + b;
			else if (b > a)bb += a + b;
			else if (a == b) {
				aa += a;
				bb += b;
			}
			
		}
		cout << aa << " " << bb << endl;
		aa = 0; bb = 0;
	}
	return 0;
}

C++: #include<stdio.h>
int main(void){
    int loop,a,b,c=0,d=0;
    scanf("%d",&loop);
    for(;loop--;){
        scanf("%d %d",&a,&b);
        if(a!=b){
            if(a>b){
                c+=a+b;
            }else{
                d+=a+b;
            }
        }else{
            c+=a;
            d+=b;
        }
    }
    printf("%d %d",c,d);
    return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int n;
	int a[10000];
	int b[10000];
	int i;
	int suma,sumb;
	
	scanf("%d",&n);
	while(n!=0){	
		suma=0;
		sumb=0;
		for(i=0;i<n;i++){
			scanf("%d %d",&a[i],&b[i]);
			if(a[i]>b[i]){
				suma=suma+a[i]+b[i];
			}
			else if(a[i]<b[i]){
				sumb=sumb+a[i]+b[i];
			}
			else{
				suma=suma+a[i];
				sumb=sumb+b[i];
			}
		}
		printf("%d %d\n",suma,sumb);
		scanf("%d",&n);
	}
	return 0;
}

C++: #include<stdio.h>
#include<math.h>
#include<algorithm>
#include<cctype>
#include<string.h>
#include <stdlib.h>

#define PI 3.1415926

int main() {
	int n, x, y;
	int a = 0, b = 0;
	for (int i = 1; i <= 5; i++) {
		scanf("%d", &n);
		if (n == 0) {
			break;
		}
		for (int j = 1; j <= n; j++) {
			scanf("%d %d", &x, &y);
			if (x == y) {
				a += x;
				b += y;
			}
			else if (x < y) {
				b += x + y;
			}
			else {
				a += x + y;
			}
		}
		printf("%d %d\n", a, b);
		a = 0;
		b = 0;
	}
	return 0;
}

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

int main() {
    int AsPoint, BsPoint, AsCard, BsCard;
    int key;
    while(true){
        cin >> key;
        AsPoint = BsPoint = 0;
        if(key == 0) return 0;
        while(key != 0) {
            cin >> AsCard;
            cin >> BsCard;
            if(AsCard == BsCard) {
                AsPoint += AsCard;
                BsPoint += BsCard;
                continue;
            }
            AsPoint += (AsCard > BsCard) ? AsCard + BsCard : 0;
            BsPoint += (BsCard > AsCard) ? AsCard + BsCard : 0;
            --key;
        }
        cout << AsPoint << " " << BsPoint << endl;
    }
}

C++: #include<iostream>
#include<vector>
int main() {
	int i = 0;
	std::cin >> i;
	int A = 0, B = 0;
	std::vector<int> a(10000), b(10000);
	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;
	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==max(a,b))x+=a+b;
    else if(b==max(a,b))y+=a+b;
  }
  cout<<x<<" "<<y<<endl;
}

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

int main(){
 int n;
 int Acard,Bcard,Apoint,Bpoint;
 while(true){
  cin>>n;
  if(n==0){
   break;
  }else{
    for(int i=0;i<n;i++){
     cin>>Acard>>Bcard;
     if(Acard>Bcard){
      Apoint+=Acard+Bcard;
     }else if(Acard<Bcard){
      Bpoint+=Acard+Bcard;
     }else{
      Apoint+=Acard;
      Bpoint+=Bcard;
     }
    }
   count<<Apoint<<' '<<Bpoint<<'\n';
  }
 }
 return 0;
}

C++: #include<iostream>
#include<vector>
int main() {
	int vec=0;
	int n;
	int a=0;
	int b=0;
	int game_a, game_b;
	std::vector<int>veca, vecb;
	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 if (game_a == game_b);
				else b += game_a + game_b;
			}
			veca.push_back(a); vecb.push_back(b); a = 0; b = 0;
		}
	}
	for (int i = 0; i < veca.size(); ++i) {
		std::cout << veca[i] <<" "<<vecb[i]<< std::endl;
	}
	return 0;
}

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

C++: #include<cstdio>

using namespace std;

int A=0,B=0;

int main()
{
	int n;
	while(true)
	{
	scanf("%d",&n);
	if(n==0)break;
	for(int i=0;i<n;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		if(a>b)A+=a+b;
		else if(a==b)
		{
			A+=a;
			B+=b;
		}
		else B+=a+b;
	}
	printf("%d %d\n",A,B);
	return 0;
	}
}

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


int main(){
    int N;
    while(scanf("%d",&N),N){
        int A=0,B=0;
        while(N--){
            int a,b;
            scanf("%d%d",&a,&b);
            if(a>b)A+=a+b;
            else if(a<b)B+=a+b;
            else{
                A+=a;
                B+=b;
            }
        }

        printf("%d %d\n",A,B);
    }
    return 0;
}

C++: #include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>

using namespace std;
typedef long long Int;
#define REP(i , x) for(int i = 0 ; i < x ; ++i)
Int Ap, Bp;

int main()
{
	int n;
	int a, b;
	
	cin >> n;
	REP(i, n){
		cin >> a >> b;
		if (a > b){
			Ap += a;
			Ap += b;
		}
		else if(a < b){
			Bp += a;
			Bp += b;
		}
		else{
			Ap += a;
			Bp += b;
		}
	}

	cout << Ap << " " << Bp << endl;
	return 0;

}