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 <cstdio>

int n,an,bn,i,j;
int a[10000],b[10000];
int main (){
	n=1;
	while(n){
		scanf("%d\n",&n);
		an=0;
		bn=0;
	for (i=0;i<n;i++){
		scanf("%d %d",&a[i],&b[i]);
	}
	for(j=0;j<n;j++){
		if(a[j]>b[j]) an=an+(a[j]+b[j]);
		else if(a[j]<b[j]) bn=bn+(a[j]+b[j]);
		else if (a[j]==b[j]) { 
			an=an+a[j];
			bn=bn+b[j];
		}
	}
	printf("%d %d\n",an,bn);
	}
	return 0;
}

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

#define REP(i,n) for(int i=0; i<n; i++)
#define FOR(i,a,b) for(int i=a; i<=b; i++)
#define N 10000


using namespace std;

int main(void){
    int a,b;
    int n;
    
    while (cin>>n && n){
        int s = 0 , t = 0;
        REP(i,n){
            cin >> a >> b;
            if (a>b)
                s += (a+b);
            else if (a<b)
                t += (a+b);
            else{
                s += a;
                t += b;
            }
        }
        cout << s << " " << t << endl;
    }
    
    return 0;
}

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

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

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<string>

using namespace std;

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

int main(){
	int n;
	scanf("%d",&n);
	
	int a=0,b=0;
	rep(i,n){
		int f,g;
		scanf("%d%d",&f,&g);
		
		if(f<g){
			a+=f+g;
		}
		if(f>g){
			b+=f+g;
		}
		if(f==g){
			a+=f;
			b+=g;
		}
	}
	printf("%d %d\n",b,a);
}

C++: #include <iostream>
using namespace std;
int main(){
	int n , i , j ;
	int total , result ;
	int a[10001] , b[10001];
	while(1){
		total =0 ;
		result = 0;
		cin >> n ;
		if( n==0 ) break;
		for( i=1 ; i<=n ; i++ ){
			cin >> a[i] >> b[i] ;
			if( a[i] > b[i] )
				total += a[i] + b[i];
			else if( a[i] < b[i] )
				result += a[i] + b[i];
			else {
				result += b[i];
				total += a[i];
			}
			cout << total <<" "<<result<<endl;
		}
	}
}

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

int main() {
    while (true) {
        int n;
        cin >> n;
        if (n==0) {
            break;
        }
        int PlayerA=0;
        int PlayerB=0;
        while (n--) {
            int scoreA;
            int scoreB;
            cin >> scoreA >> scoreB;
            if (scoreA>scoreB) {
                PlayerA+=scoreA+scoreB;
            } else if (scoreA<scoreB) {
                PlayerB+=scoreA+scoreB;
            } else {
                PlayerA+=scoreA;
                PlayerB+=scoreB;
            }
        }
        printf("%d %d\n",PlayerA,PlayerB);
    }
    return 0;
    
}

C++: #include <iostream>
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;
while(cin>>n){
int a[10000]={},b[10000]={};
int ap=0,bp=0;
	for(int i=0;i<n;i++){
	cin>>a[n]>>b[n];
	if(a[n]>b[n]){
		ap+=a[n]+b[n];
	}else if(a[n]<b[n]){
		bp+=a[n]+b[n];
	}else{
		ap+=a[n];
		bp+=b[n];
	}
	cout<<ap<<" "<<bp<<endl;
}

return 0;
}

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

C++: #include<iostream>
#include<vector>
int main() {
	int vec=0;
	int n;
	int a=0;
	int b=0;
	int game_a, game_b;
	std::vector<int>veca, vecb;
	while (1) {
		std::cin >> n;
		if (n == 0)break;
		else {
			for (int i = 0; i < n; ++i) {
				std::cin >> game_a>>game_b;
				if (game_a > game_b)a += game_a + game_b;
				else b += game_a + game_b;
			}
			veca.push_back(a); vecb.push_back(b); a = 0; b = 0;
		}
	}
	for (int i = 0; i < veca.size(); ++i) {
		std::cout << veca[i] <<" "<<vecb[i]<< std::endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
  int n,a,b,A,B;
  cin>>n;
  A=B=0;
  while(cin>>a>>b){
    if(a>b){
      A+=a+b;
    }else if(a<b){
      B+=a+b;
    }else{
      A+=a;
      B+=b;
    }
  }
  cout<<A<<" "<<B<<endl;
}

C++: #include <stdio.h>
int main(){
int n,l,r,a,b;
while(1){
scanf("%d",&n);
if(n==0)return 0;
a=b=0;
while(n--){
scanf("%d%d",&l,&r);
if(l>=r)a+=l+r;
if(r>=l)b+=l+r;
}
printf("%d %d\n",a,b);
}
}

C++: #include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n,a,b,countA=0,countB=0;
    cin>>n;
    if(n!=0){
    do{
        for(int i=0;i<n;i++){
            cin>>a>>b;
            if(a>b){
                countA+=(a+b);
            }else if(a<b){
                countB+=(a+b);
            }//a==b
        }
        cout<<countA<<" "<<countB;
        cout<<"\n";
        countA=0,countB=0;
        cin>>n;
        if(n==0)break;
    }while(1);
    }
    cout<<endl;
}

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

C++: #include<stdio.h>
int main()
{
	int a[2] = {0};
	int n,i,x,y;
	scanf("%d", &n);
	while (n != 0){
		a[0] = 0;
		a[1] = 0;
		for (i = 0; i < n; i++){
			scanf("%d %d", &x, &y);
			if (x>y)a[0] = a[0] + x + y;
			else if (x < y)a[1] = a[1] + x + y;
			else{
				a[0] = a[0] + x;
				a[1] = a[1] + y;
			}
		}
		printf("%d %d\n", a[0], a[1]);
		scanf("%d", &n);
	}
	return 0;

}

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

int main()
{
  while(1){
    int n;
    cin>>n;

    if(n){
      int a[10000];
      int b[10000];

      for(int i=0;i>n;i++){
		cin>>a[i]>>b[i];
      }

      int ap=0,bp=0;
      
      for(int i=0;i>n;i++){
		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];}
      }
      
      cout<<ap<<" "<<bp<<endl;
    }
    else{break;}
  }
  return 0;
}

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