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<stdio.h>
using namespace std;
int main(){
    int num;
    while(1){
        a_score=0;b_score=0;
        scanf( "%d", &num );
        if(num==0)break;
        for(int i=0;i<num;i++){
            int a_card,b_card;
            scanf("%d %d",&a_card,&b_card);
            if(a_card>b_card){a_score+=a_card+b_card;}
            else if(a_card==b_card){a_score+=a_card;b_score+=b_card;}
            else b_score+=a_card+b_card;
        } 
        cout<<a_score<<" "<<b_score<<endl;
    }
    
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

ll n, a, b, suma = 0, sumb = 0;

int main(){
	cin >> n;
	REP(i, n){
		cin >> a >> b;
		if (a > b){
			suma += a + b;
		}
		else if (a < b){
			sumb += a + b;
		}
		else {
			sumb += b;
			suma += a;
		}
	}
	cout << suma << " " << sumb << endl;
}

C++: #include <iostream>
#include <vector>

using namespace std;


int main() {
	int n, ka, kb;
	int a, b;
	vector<pair<int, int>> dst;
	while (cin >> n && n != 0) {
		a = b = 0;
		while (n-->0 && cin >> ka >> kb) {
			if (ka > kb)
				a += (ka + kb);
			else if (ka < kb)
				b += (ka + kb);
			else {
				a += ka;
				b += kb;
			}
		}
		dst.push_back(pair<int, int>(a, b));
	}
	for (vector<pair<int, int>>::iterator it = dst.begin(); it < dst.end(); it++)
		cout << (*it).first << " " << (*it).second << endl;
	return 0;
}

C++: //http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0500
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	while (true) {
		int n; cin >> n;
		if (!n) break;
		int ans[2] = { 0 };
		for (int i = 0; i < n;i++) {
			int a, b; cin >> a >> b;
			if (a == b) { ans[0] += a, ans[1] += b; continue; }
			ans[a < b] += (a + b);
		}
		cout << ans[0] << " " << ans[1] << endl;
	}
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<math.h>

using namespace std;

int n,a,b,asum,bsum;

int main(){
	while(TRUE){
		cin>>n;
		if( n == 0 ) break;
		for(int i=0;i<n;i++){
			cin >> a >> b ;
			if( a > b ){
				asum+=(a+b);
			}else if( a == b ){
				asum+=a;
				bsum+=b;
			}else{
				bsum+=(a+b);
			}
		}
		cout<<asum<<" "<<bsum<<endl;
		asum=0;bsum=0;
	}
	return 0;
}

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

int main(void) {
	int n;

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

		int sumA = 0, sumB = 0;
		int pointA, pointB;
		for (int i = 0; i < n; i++){

			cin >> pointA >> pointB;
			if (pointA > pointB) {
				sumA += (pointA + pointB);
			} else if (pointB > pointA) {
				sumB += (pointA + pointB);
			} else {
				sumA += pointA;
				sumB += pointA;
			}
		}
		cout << sumA << " " << sumB << endl;
	}

	return 0;
}

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

C++: #include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <iterator>
#include <utility>


using namespace std;

template <class T>
T convertStringToNumber(const string& str) {
	stringstream ss;
	T ret;

	ss << str;
	ss >> ret;

	return ret;
}


vector<vector<string>> inputData() {
	vector<vector<string>> data_set;

	string buffer;

	while(true){
		getline(cin, buffer);
		int n = convertStringToNumber<int>(buffer);

		if(!n)
			break;

		vector<string> temp;
		for(int i = 0; i < n; ++i) {
			getline(cin, buffer);
			temp.push_back(buffer);
		}

		data_set.push_back(temp);
	}

	return data_set;
}


vector<string> splitString(const string& str, const string& separator = " ") {
	vector<string> ret;

	std::size_t bp, ep;
	bp = ep = 0;
	while((ep = str.find_first_of(separator, bp)) != string::npos){
		if(bp != ep){
			ret.push_back(string(str.begin() + bp, str.begin() + ep));
		}
		bp = ep + 1;
	}

	if(bp <= str.size() - 1){
		ret.push_back(string(str.begin() + bp, str.end()));
	}

	return ret;
}



pair<int,int> judgeScore(int a, int b) {
	if(a > b)
		return make_pair(a+b, 0);
	else if(a < b)
		return make_pair(0, a+b);
	else
		return make_pair(a, b);
}


void doAllProcess() {
	auto data_set = inputData();

	for(int i = 0; i < data_set.size(); ++i) {
		int player1, player2;
		player1 = player2 = 0;

		for(int j = 0; j < data_set[i].size(); ++j) {
			auto score = splitString(data_set[i][j]);
			auto ret = judgeScore(convertStringToNumber<int>(score[0]),
									convertStringToNumber<int>(score[1]));
			player1 += ret.first;
			player2 += ret.second;
		}

		cout << player1 << " " << player2 << endl;
	}
}


int main() {
	doAllProcess();

	return 0;
}

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

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

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

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

C++: #include <bits/stdc++.h>
using namespace std;
int main() {
  while(1) {
    int n;
    cin >> n;
    if (n == 0) {
      break;
    }
    int pa = 0;
    int pb = 0;
    for (int i=0; i<n; i++) {
      int a,b;
      cin >> a >> b;
      if (a > b) {
        pa += a;
        pa += b;
      } else if (a < b) {
        pb += a;
        pb += b;
      } else {
        pa += a;
        pb += b;
      }
    }
    cout << pa << " " << pb << endl;
  }
}

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

int main()
{
	int a;
	int r, l;

	while (cin >> a && (a != 0)){
		int rsum, lsum;
		rsum = 0;
		lsum = 0;
		for (int i = a; i > 0; i--){

			cin >> r;
			cin >> l;
			if (r > l){
				rsum += r + l;
			}
			else if (l > r){
				lsum += r + l;
			}
			else{
				rsum += r;
				lsum += l;
			}
		}
		cout << rsum << ' ' << lsum << endl;
	} 
	cout << "end";
}

C++: #include <iostream>
using namespace std;
int main(){
	int pa=0, pb=0;

	int n;

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