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++: #include<string>
#include<vector>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<sstream>
#include<functional>
#include<map>
#include<stack>
#include<set>
#include<cmath>

#define REP(i,s,e) for(int i=int(s);i<int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)

#define EPS 1e-6

using namespace std;

int main(){

	int n,a,b;

	cin >> n;

	int p=0; int q=0;
	rep(i,n){

	cin >> a >> b;

	if(a>b) p+=a+b;
	else if(a<b) q+=a+b;
	else{ p+=a; q+=b; }

	}

	cout << p << " " << q << endl;

    return 0;

}

C++: #include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n,a[10000],b[10000],countA=0,countB=0;
    while(cin>>n,n!=0){
        for(int i=0;i<n;i++){
            cin>>a[i]>>b[i];
            if(a>b){
                countA+=(a[i]+b[i]);
            }else if(a<b){
                countB+=(a[i]+b[i]);
            }else{
                countA+=a[i];
                countB+=b[i];
            }
        }
        cout<<countA<<" "<<countB<<endl;
    }
    return(0);
}

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

int main () {
    int n, i,A,B, resa =0, resb =0;
    while(cin >> n,n){
        for(i=0;i<n;i++){
            cin >> A >> B;
            (A > B)? resa +=A:resb+=B;
            if(A==B) {resa += A; resb +=B;};
        }
　　　　cout << resa << " " << resb << endl;
    }
}

C++: #include <iostream>

using namespace std;

main(){
  int n;
  while(1){
    cin >> n;
    if(n==0) break;

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

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

int main() {
  int n;

  while (true) {
    cin >> n;
    int score_a = 0;
    int score_b = 0;

    if (n == 0) break;

    for (int i = 0; i < n; ++i) {
      int a, b;
      cin >> a;
      cin >> b;

      if (a == b) {
        score_a += a;
        score_b += b;
      } else if (a > b) {
        score_a += a + b;
      } else {
        score_b += a + b;
      }
    }

    cout << score_a << " " << score_b << endl;
  }
  
  return 0;
}

C++: #include <stdio.h>
int n,i,j,k;
long int A[1],B[1];
int main(){
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf(" %d %d",&j,&k);
    if(j>k){
      A[0]+=(j+k);
    } else if(j<k){
      B[0]+=(j+k)
    } else if(j==k){
      A[0]+=j;
      B[0]+=k;
    }
  }
  printf("%ld %ld\n",A[0],B[0]);
  return 0;
}

C++: // http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0500
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    while (true) {
        int N;
        cin >> N;
        if (N == 0) {
            break;
        }
        int sumA = 0, sumB = 0;
        while (N--) {
            int a, b;
            cin >> a >> b;
            if (a > b) {
                sumA += (a + b);
            } else if (a < b) {
                sumB += (a + b);
            } else {
                sumA += a;
                sumB += b;
            }
        }
        cout << sumA << " " << sumB << endl;
    }

    return 0;
}

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

struct Game {
    int a = 0, b = 0;
    Game() {}

    void score(int card_a, int card_b) {
        if (card_a > card_b)
            a += card_a + card_b;
        else if (card_a < card_b)
            b += card_a + card_b;
        else {
            a += card_a;
            b += card_b;
        }
    }
    void board() {
        cout << a << " " << b << endl;
    }
};

int main()
{
    for (int n; cin >> n && n;) {
        Game game;
        for (int a, b; n-- && cin >> a >> b;)
            game.score(a, b);
        game.board();
    }

    return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()

using namespace std;

typedef pair<int, int> pii;
typedef unsigned long long ull;

int main(void){
    for(int n, a, b, sa = 0, sb = 0; cin >> n, n; cout << sa << " " << sb << endl, sa = sb = 0)
        while(n --){
            cin >> a >> b;
            int res = a - b;
            sa += (!res) ? a:(res > 0) ? a + b:0;
            sb += (!res) ? b:(res < 0) ? a + b:0;
        }

    return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(){
	int n;
	vector< vector<int> > a, b;

	int k = 1;
	do{

		cin >> n;
		a.resize(k);
		b.resize(k);

		//cout << a.size() << endl;

		if(n != 0)
		{
			for(int i = 0; i < n; ++i)
			{
				int workA, workB;
				cin >> workA >> workB;
				a[k - 1].push_back(workA);
				//cout << a[k - 1][i] << endl;
				b[k - 1].push_back(workB);
				//cout << a[k - 1][i] << endl;
			}
		}

		k++;
		//cout << "k = " << k << endl;
	}while(n != 0);

	for (int i = 0; i < a.size() - 1; ++i)
	{
		int aRes = 0, bRes = 0;
		for (int j = 0; j < a[i].size(); ++j)
		{
			if(a[i][j] > b[i][j])
			{
				aRes += (a[i][j] + b[i][j]);
			}
			else if(a[i][j] < b[i][j])
			{
				bRes += (a[i][j] + b[i][j]);
			}
			else
			{
				aRes += a[i][j];
				bRes += b[i][j];
			}
		}
		cout << aRes << " " << bRes << endl;
	}

}

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

int main(){
 int n;
 int Acard,Bcard,Apoint,Bpoint;
 while(true){
  cin>>n;
  if(n==0){
   break;
  }else{
    for(int i=0;i<n;i++){
     cin>>Acard>>Bcard;
     if(Acard>Bcard){
      Apoint+=Acard+Bcard;
     }else if(Acard<Bcard){
      Bpoint+=Acard+Bcard;
     }else{
      Apoint+=Acard;
      Bpoint+=Bcard;
     }
    }
   count<<Apoint<<' '<<Bpoint<<'\n';
  }
 }
 return 0;
}

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

int main(){
	int n,c,d;
	while(cin >> n && n){
		int a=0,b=0;
		for(int i=0;i<n;i++){
			cin >> c >> d;
			if(c>d){
				a+=c+d;
			}else if(c<d){
				b+=c+d;
			}else{
				a+=c;
				b+=d;
			}
		}
		cout << a << " " << b << endl;
	}
}

C++: #include <iostream>

using namespace std;

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

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

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