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;
cin>>n;
while(n!=0){
	int ap=0,bp=0;
	int a,b;
	for(int k=0;k<n;k++){
		cin>>a>>b;
		if(a>b){
			ap=ap+a+b;
		}
		else if(a<b){
			bp=bp+a+b;
		}
		else{
			ap=ap+a;
			bp=bp+a;
		}
	}
	cout<<ap<<" "<<bp<<endl;
	cin>>n;
}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;

int main(){
  while(scanf("%d",&n),n){
    int a=0,b=0;
    REP(i,n){
      int x,y;
      scanf("%d%d",&x,&y);
      if(x>y)a+=x+y;
      else if(x<y)b+=x+y;
      else a+=x,b+=y;
    }
    printf("%d %d\n",a,b);
  }
  return 0;
}

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

int main() {
  int n;
  while (cin >> n and n != 0) {
    int acard, bcard, ascore = 0, bscore = 0;

    for (int i = 0; i < n; i++) {
      cin >> acard >> bcard;
      
      if (acard > bcard) {
        ascore += acard + bcard;
      } else if (acard < bcard) {
        bscore += acard + bcard;
      } else {
        ascore += acard;
        bscore += bcard;
      }
    }

    cout << ascore << " " << bscore << endl;
  }
}

C++: #include <iostream>

using namespace std;

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

C++: #include <iostream>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)

int main(void){
	int n;
	int a = 0, b = 0;
	cin >> n;
	rep(i, n){
		int x, y;
		cin >> x >> y;
		if(x > y){
			a += x + y;
		}
		if(y > x){
			b += x + y;
		}
		if(y == x){
			a += x;
			b += y;
		}
	}
	cout << a << " " << b << endl;
	return 0;
}

C++: #include <iostream>

void Game(int round, std::istream& in, std::ostream& out)
{
    int scoreA = 0;
    int scoreB = 0;
    for(int i = 0; i < round; ++i){
        int a, b;
        in >> a >> b;
        if(a > b){
            scoreA += a + b;
        }else
        if(a < b){
            scoreB += a + b;
        }else{
            scoreA += a;
            scoreB += b;
        }
    }
    out << scoreA << " " << scoreB << std::endl;
}

int main()
{
    int n;
    std::cin >> n;
    while(n){
        Game(n, std::cin, std::cout);
        std::cin >> n;
    }
    return 0;
}

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

int main(){
    
    while(1)
    {
        int num;
        cin>>num;
        
        if(num == 0)
        {
            break;
        }
        
        vector< int > cardA(num);
        vector< int > cardB(num);
        
        for(int i=0;i<num;++i)
        {
            int pA, pB;
            cin>>pA>>pB;
            cardA[i] = pA;
            cardB[i] = pB;
        }
        
        int pointA = 0;
        int pointB = 0;
        
        for(int i=0;i<um;++i)
        {
            if(cardA[i] ==cardB[i])
            {
                pointA += cardA[i];
                pointB += cardA[i];
            }
            else if(cardA[i] > cardB[i])
            {
                pointA += cardA[i] + cardB[i];
            }
            else
            {
                pointB += cardA[i] + cardB[i];
            }
        }
        
        cout<<pointA<<" "<<pointB<<endl;
    }
    
    return 0;
}

C++: #include <stdio.h>

int main(void)
{
	int ans_a, ans_b;
	int n;
	int a, b;
	
	scanf("%d", &n);
	ans_a = ans_b = 0;
	while (n){
		scanf("%d %d", &a, &b);
		
		if (a > b){
			ans_a += (a + b);
		}
		else if (a < b){
			ans_b += (a + b);
		}
		else {
			ans_a += a;
			ans_b += b;
		}
		
		n--;
	}
	
	printf("%d %d\n", ans_a, ans_b);
	
	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>
using namespace std;

int main()
{	
	while(true){
		int n,a[10000]={},b[10000]={},ascore=0,bscore=0;
		cin>>n;
		if(n==0) break;
		for(int i=0;i<n;i++){
			cin>>a[i];
			cin>>b[i];
			if(a[i]>b[i]){
				ascore+=a[i]+b[i];
			}else if(a[i]<b[i]){
				bscore+=a[i]+b[i];
			}else if(a[i]==b[i]){
				ascore+=a[i];
				bscore+=b[i];
			}
		}
	}
	cout<<ascore<<" "<<bscore<<endl;
	return 0;
}

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

int main(){
  int n,i,a,b;

  while(1){
    int x=0, y=0;
    cin >> n;
    if( n == 0 ) break;
    if( n <= 10000){
      for( 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 <<endl;
  }
  
  return 0 ;
}

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

C++: #include<iostream>

using namespace std;

int main(){

  int n;

  for( ; ; ){

  cin>> n;

  int A,B;

  A=0;
  B=0;

  if(n==0)break;

   for(int i=0;i<n;i++){
 
     int a,b;

     cin>>a>>b;

     if(a>b){
       A=A+a+b;
     }
     if(a<b){
       B=B+a+b;
     }
     if(a==b){
       A=A+a;
       B=B+b;
     }
   }
   cout<<A<<" "<<B<<endl;
  }

  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int maisuu, a[15000], b[15000];
	long long int a_p = 0, b_p = 0;
	cin >> maisuu;
	if (maisuu == 0){
		return 1;
	}
	for (int i = 0; i < maisuu; i++){
		cin >> a[i];
		cin >> b[i];
	}
	for (int i = 0; i < maisuu; i++){
		if (a[i] < b[i]){
			b_p += a[i] + b[i];
		}
		else if (a[i]>b[i]){
			a_p += a[i] + b[i];
		}
		else if (a[i] == b[i]){
			a_p += a[i];
			b_p += b[i];
		}
	}
	cout << a_p << " " << b_p << endl;
	return 0;
}

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

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