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 <bits/stdc++.h>
using namespace std;
 
int main() {
    int n,a,b,countA=0,countB=0;
    cin>>n;
    if(n!=0){
    do{
        for(int i=0;i<n;i++){
            cin>>a>>b;
            if(a>b){
                countA+=(a+b);
            }else if(a<b){
                countB+=(a+b);
            }//a==b
        }
        cout<<countA<<" "<<countB;
        cout<<"\n";
        countA=0,countB=0;
        cin>>n;
        if(n==0)break;
    }while(1);
    }
    cout<<endl;
}

C++: #include<cstdio>

int n;

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

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

int main(){
	int n,a,b,Ares=0,Bres=0;
	while(1){
	cin>>n;
	if(n==0)
		break;
	for(int i=0;i<n;i++){
		cin>>a>>b;
		if(a==b){
			Ares+=a+b;
			Bres+=a+b;
		}else if(a<b){
			Bres+=a+b;
		}else if(a>b){
			Ares+=a+b;
		}
	}
	cout<<Ares<<" "<<Bres<<endl;
	}
}

C++: #define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
typedef pair <int,PP> PPP;

static const double eps = 1e-8;

int main(){
	int n;
	while(~scanf("%d",&n)){
		if(n==0) break;
		int lSum=0,rSum=0;
		for(int i=0;i<n;i++){
			int lhs,rhs;
			scanf("%d %d",&lhs,&rhs);
			if(lhs > rhs) lSum += lhs + rhs;
			else if(lhs < rhs) rSum += lhs + rhs;
			else if(lhs == rhs){
				rSum += rhs;
				lSum += lhs;
			}
		}

		printf("%d %d\n",lSum,rSum);
	}
}

C++: #include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n,a,b,x=0,y=0;
  while(n!=0){
    cin>>n;
    if(n==0)continue;
    rep(i,n){
      cin>>a>>b;
      if(a==b){
	x+=a;
	y+=b;
      }
      else if(a>b)x+=(a+b);
      else if(a<b)y+=(a+b);
    }
    cout<<x<<" "<<y<<endl;
    x=0;
    y=0;
  }
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b,aa=0,ab=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a>>b;
    if(a>b){
      aa+=a+b;
    }
    if(a<b){
      ab+=a+b;
    }
    if(a==b){
      aa+=a;
      ab+=b;
    }
  }
  cout<<aa<<' '<<ab<<endl;
  return(0);
}

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

int main(){
	for (;;){
		int n;
		cin >> n;
		if (n == 0) return 0;

		int p0=0, p1=0;

		for (int i = 0; i < n; ++i){
			int a, b;
			cin >> a >> b;
			if (a>b) p0 += a + b;
			if (a == b){ p0 += a; p1 += a; }
			if (a<b) p1 += a + b;
		}
		cout << p0 << ' ' << p1 << 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 <iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;

int main()
{
    int  a=0,b=0,a1=0,b1=0,i=0,n=0,j=0;
    for(i=1;;i++){
        cin >> n;
        if(n==0)break;
        for(j=0;j<n;j++){
            cin >> a >> b;
            if(a>b){
                a1+=a+b;
            }
            if(a<b){
                b1+=a+b;
            }
            if(a==b){
                a1+=a;
                b1+=b;
            }

        }
        cout << a1 << ' ' << b1 <<endl;
        a1=b1=0;
    }
    //cout << b;
}

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);
		A = 0;
		B = 0;
	}
}

C++: #include <iostream>

using namespace std;

int main(){
  int n,l,r,a,b;
  while(cin>>n,n){
    a=b=0;
    while(n--){
      cin>>l>>r;
      if(l==r){
	a+=l;b+=l;
      }
      else (r<l)?a+=l+r:b+=l+r;
    }
    cout<<a<<' '<<b<<endl;
  }
  return 0;
}

C++: #include <cstdio>
int main(){
 long asum,bsum,a,b,n,i;
 asum=bsum=0;
 scanf("%ld",&n);
 for(i=0;i<n;i++){
  scanf("%ld %ld",&a,&b);
  if (a>b) asum += a+b;
  if (a<b) bsum += a+b;
  if (a==b) { asum += a; bsum += b; }
 };
 printf("%ld %ld\n",asum,bsum);
 return 0;
};

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

int main()
{
  ios::sync_with_stdio(false);
  int n;
  while (cin >> n) {
    if (n == 0)
      break;

    int A = 0, B = 0;
    for (int i = 0; i < n; ++i) {
      int c1, c2;
      cin >> c1 >> c2;
      if (c1 > c2) {
	A += (c1+c2);
      } else if (c1 < c2) {
	B += (c1+c2);
      } else {
	A += c1;
	B += c2;
      }
    }
    cout << A << " " << B << endl;
  }
  return 0;
}

C++: #include <iostream>
using std::cout;
using std::endl;
using std::cin;

int main() {
	while (true) {
		int n;
		cin >> n;
		if (n == 0) {
			break;
		}
		int sa = 0,sb = 0;
		while (n--) {
			int a,b;
			cin >> a >> b;
			if (a > b) {
				sa += a + b;
			} else if (a < b) {
				sb += a + b;
			} else {
				sa += a;
				sb += b;
			}
		}
		cout << sa << " " << sb << endl;
	}
}

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

int main(){
	int n,a,b;
	long suma=0,sumb=0;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a >> b;
		if(a>b) suma+=a+b;
		else if(a<b) sumb+=a+b;
		else{suma+=a;sumb+=b;}
	}
	printf("%ld %ld\n",suma,sumb);
}

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

int main(){
	long long n, x, y, sumx=0, sumy=0;
	cin >> n;

	for(int i=0; i<n; i++){
		x=0,y=0;
		cin >> x >> y;
		if(x > y){
			sumx = sumx + x + y;
		}
		else if(x < y){
			sumy = sumy + x + y;
		}
		else if(x == y){
			sumx = sumx + x;
			sumy = sumy + y;
		}
	}
	
	cout << sumx << " " << sumy  << "\n" << endl;
	return 0;
}

C++: #include<bits/stdc++.h>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
  int n;
  while(1){
    cin>>n;
    if(!n)break;
    int a,b;
    int apoint=0,bpoint=0;
    rep(i,n){
      cin>>a>>b;
      if(a==b){
	apoint+=a;
	bpoint+=b;
      }else if(a>b){
	apoint+=(a+b);
      }else{
	bpoint+=(a+b);
      }
    }
    cout<<apoint<<" "<<bpoint<<endl;
  }
  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;
			bs +=  m;
			}
			else if (n > m) {
				 + m;
			}
			else if (m > n) {
				
			}
		}
		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;
}