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

using namespace std;

int main()
{
	int n, a, b, as, bs;

	while (cin >> n, n){
		as = 0;
		bs = 0;
		for (int i = 0; i < n; i++){
			cin >> a >> b;
			if (a == b){
				as += a;
				bs += b;
			}
			else if (a == max(a, b)) as += a + b;
			else if (b == max(a, b)) bs += a + b;
		}
		cout << as << " " << bs << endl;
	}
	return (0);
}

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

struct player{
    int point;
    int card[10000];
    inline player(){point = 0;}
};

int main()
{
    int loop = 1;
    player a, b;
    while(1) {
        loop = 0;
        cin >> loop;
        if(loop == 0) break;
        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];
                continue;
            }
            if(a.card[c] == b.card[c])
            {
                 a.point += a.card[c];
                 b.point +=b.card[c];
                 continue;
            }
            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 n;
	int a,b;
	int A,B;
	while(true){
		cin>>n;
			if(n==0){break;}
	for(int i=0;i<n;i++){
		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;
	}
	return 0;
}

C++: #define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)c.size())

typedef unsigned long long ull;
const int INF = (int)1e8;

int main(){
	int n;
	while(cin>>n,n){
		int a=0,b=0;
		FOR(i,n){
			int x,y; cin>>x>>y;
			if(x>y) a+=x+y;
			else if(x<y) b+=x+y;
			else a+=x,b+=y;
		}
		printf("%d %d\n",a,b);
	}
    return 0;
}

C++: #include<iostream>
#include<vector>
int main(){
int n;
int s=0;
int g=0;
std::cin>>n;
std::vector<int> a(n),b(n);
for(int i=0;i<n;++i){
std::cin>>a[i]>>b[i];
if(a[i]>b[i]) g+=a[i];
else s+=b[i];
}
std::cout<<" "<<std::endl;
std::cout<<g<<" "<<s<<std::endl;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

int n, a, b;

int main(){
	while (cin >> n){
		int	suma = 0, sumb = 0;
		REP(i, n){
			cin >> a >> b;
			if (a > b){
				suma += a + b;
			}
			else if (a < b){
				sumb += a + b;
			}
			else {
				sumb += b;
				suma += a;
			}
		}
		cout << suma << " " << sumb << endl;
	}
}

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

C++: #include<iostream>

using namespace std;
main(){
  int n,s1,s2;
  int a,b;
  cin>>n;
  while(n!=0){
    s1=s2=0;
    for(int i=0;i<n;i++){
      cin>>a>>b;
      if(a>b)
	s1+=(a+b);
      else if(a<b)
	s2+=(a+b);
      else{
	s1+=a;
	s2+=a;
      }

    }
    cout<<s1<<" "<<s2<<endl;
    
    cin>>n;
  }
  return 0;
}

C++: #include <stdio.h>

int main(void)
{
	int ans_a, ans_b;
	int n;
	int a, b;
	
	while (1){
		scanf("%d", &n);
		if (n == 0){
			break;
		}
	ans_a = ans_b = 0;
	while (n){
		scanf("%d %d", &a, &b);
		
		if (a > b){
			ans_a += (a + b);
		}
		else if (a < b){
			ans_b += (a + b);
		}
		else {
			ans_a += a;
			ans_b += b;
		}
		
		n--;
	}
	
	printf("%d %d\n", ans_a, ans_b);
	
	return (0);
}

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

int main(void)
{
	int n;
	int a,b;
	int asum,bsum;
	while(1)
	{
		cin >> n;
		if(n == 0)
			return 0;
		asum=0;bsum=0;
		for(int i=0;i<n;i++)
		{
			cin >> a >> b;
			if(a>b)
			{
				asum=asum+a+b;
			}
			if(b>a)
				bsum=bsum+a+b;
			if(a==b)
			{
				asum+=a;
				bsum+=b;
			}
		}
		cout << asum << ' ' << bsum << endl;
	}
	return 0;
}

C++: #include <stdio.h>

int main(){
	long long Right_Point = 0;
	long long Left_Point = 0;

	int Right_Card, Left_Card;

	int kaisuu;

	while (1){
		Right_Point = 0;
		Left_Point = 0;
		scanf("%d", &kaisuu);
		if (kaisuu == 0){
			break;
		}
		for (int a = 0; a < kaisuu; a++){
			scanf("%d%d", &Right_Card, &Left_Card);
			if (Right_Card == Left_Card){
				Right_Point += Right_Card;
				Left_Point += Left_Point;
			}
			else if (Right_Card < Left_Card){
				Left_Point = Left_Point + (Right_Card + Left_Card);
			}
			else
				Right_Point = Right_Point + (Right_Card + Left_Card);
		}
		printf("%d %d\n", Right_Point, Left_Point);
	}
	return 0;
}

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

C++: #include <iostream>

using namespace std;

int main(){
	int n;
	int a[10000], b[10000];

	while (cin >> n){
		int asco, bsco;

		asco = bsco = 0;

		for (int i = 0; i < n; i++){
			cin >> a[i] >> b[i];
			
			if (a[i] == b[i]){
				asco = a[i];
				bsco = b[i];
			}
			else if(a[i] > b[i]){
				asco += a[i] + b[i];
			}
			else {
				bsco += a[i] + b[i];
			}
		}

		cout << asco << " " << bsco << endl;
	}
	return 0;
}

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

struct player{
    int point;
    int card[10000];
    inline player(){point = 0;}
};

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];
            continue;
        }
        if(a.card[c] == b.card[c])
        {
             a.point += a.card[c];
             b.point +=b.card[c];
             continue;
        }
        a.point += a.card[c] + b.card[c];
    }
    cout << a.point << " " << b.point << endl;
    return EXIT_SUCCESS;
}