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, i,A,B, resa =0, resb =0;
    while(cin >> n,n){
        for(i=0;i<n;i++){
           　cin >> A >> B;
             (A > B)? resa +=A:resb+=B;
             if(A==B) {resa += A; resb +=B;};
        }
    cout << resa << " " << resb << endl;
    }
}

C++: #include<stdio.h>
#include<iostream>
using namespace std;
int main(){
int card[100],i,j,a=0,b=0,c=1,n;
cin>>n;
while(n!=0){
for(i=0;i<2*n;i++){
cin>>card[i];
}
for(i=0;i<2*n;i=i+2){
if(card[i]>card[c]){
a=a+card[i]+card[c];
}
else if (card[i]==card[c]){
a=a+card[i];
b=b+card[c];
}
else{
b=b+card[i]+card[c];
}
c=c+2;
}
cout<<a<<" "<<b<<endl;
c=1;
a=0;
b=0;
cin>>n;
}
return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
typedef long long int ll;

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

C++: //
//  main.cpp
//  program
//
//  Created by h3032906 on 2016/11/24.
//  Copyright ?? 2016??´ h3032906. All rights reserved.
//

#include <iostream>

int main(int argc, const char * argv[]) {

    int n, a, b;
    int at = 0;
    int bt = 0;
    for( ; ; ){
        std::cin >> n;
        if(n == 0){
            break;
        }
        for(int i = 0; i < n; i++){
            std::cin >> a >> b;
            if(a > b){
                at = at + a + b;
            }
            else if(b > a){
                bt = bt + a + b;
            }
            else {
                at = at + a;
                bt = bt + b;
            }
        }
        std::cout << at << bt << std::endl;
        at = 0;
        bt = 0;
    }
    return 0;
}

C++: #include <stdio.h>

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

C++: #include <iostream>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(c) (c).begin(),(c).end()
int main(){
	while(true){
		int n,a=0,b=0;
		cin >> n;
		if(!n) break;
		rep(i,n){
			int p,q;
			cin >> p >> q;
			if(p>q) a+=(p+q);
			else if(p<q) b+=(p+q);
			else{
				a+=p;
				b+=p;
			}
		}
		cout << a << " " << b << endl;
	}
	return 0;
}

C++: #include <cstdio>
int main() {
	int n,A,B,a,b;
	while(scanf("%d",&n),n) {
		A=B=0;
		for(int i=0;i<n;i++) {
			scanf("%d %d",&a,&b);
			if(a>b)A+=a+b;
			else if(a<b)B+=a+b;
			else A+=a,B+=b;
		}
		printf("%d %d\n",A,B);
	}
}

C++: #include<stdio.h>


int main(){
	int n;
	int a=0,b=0;
	int apoint=0,bpoint=0;
	int i;

	scanf("%d",&n);

	while(n!=0){
		for(i=0;i<n;i++){
			scanf("%d %d",&a,&b);
			if(a<b){
				bpoint = bpoint + a + b;
			}if(a>b){
				apoint = apoint + a + b;
			}if(a==b){
				apoint= apoint + a;
				bpoint= bpoint + b;
			}
		}		
		printf("%d %d",apoint,bpoint);
		apoint=0;
		bpoint=0;
		scanf("%d",&n);
	}
}

C++: #include <cstdio>
using namespace std;
int main()
{
	long long int a=0,b=0,n,x,y;
	scanf("%lld",&n);
	for(long long int i=0;i<n;i++){
		scanf("%lld %lld",&x,&y);
		if(x>y) {a+=x+y;}
		else if(x<y) {b+=x+y;}
		else{
			a+=x;
			b+=y;
		}
	}
	printf("%lld %lld\n",a,b);
	return 0;
}

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 sumb+=a+b;
	}
	printf("%ld %ld\n",suma,sumb);
}

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

C++: #include<stdio.h>

int main(){
	int n;
	int A=0;
	int B=0;
	int i=0;
	while(1){
	A=0;
	B=0;
	scanf("%d", &n);
	if(n==0){
	return 0;
	}
	int x[10000];
	int y[10000];
	i=0;
	while(i<n){
	scanf("%d", &x[i]);
	if(0>x[i] || 9<x[i]){
	return 0;
	}
	scanf("%d", &y[i]);
	if(0>y[i] || 9<y[i]){
	return 0;
	}
	++i;
}
	i=0;
	while(i<n){
	if(x[i]>y[i]){
	A=A+x[i]+y[i];
}else {
	if(x[i]<y[i]){
	B=B+x[i]+y[i];
}else{
	A=A+x[i];
	B=B+y[i];
			}
		}
	++i;
	}
	printf("%d %d\n", A, B);
	}
}

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

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

C++: #include<iostream>
using namespace std;
int n[10000000],s1,s2;
int main(){
int p,a,b;
cin>>p;
for(int i=0;i<p;i++){
cin>>a>>b;
if(a>b){s1+=a+b;}
else if(b>a){s2+=a+b;}
else{s1+=a;s2+=b;
}
cout<<s1<<' '<<s2<<endl
}

C++: #include<iostream>
using namespace std;
static const int N = 10000;

int main() {
	int n;
	int i;
	int A[N];
	int B[N];
	int score_A = 0;
	int score_B = 0;

	while (1) {
		cin >> n;

		if (n == 0) break;

		for (i = 0; i < n; i++) {
			cin >> A[i];
			cin >> B[i];
		}

		for (i = 0; i < n; i++) {
			if (A[i] > B[i]) {
				score_A += A[i] + B[i];
			}
			else if (A[i] < B[i]) {
				score_B += A[i] + B[i];
			}
			else if (A[i] = B[i]) {
				score_A += A[i];
				score_B += B[i];
			}
		}

		cout << score_A << " " << score_B << endl;

		for (i = 0; i < n; i++) {
			score_A = 0;
			score_B = 0;
		}
	}
	return 0;
}

C++: #include <cstdio>

int main(){
	int a, b, c;
	int n_a[a];
	int n_b[a];
	scanf("%d", a);
	for(int i=0; i<a; i++){
		scanf("%d %d", n_a[i], n_b[i]);
	}
	for(int i=0; i<a; i++){
		if(n_a[i] > n_b[i]){
			b += n_a[i]+n_b[i];
		}else if(n_a[i] < n_b[i]){
			c += n_a[i]+n_b[i];
		}else if(n_a[i] == n_b[i]){
			b += n_a[i];
			c += n_b[i];
		}
	}
	printf("%d %d", b, c);
	return 0;
}

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

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