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 i, n, pA, pB, tA = 0, tB = 0;
int main(){
while(cin >> n) {
if(n == 0) { break; }
for (i=1; i<=n; i++) {
cin >> pA >> pB;
if (pA > pB) {
tA += pA + pB;
} else {
if (pA < pB) {
tB += pA + pB;
} else {
tA += pA;
tB += pB;
}
}
}
cout << tA << " " << tB << endl;
tA = 0; tB = 0;
}
return 0;
}

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

using namespace std;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		vector<int> A(n);
		vector<int> B(n);
		for(int i = 0; i < n; ++i)
		{
			cin >> A[i] >> B[i];
		}
		int pointA = 0;
		int pointB = 0;
		for(int i = 0; i < n; ++i)
		{
			if(A[i] > B[i])
			{
				pointA += A[i] + B[i];
			}
			else if(A[i] < B[i])
			{
				pointB += A[i] + B[i];
			}
			else
			{
				pointA += A[i];
				pointB += A[i];
			}
		}
		cout << pointA << " " << pointB << endl;
	}
}

int main()
{
	solve();
	return(0);
}

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	int n;
	int resa,resb;
	while(n=in()){
		resa=0;resb=0;
		int a,b;
		int i;
		for(i=0;i<n;i++){
			cin>>a>>b;
			if(a>b)resa+=a+b;
			else if(a<b)resb+=a+b;
			else{resa+=a;resb+=b;}
		}
		cout<<resa<<" "<<resb<<endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

int main(){
    int n;
    scanf("%d", &n);
    vector<int> a(n), b(n);
    for(int i=0;i<n;++i) scanf("%d %d", &a[i],&b[i]);
    int as=0, bs=0;
    for(int i=0;i<n;++i){
        if(a[i]>b[i])as+=a[i]+b[i];
        else if(a[i]<b[i])bs+=a[i]+b[i];
        else {as+=a[i];bs+=b[i];}
    }
    printf("%d %d\n", as,bs);
}

C++: #include <stdio.h>
#include <math.h>
#include <ctype.h>

int main(void)
{
  int i,j,k,l;
  int n,m;
  int a,b;
  int cnt_a,cnt_b;
  while(1) {
	scanf("%d",&n);
	if(n == 0) break;
	cnt_a = cnt_b = 0;
	for(i=0;i<n;i++) {
	  scanf("%d %d",&a,&b);
	  if(a > b) cnt_a += a+b;
	  else if(b > a) cnt_b = a+b;
	  else { 
		cnt_a += a ,cnt_b += b;
	  }
	}
	printf("%d %d\n",cnt_a,cnt_b);
  }
	
  return 0;
}

C++: #include<cstdio>

using namespace std;

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

C++: #include <iostream>

using namespace std;

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

C++: #include <iostream>
using namespace std;
int main(){
    int n;
    while(cin>>n){
        if(n==0)return 0;
        
    int a[n];
    int b[n];
    
    int ansa=0,ansb=0;
    
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
        if(a[i]>b[i]){ansa+=a[i];ansa+=b[i];}
        else if(a[i]<b[i]){ansb+=a[i];ansb+=b[i];}
        else{ansa+=a[i];ansb+=b[i];}
        
    }
        cout<<ansa<<" "<<ansb<<endl;
        
    }
}

C++: #include <iostream>
using namespace std;
int main(){

	int n, a, b, ap = 0, bp = 0, i;

	cin >> n;
	for (i = 0; i < n; i++){
		cin >> a >> b;

		//?????°?????´??°
		if (a > b)
			ap += a + b;
		else if (a < b)
			bp += a + b;
		else{
			ap += a;
			bp += b;
		}
	}

	cout << ap << ' ' << bp << endl;
}

C++: #include <iostream>
using namespace std;
int main(){
  int n,a,b,ap,bp,i;
  while(1){
    cin >> n;
    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<stdio.h>
int main(void)
{
	int a,s,d,f,i,g;
	scanf("%d",&a);
	while(a!=0){
	f=0;
	g=0;
	for(i=1;i<=a;i++){
		scanf("%d %d",&s,&d);
		if(s>d){
			f=f+s+d;
		}
		else if(d>s){
			g=g+s+d;
		}
		else if(d==s){
			g=g+d;
			f=f+s;
		}
	}
	printf("%d %d\n",f,g);
	scanf("%d",&a);
	}
	return 0;
}

C++: #include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <cmath>
#include <string>

using namespace std;





int main()
{
	int n;
	int a, b;
	int A, B;
	
	while (1)
	{
		cin >> n;
		if (n == 0) break;
		
		A = 0;
		B = 0;
		
		for (int i=0; i<n; i++)
		{
			cin >> a >> b;
			
			//cout << "a = " << a << " : b = " << b << "\n";
			
			if (a > b)
			{
				A += a;
			} else if (a < b) {
				B += b;
			} else if (a == b) {
				A += a;
				B += b;
			}
		}
		
		cout << A << " " << B << "\n";
	}
	
	
}

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

int main(){
    int n;

    while(cin >> n, n != 0){
        int a_point = 0, b_point = 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<iostream>
using namespace std;
 
int main(void){
  int n,a,b;
 
  while(cin >> n,n){

    int A=0,B=0;
    for(int i=0;i<n;i++){
      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 <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

int main() {
	int n; 
	while (cin >> n, n) {
		int c1 = 0, c2 = 0;
		rep(i, n) {
			int a, b; cin >> a >> b;
			if (a > b)c1 += a + b;
			else if (a < b)c2 += a + b;
			else { c1 += a; c2 += b; }
		}
		cout << c1 << ' ' << c2 << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<sstream>
#include<cstdlib>

using namespace std;

int main(){
	while(1){
		string str;
		getline(cin,str);
		int n = atoi(str.c_str());
		if(n==0)break;
		int scoreA = 0, scoreB = 0;
		while(n--){
			getline(cin,str)
			stringstream ss(str);
			string tmp;
			getline(ss,tmp,' ');
			int a = atoi(tmp.c_str());
			getline(ss,tmp);
			int b = atoi(tmp.c_str());
			if(a>b)scoreA+=(a+b);
			else scoreB+=(a+b);
		}
		cout<<scoreA<<" "<<scoreB<<endl;
	}
	return 0;
}