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>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()

using namespace std;

typedef pair<int, int> pii;
typedef unsigned long long ull;

int main(void){
    for(int n, a, b, sa = 0, sb = 0; cin >> n, n; cout << sa << " " << sb << endl, sa = sb = 0)
        while(n --){
            cin >> a >> b;
            int res = a - b;
            sa += (!res) ? a:(res > 0) ? a + b:0;
            sb += (!res) ? b:(res < 0) ? a + b:0;
        }

    return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(){
	int n;
	vector< vector<int> > a, b;

	int k = 1;
	do{

		cin >> n;
		a.resize(k);
		b.resize(k);

		//cout << a.size() << endl;

		if(n != 0)
		{
			for(int i = 0; i < n; ++i)
			{
				int workA, workB;
				cin >> workA >> workB;
				a[k - 1].push_back(workA);
				//cout << a[k - 1][i] << endl;
				b[k - 1].push_back(workB);
				//cout << a[k - 1][i] << endl;
			}
		}

		k++;
		//cout << "k = " << k << endl;
	}while(n != 0);

	for (int i = 0; i < a.size() - 1; ++i)
	{
		int aRes = 0, bRes = 0;
		for (int j = 0; j < a[i].size(); ++j)
		{
			if(a[i][j] > b[i][j])
			{
				aRes += (a[i][j] + b[i][j]);
			}
			else if(a[i][j] < b[i][j])
			{
				bRes += (a[i][j] + b[i][j]);
			}
			else
			{
				aRes += a[i][j];
				bRes += b[i][j];
			}
		}
		cout << aRes << " " << bRes << endl;
	}

}

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

int main(){
 int n;
 int Acard,Bcard,Apoint,Bpoint;
 while(true){
  cin>>n;
  if(n==0){
   break;
  }else{
    for(int i=0;i<n;i++){
     cin>>Acard>>Bcard;
     if(Acard>Bcard){
      Apoint+=Acard+Bcard;
     }else if(Acard<Bcard){
      Bpoint+=Acard+Bcard;
     }else{
      Apoint+=Acard;
      Bpoint+=Bcard;
     }
    }
   count<<Apoint<<' '<<Bpoint<<'\n';
  }
 }
 return 0;
}

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

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

C++: #include <iostream>

using namespace std;

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

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

int main(){
	int match;
	while(1){
		cin >> match;
		if(match == 0)break;
		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 main(){
    int n=-1;
    int a,b;
    while(cin>>n,n!=0){
       
        int sumA = 0;
        int sumB = 0;
        
        for(int i=0;i<n;i++){
            cin >> a >> b;
        
            if(a>b){
                sumA = sumA+a+b;
            }else if(a==b){
                sumA +=a;
                sumB +=a;
            }else if(b>a){
                sumB = sumB+a+b;
            }      
        }
        cout << sumA << " " << sumB << endl;
    }

    return 0;
}

C++: #include <cstdio>

using namespace std;

int main()
{
	int n;
	int a, b;
	int a_s, b_s;
	
	while (scanf("%d", &n), n != 0){
		a_s = b_s = 0;
		
		while (n != 0){
		scanf("%d %d", &a, &b);
		
		if (a > b) a_s += a + b;
		else if (a < b) b_s += b + a;
		else {
			a_s += a;
			b_s += b;
		}
		n--;
		}
		
		printf("%d %d\n", a_s, b_s);
	}
}

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

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

int main(){
  int n;
  for(;;){
    cin >> n;
    if(!n) { break; }
    int a, b;
    int asum = 0, bsum = 0;
    for(int i = 0; i < n; i++) {
      cin >> a >> b;
      if(a > b){
	asum+=a+b;
      } else if(a < b) {
	bsum+=a+b;
      } else {
	asum+=a;
	bsum+=b;
      }
    }
    cout << asum << " " << bsum << endl;
  }
  return 0;
}

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

C++: #include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 

using namespace std;

void main()
{
	int n,ca,cb,A,B;

	cin>>n;
	while(n>0){
		ca=cb=A=B=0;
		for(int i=0;i<n;i++){
			cin>>ca>>cb;
			if(ca>cb) A+=ca+cb;
			else if(cb>ca) B+=ca+cb;
			else{A+=ca;B+=cb;}
		}
		cout<<A<<" "<<B<<endl;
		cin>>n;
	}

}

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<iostream>
using namespace std;
int main(){
	int a,b,n,ansa=0,ansb=0;

	for(;;){
		cin>>n;
		if(n==0)break;
		ansa=0;
		ansb=0;
		for(int i=0;i<n;i++){
			cin>>a>>b;
			if(a>b){
				ansa=ansa+a+b;
			}
			else if(a<b){
				ansb=ansb+a+b;
			}
			else if(a==b){
				ansa=ansa+a;
				ansb=ansb+b;
			}
		}
		cout<<ansa<<" "<<ansb<<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;
					cin >> 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;
		}
	}
}