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 <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <ctime>
#include <vector>
#include <stack>

using namespace std;
////////////////*My library*////////////////////////
#define rep_to(a,i,n) for(int i=a;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_r(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) cout<<x<<endl
#define s_1(x) cin>>x
#define s_2(x,y) cin>>x>>y
////////////////////////////////////////////////////

////////////////////////
/*prime()*/
/*primecount()*/
/*sort()*/
/*imos???*/
/*????????¢?´¢*/
/*??±???????????¢?´¢*/
/*???????¨???????*/
///////////////////////

int main()
{
	int N;
	int a,b;
	while(1)
	{
		s_1(N);
		if(N==0)break;

		int sumA=0,sumB=0;
		rep(i,N)
		{
			s_2(a,b);
			if(a>b)sumA+=(a+b);
			else if(a<b) sumB+=(a+b);
			else 
			{
				sumA+=a;
				sumB+=b;
			}
		}
		cout<<sumA<<" "<<sumB<<endl;
	}

	return 0;
}

C++: #include <stdio.h>

main()
{
	int A,B,a,b,i,n;
	while(1)
	while(scanf("%d",&n)){
	if(n==0) break;
	A=0;
	B=0;
		for(i=1;i<n+1;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 <iostream>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main() {
    int n, a, b;
    while (cin >> n) {
        int apt = 0, bpt = 0;
        rep(i, n) {
            cin >> a >> b;
            if (a > b) {
                apt += a + b;
            }
            else if (a < b) {
                bpt += a + b;
            }
            else {
                apt += a;
                bpt += b;
            }
        }
        cout << apt << " " << bpt << endl;
    }
    return 0;
}

C++: #include <iostream>

int main(){
	int i,n,a,b,apoint=0,bpoint=0;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> a;
		cin >> b;
		if(a>b){apoint+=a;apoint+=b;}
		else if(b>a){bpoint+=a;bpoint+=b}
		else {apoint+=a;bpoint+=b}
	}
	cout << apoint <<' ' << bpoint << endl;
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){ 
	int n;
	int a[3]={0};
	int b[3]={0};
	int A,B;
	for(int i=0;i<5;i++){
                cin>>n;
		if(n==0){break;}
		for(int j=0;j<n;j++){
			if(a[j]>b[j]){
				A+=a[j]+b[j];
			}
			else if(a[j]<b[j]){
				B+=a[j]+b[j];
			}
		}
		cout<<A<<" "<<B<<endl;
	}
	
	return 0;
}

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

int main(){

  std::vector<std::pair<int,int> > data;

  char buf[100];
  int n;

  std::cin >> buf;
  n = atoi(buf);

  char a[100];
  char b[100];

  for (int i=0; i<n ; i++){
    std::cin >> a;
    std::cin >> b;
    data.push_back(std::pair<int,int>(atoi(a),atoi(b)));
  }

  int you = 0;
  int opp = 0;

  for (std::vector<std::pair<int,int> >::iterator it = data.begin(); it != data.end(); it++){
    int yv = (*it).first;
    int ov = (*it).second;
    if (yv > ov ){
      you += yv+ov;
    }else if (yv < ov){
      opp += yv+ov;
    }else{
      you += yv;
      opp += ov;
    }
  }

  std::cout << you << " " << opp << std::endl;

  return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
  int a,b,x;
  while(cin >> x && x){
    a = b = 0;
    while(x--){
      int in1,in2;
      cin >> in1 >> in2;
      if(in1 > in2){
	a += in1+in2;
      }else if(in1 == in2){
	a += in1;
	b += in2;
      }else{
	b += in1+in2;
      }
    }
    cout << a << " " << b << endl;
  }
  return 0;
}

C++: #include<stdio.h>
int main()
{
  int a,b,at,bt,k,i;
  scanf("%d",&k);
  at=0;
  bt=0;
  for(i=0;i<k;i++){
    scanf("%d %d",&a,&b);
    if(a>b)at+=a+b;
    else if(b>a)bt+=a+b;
    else {
      bt+=b;
      at+=a;
    }
  }
  printf("%d %d\n",at,bt);
  return 0;
}

C++: #include<iostream>
int score_a,score_b;
void main(void)
{
using namespace std;
int n,data_a,data_b;
while(1)
{
cin>>n;
if(!n)break;
score_a=0;
score_b=0;
for(;n>0;n--){
cin>>data_a;
cin>>data_b;
if(data_a>data_b){
score_a+=(data_a+data_b);
}else if(data_a<data_b){
score_b+=(data_a+data_b);
}else{
score_a+=data_a;
score_b+=data_b;
}
}
cout<<score_a<<" "<<score_b<<endl;
}
}

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

int main() {
    int t;
    cin >> t;
    for(int i = 0;i < t;i++){
        int n;
        cin >> n;
        int a,b,sum1 = 0,sum2 = 0;
        for(int j = 0;j < n;j++){
            cin >> a >> b;
            sum1 += a;
            sum2 += b;
        }
        cout << sum1 << " " << sum2 << endl;
    }
	return 0;
}

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

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

C++: #include<iostream>
using namespace std;
 
int main(){
	int a;
	int uma;
	int ushi;
	int b;
	int c;

	cin >> a;
	for (int i; i < a; i++){
		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;
		}
	}
	cout << uma <<" "<<ushi<<endl;

}

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

int n, a, b, sa, sb;

int main(){
  for(;;){
    cin >> n;
      if(n == 0){
        break;
      }else{
        for(int i = 0; i < n; i++){
          cin >> a >> b;
          if(a < b){
            sb += a + b;
          }else if(a > b){
            sa += b + a;
          }else{
            sa += a;
            sb += b;
          }
        }
        cout << a << " " << b;
      }
    }
  return 0;
}

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;}
		if(x<y) {b+=x+y;}
		if(x==y){
			a+=x;
			b+=y;
		}
	}
	printf("%lld %lld\n",a,b);
	return 0;
}

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

struct player{
    int point = 0;
    int card[10000];
private:


};

int main()
{
    int loop;
    player a, b;
    cin >> loop;
    for(int c = 0; c < loop; c++)
    {
        cin >> a.card[c];
        cin >> b.card[c];
    }

    for(int c = 0; c < loop; c++)
    {
        if(a.card[c] < b.card[c]) b.point += a.card[c] + b.card[c];
        if(a.card[c] == b.card[c]) a.point += a.card[c], b.point +=b.card[c];
        if(a.card[c] > b.card[c]) a.point += a.card[c] + b.card[c];
    }
    cout << a.point << " " << b.point << endl;
    return EXIT_SUCCESS;
}

C++: #include <iostream>

using namespace std;

int main(int argc, char **argv)
{
	int n, s, t, a, b;
	
	while(1){
		cin >> n;
		if(n == 0){
			break;
		}
		a = b = 0;
		for(int i = 0; i < n; i++){
			cin >> s >> t;
			if(s > t){
				a += (s+t);
			} else if(s < t){
				b += (s+t);
			} else {
				a += s;
				b += t;
			}
		}
		
		cout << a << " " << b << endl;
	}
	
	return 0;
}

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

return 0;
}