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++: //Bokann ga bokka--nn!!
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
int main(){
	while(1)
	{
		int n;
		scanf("%d",&n);
		if(!n) return 0;
		int a=0,b=0;
		for(int i=0;i<n;i++)
		{
			int x,y;
			scanf("%d %d",&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);
	}
}

C++: #include<iostream>
using namespace std;
int main()
{
  int n,a,b,A,B;
  while(cin>>n,n){
    A=B=0;
    while(n-->0){
      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<iostream>
using namespace std;

int main(){
int n,a,b;
int sumA=0,sumB=0;
while(cin>>n){
	sumA=0,sumB=0;
for(int i=0;i<n;i++){
cin>>a>>b;
if(a>b){
sumA+=a;
sumA+=b;
}
if(a==b){
sumA+=a;
sumB+=b;
}
if(a<b){
sumB+=a;
sumB+=b;
}}
printf("%d %d",sumA,sumB);
}}

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

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

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

C++: #include<stdio.h>
int main(void){
    int loop,a,b,c=0,d=0;
    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\n",c,d);
    return 0;
}

C++: // aoj-5000.cpp

#include <cstdio>

int main() {
	int i;
	int cards, a, b, scoreA = 0, scoreB = 0;

	while (1) {
		// read number of cards
		scanf("%d", &cards);
		if (cards == 0) break;
		scoreA = 0;
		scoreB = 0;
	
		for (i=0; i<cards; ++i) {
			scanf("%d %d", &a, &b);
			if (a > b) {
				scoreA += (a + b);
			} else if (b > a) {
				scoreB += (a + b);
			} else {
				scoreA += a;
				scoreB += b;
			}
		}
		printf("%d %d\n", scoreA, scoreB);
	}

	return 0;
}

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

int main()
{
	int n,PointA=0,PointB=0;
	short A,B,a=1;
	cin>>n;
	
	while(n!=0 || a==5){
		for(int i=0;i<n;i++){
			cin>>A>>B;
			if(A>B){
				PointA+=A+B;
			}
			else if(A<B){
				PointB+=A+B;
			}
			else if(A==B){
				PointA+=A;
				PointB+=B;
			}
		}
		cout<<PointA<<" "<<PointB<<endl;
		PointA=0,PointB=0;
	        a++;
		cin>>n;
	}
	
	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++: /*
 * AOJCardGame.cxx
 * 
 * Copyright 2016 Tom Tanaka <torumu@Tom-no-MacBook-Pro.local>
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301, USA.
 * 
 * 
 */


#include <iostream>

int main(int argc, char **argv)
{
	int a, b;
	int n;
	int acards,bcards;
	while(true){
		a = 0;
		b = 0;
		std::cin >> n;
		if(n == 0){
			break;
		}
		for(int i = 0; i < n; i++){
			std::cin >> acards >> bcards;
			if(acards < bcards){
				b += bcards + acards;
			}
			if(acards > bcards){
				a += bcards + acards;
			}
			if(acards == bcards){
				a += acards;
				b += bcards;
			}
		}
		std::cout << a << " " << b << std::endl;
	}
	return 0;
}

C++: #include<iostream>

using namespace std;

int main()
{
	int n;
	int a[10000], b[10000];
	int a_score;
	int b_score;
	int score_stock[10000][2];
	int i, j;
	for(j = 0;;j++){
		a_score = 0;
		b_score = 0;
		cin >> n;		//J[hÌ
		if(n == 0){
			break;
		}
		
		for(i = 0;i < n; i++){
			cin >> a[i];
			cin >> b[i];
			if((a[i] == 0)||(b[i] == 0)){
				break;
			}
		}
		
		for(; i > -1; i--){
			if(a[i] > b[i]){
				a_score += a[i] + b[i];
			}
			else if(a[i] < b[i]){
				b_score += a[i] + b[i];
			}
			else{
				a_score += a[i];
				b_score += b[i];
			}
		}
		score_stock[j][0] = a_score;
		score_stock[j][1] = b_score;
	}
	for(i = 0; i < j; i++){
		cout << score_stock[i][0] << " "<<score_stock[i][1] << endl;
	}
}

C++: #include <cstdio>

int n,an,bn,i,j;
int a[10000],b[10000];
int main (){
	scanf("%d",&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<stdio.h>
int main(void){
    int loop,a,b,c=0,d=0;
while( scanf("%d",&loop) != EOF ){
    
    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\n",c,d);
}
    return 0;
}

C++: #include <stdio.h>

int main()
{
  int a = 0, b = 0, n, tmpa, tmpb;

  while (1) {
  scanf("%d", &n);
  if(n == 0)
    break;
  a = 0; b = 0;
  for(int i = 0; i < n; i++) {
    scanf("%d%d", &tmpa, &tmpb);
    if(tmpa == tmpb) {
      a += tmpa; b += tmpb;
    } else if(tmpa > tmpb) {
      a += (tmpa + tmpb);
    } else {
      b += (tmpa + tmpb);
    }
  }
  printf("%d %d\n", a, b);
  }

  return 0;
}

C++: #include<stdio.h>

int main(){
int a,b,c,d,e;
while(1){
scanf("%d",&a);
if(a==0) break;
d=e=0;
for(int i=0;i<a;i++)
{scanf("%d%d",&b,&c);
if(b<c) e=e+b+c;
else if(b>c) d=d+b+c;
else {d=d+b;
e=e+c;}}
printf("%d %d\n",c,d);
}
return 0;
}