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 <stdio.h>

int main(){
	int a[10000], b[10000];
	int sumA, sumB;
	int n;
	int i;
	
	sumA = 0;
	sumB = 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++){
			printf("%d %d\n", a[i], b[i]);
		}
		*/
		
		for(i=0;i<n;i++){
			if(a[i] > b[i]) sumA += a[i]+b[i];
			if(a[i] < b[i]) sumB += a[i]+b[i];
			if(a[i] == b[i]){
				sumA += a[i];
				sumB += b[i];
			}
		}
		
		printf("%d %d\n", sumA, sumB);
		
		sumA = 0;
		sumB = 0;
		
	};
	
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
using namespace std;
int main(){
	
	int n;
	
	while(cin>>n,n!=0){
	int A=0,B=0;
	vector<int>a(n);
	vector<int>b(n);
	
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
		if(a[i]>b[i])
			A+=a[i]+b[i];
		else if(b[i]>a[i])
			B+=a[i]+b[i];
		else{
			A+=a[i];
			B+=b[i];
		}
	}
	cout<<A<<" "<<B<<endl;
	}
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    int suma=0;
    int sumb=0;
    rep(i,n){
      int a,b;
      cin>>a>>b;
      if(a<b)
        sumb+=a+b;
      else if(a>b)
        suma+=a+b;
      else{
        suma+=a;
        sumb+=b;
      }
    }
    cout<<suma<<" "<<sumb<<endl;
  }
}

C++: #include<cstdio>
#include<iostream>
using namespace std;
int main()
{
    int n;
    while(cin>>n)
    {
        if(n==0)break;
        int a,b;
        int as=0,bs=0;
        for(int kk=0;kk<n;kk++)
        {
            cin>>a>>b;
            if(a>b)as+=a+b;
            else if(a<b)bs+=a+b;
            else if(a==b)
            {
                as+=a;
                bs+=b;
            }
        }
            cout<<as<<" "<<bs<<endl;
    }
    return 0;
}

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

int main(){
	int a=0,b=0;
	int na,nb;
	int nc;
	cin>>nc;
	if(nc==0) return 0;
	for(int i=0;i<nc;i++){
		cin>>na>>nb;
		if(na>nb) a+=(na+nb);
		else if(na<nb) b+=(na+nb);
		else {a+=na;b+=nb;}
	}
	cout<<a<<" "<<b<<endl;
	return 0;
}

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

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

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

int main() {
	int n, a, b, temp_a, temp_b;	
	while (cin >> n) {
		a = 0; b = 0; if (n == 0) break;
		for (int i = 0; i < n; i++) {
			cin >> temp_a >> temp_b;
			if (temp_a == temp_b) {
				a = a + temp_a; b = b + temp_b;
			}
			else {
				a = a + (temp_a > temp_b ? temp_a + temp_b : 0);
				b = b + (temp_a < temp_b ? temp_a + temp_b : 0);
			}
		}
		cout << a << " " << b << endl;
	}
	return 0;
}

C++: #include<cstdio>
int main(){
    for(;;){
        int ai,bi,as=0,bs=0,n;
        scanf("%d",&n);
        if(n==0) break;
        for(int i=0;i<n;i++){
            scanf("%d%d",&ai,&bi);
            if(ai>bi) as+=ai+bi;
            else if(ai<bi) bs+=ai+bi;
            else{
                as+=ai;
                bs+=bi;
            }
        }
        printf("%d %d\n",as,bs);
    }
}

C++: #include<iostream>

using namespace std;

int main() {
	int n;
	int a, b;
	int Sa = 0, Sb = 0;
	
	while(1) {
		cin >> n;
		if(!n) break;
		Sa = Sb = 0;
		for( int i=0; i<n; i++) {
			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;
	}
	
	return 0;
}

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

int main(){
	int a;
	int uma;
	int ushi;
	int b;
	int c;
	int i;
	while (true){
		cin >> a;
		if (a == 0){ break; }
		else{
			while (true){
				if (i<a){
					cin >> b >> c;
					if (b>c){
						uma = uma + b + c;
					}
					if (b == c){
						uma = uma + b;
						ushi = ushi + c;
					}
					else{
						ushi = ushi + b + c;
					}
					i++;
				}if (i == a){ break; }
			}
			cout << uma << " " << ushi << endl;
			uma = 0;
			ushi = 0;
			i = 0;
		}
	}
}

C++: #include<stdio.h>

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

C++: #include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
	int n;
	int a[10000],b[10000];
	
	while(cin>>n && n!=0){
		int point_a=0;
		int point_b=0;

		for(int i=0;i<n;i++){
			cin>>a[i]>>b[i];
			if(a[i] > b[i]){
				point_a+=(a[i] + b[i]);
			}else if(a[i] == b[i]){
				point_a+=a[i];
				point_b+=b[i];
			}else{
				point_b+=(a[i] + b[i]);
			}
		}
		cout<<point_a<<" "<<point_b<<endl;
	}
	return 0;
}

C++: //============================================================================
// Name        : svdzva.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
#include<algorithm>
using namespace std;

int main() {
	int n, play1 = 0, play2 = 0, card1[10000], card2[10000];
	while (true) {
		cin >> n;
		if(n == 0)break;
		for (int i = 0; i < n; i++) {
			cin >> card1[i] >> card2[i];
			if (card1[i] > card2[i]) {
				play1 = play1 + card1[i] + card2[i];
			} else if (card1[i] < card2[i]) {
				play2 = play2 + card2[i] + card1[i];
			} else {
				play1 = play1 + card1[i];
				play2 = play2 + card2[i];
			}
		}
	}
	cout << play1 << " " << play2 << endl;
	return 0;
}

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