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, b, as = 0, bs = 0,  n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d %d", &a, &b);
		if(a > b){
			as += a + b;
		}else if(a < b){
			bs += a + b;
		}else{
			as += a;
			bs += b;
		}
		printf("%d %d\n", as, bs);
		return 0;
	}
}

C++: #include<iostream>

int main(){
	int i=0,n,a=0,b=0;
	std::cin>>n;
	while(i<n){
		int ca,cb;
		std::cin>>ca>>cb;
		if(ca>cb)a+=ca+cb;
		else if(cb>ca)b+=ca+cb;
		else if(ca==cb)a+=ca,b+=cb;
		i++;
	}
	std::cout<<a<<" "<<b<<std::endl;
	return 0;
}

C++: #include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int a[200000];
int b[200000];
int main(){
    while(1){
    int n;
    scanf("%d",&n);
    if(n == 0)
        break;
    REP(i,n)
        scanf("%d%d",a + i,b + i);

    int ap = 0,bp = 0;

    REP(i,n){
        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];
        }
    }
    printf("%d %d\n",ap,bp);
    }
    return 0;
}

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

int main(){
	int n,a,b;
	long suma=0,sumb=0;
	do{
		cin >> n;
		for(int i=0;i<n;i++){
			cin >> a >> b;
			if(a>b) suma+=a+b;
			else if(a<b) sumb+=a+b;
			else{suma+=a;sumb+=b;}
		printf("%ld %ld\n",suma,sumb);
	while(n!=0);
}

C++: #include <iostream>

using namespace std;
int main()
{
    int loop;
    cin >> loop;
    int p1=0,p2=0;
    while(loop--)
    {
        int a,b;
        cin >> a >> b ;
        if(a > b) {
            p1 = p1 + a + b;
        }else if(a==b) {
            p1 += a;
            p2 += b;
        }
        else {
            p2 = p2 + a + b;
        }
    }
    cout << p1 << " " << p2 << endl;
    return 0;
}

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

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

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

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

int n;

void solve() {
  int a = 0, b = 0;
  rep(i,n) {
    int ta, tb; cin>>ta>>tb;
    if (ta > tb) a += ta + tb;
    else if (ta < tb) b += ta + tb;
    else a += ta, b += tb;
  }
  cout<<a<<" "<<b<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>n, n) {
    solve();
  }
  return 0;
}

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

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

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;
		
	};
	
	return 0;
}

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

int main()
{
	int a;
	int r, l;

	while (cin >> a && (a != 0)){
		int rsum, lsum;
		rsum = 0;
		lsum = 0;
		for (int i = a; i > 0; i--){

			cin >> r;
			cin >> l;
			if (r > l){
				rsum += r + l;
			}
			else if (l > r){
				lsum += r + l;
			}
			else{
				rsum += r;
				lsum += l;
			}
		}
		cout << rsum << ' ' << lsum << endl;
	} 
}

C++: #include<cstdio>
#include<algorithm>
#include<cmath>

using namespace std;

int main(){
        int a[1000] = {0};
        int b[1000] = {0};
        int n, i, pa, pb;
        while(true){
                pa = pb = 0;
                scanf("%d", &n);
                if(n == 0)
                        return 0;
                for(i = 0; i < n; i++){
                        scanf("%d%d", &a[i], &b[i]);
                        if(a[i] > b[i])
                                pa += a[i] + b[i];
                        else if(b[i] > a[i])
                                pb += a[i] + b[i];
                        else if(a[i] = b[i]){
                                pa += a[i];
                                pb += b[i];
                        }
                }
                printf("%d %d\n", pa, pb);
        }
        return 0;
}

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

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

using namespace std;

int n;

int main(){
	while(1){
		cin >> n;
		if(!n){
			break;
		}
		int s = 0, p = 0;
		rep(i, n){
			int a, b;
			cin >> a >> b;
			s += (a + b);
			if(a >= b){
				p += a > b ? a + b : a; 
			}
		}
		cout << p << ' ' << s - p << endl;
	}
	return 0;
}

C++: //============================================================================
// Name        : svdzva.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
using namespace std;
int main() {
	while (true) {
		int n, play1 = 0, play2 = 0, card1[10000], card2[10000];
		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;
}