Go: package main

import "fmt"

func main() {
	for {
		var a, b, n int
		fmt.Scanf("%d", &n)

		if n == 0 {
			return
		}

		for i := 0; i < n; i++ {
			var cardA, cardB int
			fmt.Scanf("%d %d", &cardA, &cardB)

			if cardA > cardB {
				a += cardA + cardB
			} else if cardB > cardA {
				b += cardA + cardB
			} else {
				a += cardA
				b += cardB
			}
		}

		fmt.Println(a, b)
	}
}

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;
}

C++: #include<iostream>
#include<string>
using namespace std;
int N, S, i, cnt, R, num;
string str, s;
string ring[101];
int main(){
    cin >> str >> N;
    S = str.size();
    for (i=0; i<N; i++){
        cin >> s;
        ring[i] = s + s;
    }
    cnt = 0;
    for (i=0; i<N; i++){
        R = ring[i].size();
        for (num = 0; num < R-S+1; num++){
            if( ring[i].substr(num,S) == str ){
                cnt++; break;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

C++: #include <stdio.h>

int main () {
    int a, b, n, scorea, scoreb;
    scanf("%d", &n);
    while (~scanf("%d %d", &a, &b)) {
        if (a == b) {
            scorea += a;
            scoreb += b;
        }
        else if (a > b) {
            scorea += a + b;
        } else {
            scoreb += a + b;
        }
    }

    printf("%d %d\n", scorea, scoreb);
    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{
                ans1+=v[i]; ans2= v2[i];}
        }
        cout << ans1 << " " << ans2 << endl;
    }
}

C++: #include <cstdio>

int n;
int a,b;
int A,B;

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

  if(!n)return 0;
  
  A=B=0;

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

  printf("%d %d\n", A,B);

  main();
}

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

int main(){
  int n;
  int Acard,Bcard;
  int Atotal,Btotal;
  cin>>n;
  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';
  return 0;
}

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

int main(){
	int a[4];
	int b[4];
	int i=0;
	int s=0;
	int t=0;
	
	for(i=0;i<4;i++){
		cin>>a[i];
		s=s+a[i];
	}
	
	for(i=0;i<4;i++){  
		cin>>b[i];
		t=t+b[i];
	}
	
	if(s<t){
		cout<<t<<endl;
	}else{
		cout<<s<<endl;
	}
}

C++: #include <stdio.h>

int main(void) {
	int n, i, po[2] = {0}, ca[2];
	
	scanf("%d", &n);
	for(i = 0; n > i; i++){
		scanf("%d%d", &ca[0], &ca[1]);
		if(ca[0] > ca[1]) po[0] += ca[0]+ca[1];
		else if(ca[0] < ca[1]) po[1] += ca[0]+ca[1];
		else{ po[0] += ca[0]; po[1] += ca[1];}
	}
	printf("%d %d\n",po[0],po[1]);
	return 0;
}

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

int main(void) {
	int i, n, a, b, as = 0, bs = 0;
	cin >> n;

	for(i=0 ; i<n ; i++) {
		cin >> a >> b;
		if(a > b)		{ as += a + b; }
		else if(a < b)	{ bs += a + b; }
		else 			{ as += a; bs += b; }
	}
	printf("%d %d\n", as, bs);
	return 0;
}

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

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

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

		cout << as << ' ' << bs << endl;
	}


	return 0;
}