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>

using namespace std;
int main(void){
  int n,j = 0,i,c,a[10000],b[10000];
  /* vector <int> a;
     vector <int> b;*/
  vector <int> d;
  vector <int> sa(10000,0);
  vector <int> sb(10000,0);
  while(cin >> n,n != 0){
    for(i=0;i<n;i++){
      cin >> a[i];
      cin >> b[i];
    }
    
    i=0;
    for(i=0;i<n;i++){
      c = a[i] + b[i];
      if(a[i] > b[i]) sa[j] = sa[j] + c;
      else if(a[i] < b[i]) sb[j] = sb[j] + c;
      else{
	sa[j] = sa[j] + c/2;
	sb[j] = sb[j] + c/2;
      }
    }
    j++;

    cout << sa[j-1] << " " << sb[j-1] << endl;
  }
}

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

int main(){
  int n;
  int Acard,Bcard;
  int Atotal,Btotal;
while(true){
  cin>>n;
  if(n==0){
    break;
  }
  for(int i=0;i<n;i++){
    cin>>Acard>>Bcard;
    if(Acard>Bcard){
      Atotal+=Acard+Bcard;
    }else if(Bcard>Acard){
      Btotal+=Acard+Bcard;
    }else{
      Atotal+=Acard;
      Btotal+=Bcard;
    }
  }

  cout<<Atotal<<' '<<Btotal<<'\n';
  Atotal=0;
  Btotal=0;
}
  return 0;
}

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

int main(){
	int n, x, y, sumx=0, sumy=0;
	cin >> n;

	for(int i=0; i<n; i++){
		x=0,y=0;
		cin >> x >> y;
		if(x > y){
			sumx = sumx + x + y;
		}
		else if(x < y){
			sumy = sumy + x + y;
		}
		else if(x == y){
			sumx = sumx + x;
			sumy = sumy + y;
		}
	}
	
	cout << sumx << " " << sumy  <<  endl;
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

int main()
{
    int N, a, b;
    while (cin >> N, N) {
        int p1 = 0, p2 = 0;
        for (int i = 0; i < N; i++) {
            cin >> a >> b;
            if (a > b) {
                p1 += a + b;
            } else if (a < b) {
                p2 += a + b;
            } else {
                p1 += a;
                p2 += b;
            }
        }
        cout << p1 << " " << p2 << endl;
    }
    return 0;
}

C++: 
#include <cstdio>

using namespace std;

#define FOR( i, n ) for( int i = 0; i < n; ++i )

int main( void )
{
	int point_a = 0;
	int point_b = 0;

	int n;
	scanf( "%d", &n );

	FOR( i, n )
	{
		int a, b;
		scanf( "%d %d", &a, &b );

		if( a > b )
		{
			// AÌ¿
			point_a += a+b;
		}
		else
		{
			if( a == b )
			{
				// ø«ª¯
				point_a += a;
				point_b += b;
			}
			else
			{
				// BÌ¿
				point_b += a+b;
			}
		}

	}

	// Ê
	printf( "%d %d\n", point_a, point_b );

	return 0;
}

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

C++: #include <iostream>
using namespace std;
  
int main()
{
  while(1){ 
  int i, n, x, y;
  cin >>n;

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

C++: #include <iostream>



int main () {
  int n, i;
  int left, right;
  int sum_a, sum_b;
  while (std::cin >> n) {
    if (n == 0) {
      break;
    }
    sum_a = 0;
    sum_b = 0;
    for (i = 0; i < n; i ++) {
      std::cin >> left >> right;

      if (left > right) sum_a += (left + right); 
      else if (left < right) sum_b += (left + right);
      else {
        sum_a += left;
        sum_b += right;
      }
    }
    std::cout << sum_a << " " << sum_b << std::endl;
  }
  return 0;
}

C++: // cardgame.cpp
#include <iostream>
using namespace std;

int main(){
	for(;;){
		int n=0;	// nを0でリセット
		int i,j;
		int a[10000], b[10000];
		int a_point=0, b_point=0;
		cin >> n;	// nを取得
		if(n==0)
			break;;
		for(i=0;i<n;++i){	// カードを配る
				cin >> a[i];
				cin >> b[i];
		}
		for(j=0;j<n;++j){
			if(a[j]>b[j])
				a_point+=(a[j]+b[j]);
	        else if(a[j]<b[j])
				b_point+=(a[j]+b[j]);
			else if(a[j]==b[j]){
				a_point+=a[j];
				b_point+=b[j];
			}
		}
		cout << a_point << " " << b_point << endl;
	}
	return 0;	
}

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

int main(void){
  int n;
  while(cin >> n, n != 0){
    int a = 0;
    int b = 0;    
    for(int i = 0; i < n; i++){
      int ta,tb;
      cin >> ta >> tb;
      int sum = ta + tb;
      if(ta > tb) a += sum;
      if(ta < tb) b += sum;
      if(ta == tb){
	a += ta; b += tb;
      }
    }
    cout << a << " " << b << endl;
  }

  return 0;
}

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

	cin >> a;
	for (int i; i < a; i++){
		cin >> b[i];
		cin >> c[i];
	}
	for (int j; j < a; j++){
		if (b[j]>c[j]){
			uma = uma + 2;
		}
		if(b[j]=c[j]){
			uma = uma + 1;
			ushi = ushi + 1;
		}
		else{
			ushi = ushi + 2;
		}
	}
	cout << uma << ushi;

}

C++: #include <iostream>

using namespace std;

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

C++: #include<iostream>
int main() {
	int vec=0;
	int n;
	int a=0;
	int b=0;
	int game_a, game_b;
	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; b += game_b; }
				else if (game_a > game_b)a += game_a + game_b;
				else b += game_a + game_b;
			}
			std::cout << a << " " << b << std::endl; a = ; b = 0;
		}
	}
	return 0;
}

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

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

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

C++: #include <stdio.h>


int main(void)
{

	int n;
	int a=0,b=0;
	int ac,bc;

	scanf("%d", &n);

	for(int i = 0; i < n; i++){
		
		scanf("%d %d", &ac,&bc);
		if(ac > bc)
			a += ac + bc;
		else if(ac < bc)
			b += ac + bc;
		else {
			a += ac;
			b += bc;
		}
	}
	printf("%d %d\n", a,b);


	return 0;
}

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