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 <cstdio>
using namespace std;

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

C++: #include <stdio.h>
 
int main(){
int n,a=0,b=0;
scanf("%d",&n);
while(n){
int aa,bb;
for(int i=n;i>0;i--){
scanf("%d %d",&aa,&bb);
if(aa>bb){
a+=aa+bb;
}else if(aa<bb){
b+=aa+bb;
}else{
a+=aa;
b+=bb;
}
}
scanf("%d",&n);
}
}

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

int main() {
    int n, a, b;
    while (cin >> n, n) {
        int pa = 0, pb = 0;
        for (int i=0; i<n; ++i) {
            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 A = 0, B = 0, j, as, bs;

int main(){
    cin >> j;
    for(int i = 0; i < j; i++){
        cin >> as >> bs;
        if(as > bs){
            A += as + bs;
        }else if(as < bs){
            B += as + bs;
        }else{
            A += as;
            B += bs;
        }
    }
    cout << A << " " << B << endl;
    return 0;
}

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

int main(void){
  int a,b;
  int n;
  while(cin>>n,n){

    a = b = 0;
  while(n--){
    int c,d;
    cin>>c>>d;
    if(c==d){
      a += c ;
      b += c ;
    }else if(c>d)
      a += c + d;
    else
      b += c + d; 
  }
  cout<< a << " " << b << endl;
  }
}

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

int main(){
int a,b,c;
while(scanf("%d",&c),c){
	a=b=0;
	for(int d=0;d<c;d++){
	int e,f;
	scanf("%d%d",&e,&f);
	if(e>f)a+=e+f;
	else if(e<f)b+=e+f;
	else {a+=e;b+=f;}
}
printf("%d %d\n",a,b);
}
}

C++: #include <iostream>
using namespace std;
int main(){
	int pa=0, pb=0;

	int n;

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

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

int main()
{
  while(1){
    int n;
    cin>>n;

    if(n){
      int a[10000];
      int b[10000];

      for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
      }

      int ap=0,bp=0;
      
      for(int i=0;i<n;i++){
		if(a[i]>b[i]){ap+=a[i]+b[i];}
		else if(a[i]<b[i]){bp+=a[i]+b[i];}
		else{ap+=a[i];bp+=b[i];}
      }
      
      cout<<ap<<" "<<bp<<endl;
    }
    else{break;}
  }
  return 0;
}

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

int main() {

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

    while (cin >> n, n) {
        ap = 0;
        bp = 0;

        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;

        return 0;

    }
}

C++: #include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



int n, a, b;

int main() {
    while (cin >> n) {
        if (n == 0) break;
        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 <stdio.h>

int N ;
int a ;
int b ;
int point[2] ;

void init ( ) ;

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

void init ( )
{
	point[0] = point[1] = 0 ;
}

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