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 i,k;
  i = 0;
  int a,b;
  int suma[3],sumb[3];
  suma[3] = {};
  sumb[3] = {};
  while(1){
    int n;
    cin>>n;
    if(n==0) break;
    for(i=0;i<n;i++){
      cin>>a>>b;
      if(a>b) suma[i]=a+b+suma[i];
      else if(a<b) sumb[i]=a+b+sumb[i];
      else{
        suma[i]=a+suma[i];
        sumb[i]=b+sumb[i];
      }
  }
 }
  for (k = 0; k < i;k++) {
   cout<<suma[k]<<" "<<sumb[k]<<endl;
 }
 return 0;
}

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

#include <algorithm>

int main() {
	int n;
	while (1) {
		cin >> n;
		if (n==0) break;
		int p1=0, p2=0;
		int c1, c2;
		for (int i=0; i<n; i++) {
			cin >> c1 >> c2;
			if (c1==c2) p1+=c1, p2+=c2;
			if (c1>c2) p1+=c1+c2;
			if (c1<c2) p2+=c1+c2;
		}
		cout << p1 << " " << p2 << endl;
	}
	return 0;
}

C++: #include <iostream>

int main(){
    
    int num,a,b,resa=0,resb=0;
    
    std::cin>>num;
    
    for(int i=0;i<num;i++){
        std::cin>>a>>b;
        if(a>b)
            resa+=a+b;
        else
        if(a<b)
            resb+=a+b;
        else
            if(a==b)
                resa+=a,resb+=b;
    }
    
    std::cout<<resa<<' '<<resb<<std::endl;
    
    return 0;
}

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

C++: #include<stdio.h>
void judge(int n, int a[], int b[], int *result1, int *result2) {
	while (--n >= 0) {
		if (a[n] > b[n]) {
			*result1 += a[n] + b[n];
		}
		else if (a[n] < b[n]) {
			*result2 += a[n] + b[n];
		}
		else if (a[n] == b[n]) {
			*result1 += a[n];
			* result2 += b[n];
		}
	}
}
int main() {
	int a[1000];
	int b[1000];
	int n, t = 0;
int i;
	int result1 = 0, result2 = 0;
	int result[1000][2];
	do {
		scanf("%d", &n);
		for (i = 0; i < n; i++) {
			scanf("%d %d", &a[i], &b[i]);
		}
		judge(n, a, b, &result1, &result2);
		result[t][0] = result1;
		result[t][1] = result2;
		result1 = 0;
		result2 = 0;
		t++;
	} while (n != 0);

	for (i = 0; i < t-1;i++) {
		printf("%d %d\n", result[i][0], result[i][1]);
	}

	return 0;
}

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

int main(void){
  int n;
  while(cin >> n, n){
    int a = 0;
    int b = 0;
    for(int i = 0; i < n; i++){
      int pa;
      int pb;
      cin >> pa >> pb;
      if(pa > pb){
        a += pa + pb;
      } else if(pa < pb){
        b += pa + pb;
      } else {
        a += pa;
        b += pb;
      }
    }
    cout << a << " " << b << endl;
  }
  return 0;
}

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

int main(){
	while(1){
		int n;
		cin >> n;
		if(n==0) break;
		
		int a=0, b=0;
		for(int i=0; i<n; i++){
			int n,m;
			cin >> n >> m;
			if(n>m) a += n+m;
			if(n<m) b += n+m;
			if(n==m){
				a += n;
				b += m;
			}
		}
		cout << a << " " << b << 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);
		}
	}
	for (int i = 0; i < veca.size(); ++i) {
		std::cout << veca[i] <<" "<<vecb[i]<< std::endl;
	}
	return 0;
}

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

C++: #include <iostream>
using namespace std;
int main()
{
	int a = 1, e = 0, f = 0, c, d;
	while (1)
	{
		cin >> a;
		if (a == 0)
		{
			break;
		}
		e = 0;
		f = 0;
		for (int b = 0; b < a; 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<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PA;
using namespace std;
#define MAX 1e7
int main(){
    int n;
    while(cin >> n,n){
        vi v(n+1,0);
        vi v2(n+1,0);
        int ans1 = 0; int ans2 =0;
        rep(i,n){
            cin >> v[i] >> v2[i];
            if(v[i]>v2[i])
                ans1+=v[i]+v2[i];
            else if(v[i] < v2[i])
                    ans2 += v[i]+v2[i];
            else if(v[i] == v2[i]){
                ans1+=v[i]; ans2= v2[i];}
        }
        cout << ans1 << " " << ans2 << endl;
    }
}

C++: #include <stdio.h>

int n, A[11234], B[11234];
int ans[2];

int main(void) {
	while (true) {
		scanf("%d", &n);
		if (n == 0) { break; }
		for (int i = 0; i < n; ++i) { scanf("%d%d", &A[i], &B[i]); }

		for (int i = 0; i < n; ++i) {
			if (A[i] > B[i]) { ans[0] += A[i] + B[i]; }
			else if (A[i] < B[i]) { ans[1] += A[i] + B[i]; }
			else { ans[0] += A[i], ans[1] += B[i]; }
		}

		printf("%d %d\n", ans[0], ans[1]);
	}
	return 0;
}

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

C++: #include<iostream>

using namespace std;
#define MAX_N 10000

int N;//カードの枚数
int A[MAX_N],B[MAX_N];
  
int PA = 0,PB = 0;//A,Bのそれぞれの得点
int main(){
  scanf("%d",&N);//配られるカードの枚数
  for(int i = 0;i < N;i++){
    scanf("%d %d",&A[i],&B[i]);
    if(A[i] > B[i])
      PA += A[i]+B[i];
    else if(A[i] > B[i])
      PB += A[i]+B[i];
  }
  printf("%d %d\n",PA,PB);
  return 0;
 
}

C++: #include<iostream>
using namespace std;
int main(){
    int N,suma=0,sumb=0;
    while(N--){
        cin >> x >> y;
        if(x>y) suma=suma+x+y;
        else    sumb=sumb+x+y;
    }
    cout << suma << " " << sumb << "\n";
    return 0;
}

C++: #include <stdio.h>
#include<iostream>
#include<cstdio>
using namespace std;
int main(void)
{
	int n, m, A = 0, B = 0, l, a[100] = { 0 }, b[100] = { 0 }, i, j;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
		if (a[i] > b[i]) {
			A += a[i] + b[i];
		}
		else if (a[i] == b[i]) {
			A += a[i];
			B += b[i];
		}
		else {
			B += a[i] + b[i];
		}
	}
	printf("%d %d\n", A, B);
}