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++: //Volume5 -> 0501

#include <iostream>
#include <vector>
//#include <math.h>
//#include <string>
#include <cmath>
#include <iomanip>

int main();

int main(){
	std::vector<int> totalAPoint;		//Aの得点
	std::vector<int> totalBPoint;		//Bの得点
	int dataSetCount = 0;				//ゲーム数

	while (1){
		int n = 0;		//1ゲームの入力数

		std::cin >> n;
		//n=0で終了
		if (n == 0){
			break;
		}

		dataSetCount++;

		int aPoint = 0;		//1ゲームにおけるAの得点
		int bPoint = 0;		//1ゲームにおけるBの得点

		for (int i = 0; i < n; i++){
			int tempA;
			int tempB;

			std::cin >> tempA >> tempB;
			if (tempA > tempB){
				aPoint += (tempA + tempB);
			}
			else if (tempA < tempB){
				bPoint += (tempA + tempB);
			}
			//引き分け
			else{
				aPoint += tempA;
				bPoint += tempB;
			}
		}

		totalAPoint.push_back(aPoint);
		totalBPoint.push_back(bPoint);
	}

	//結果出力
	for (int i = 0; i < dataSetCount; i++){
		std::cout << totalAPoint[i] << " " << totalBPoint[i] << std::endl;
	}

	//while (1);
	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;
  }
}

C++: #include <stdlib.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int a[10000];
int b[10000];
int main(){
	while(1){
	int n;
	cin>>n;
	if(n==0)break;
	REP(i,n)cin>>a[i]>>b[i];
	int ans_a=0,ans_b=0;
	REP(i,n){
		if(a[i]>b[i]){
			ans_a+=(a[i]+b[i]);
		}else if(a[i]<b[i]){
			ans_b+=(a[i]+b[i]);
		}else{
			ans_a+=a[i];
			ans_b+=b[i];
		}
	}
	cout<<ans_a<<" "<<ans_b;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int result[200] = { 0 };
int main(){
		int num;
		int tmp1, tmp2, sc1 = 0, sc2= 0;
		while (cin >> num){
			sc1 = sc2 = 0;
			if (num == 0)break;
			for (int i = 0; i < num; i++){
				cin >> tmp1 >> tmp2;
				if (tmp1 == tmp2){
					sc1 += tmp1;
					sc2 += tmp2;
				}
				else if (tmp1 > tmp2)
					sc1 += tmp1 + tmp2;
				else if (tmp1 < tmp2)
					sc2 += tmp1 + tmp2;
			}
			cout << sc1 << " " << sc2 << endl;
		}
}

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; }
	}
	cout << as << " " << bs << endl;
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main() {
  int k;
  int h = -1;
  int A[100];
  int B[100];
  while(1) {
    ++h;
    cin >> k;
    if(k == 0) break;
    int a,b;
    A[h] = 0;
    B[h] = 0;
    for(int c = 0; c < k; ++c) {
      cin >> a >> b;
      if(a > b) {
        A[h] += a + b;
      }else if(a == b) {
        A[h] += a;
        B[h] += b;
      }else if(a < b) {
        B[h] += a + b;
      }
    }
  }
  for(int ho = 0; ho < h; ++ho) {
    cout << A[ho] << " " << B[ho] << endl;
  }
}

C++: #include <iostream>

using namespace std;

int main() {
	int n, cards[2][10000], score[2];
	while (cin >> n, n) {
		for (int i = 0; i < n; ++i)
			cin >> cards[0][i] >> cards[1][i];
		
		score[0] = 0, score[1] = 0;
		for (int i = 0; i < n; ++i)
			if (cards[0][i] > cards[1][i]) score[0] += cards[0][i] + cards[1][i];
			else if (cards[0][i] < cards[1][i]) score[1] += cards[0][i] + cards[1][i];
			else score[0] += cards[0][i], score[1] += cards[1][i];

		cout << score[0] << " " << score[1] << endl;
	}
	return 0;
}

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

#define loop(i,a,b) for(int i=a; i<b; i++)
#define rep(i,b)
 
int main(void){
    int n;
    while(cin >> n, n){
        int a = 0;
        int b = 0;    
        rep(i,n){
            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;
    }
}

C++: #include<stdio.h>
int main(void)
{
	int n;
	int a[10000],b[10000];
	int i,sa,sb;
	
	scanf("%d",&n);
	while(n!=0){
		for(i=0;i<n;i++){
			scanf("%d %d",&a[i],&b[i]);
		}
		sa=0;
		sb=0;
		for(i=0;i<n;i++){
			if(a[i]>b[i]){
				sa=sa+a[i]+b[i];
			}
			else if(a[i]<b[i]){
				sb=sb+a[i]+b[i];
			}
			else {
				sa=sa+a[i];
				sb=sb+b[i];
			}
		}
		printf("%d %d\n",sa,sb);
		scanf("%d",&n);
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

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

int main(void){
	int n;
	int a = 0, b = 0;
	while(true){
		cin >> n;
		if(c == 0) break;
		rep(i, n){
			int x, y;
			cin >> x >> y;
			if(x > y){
				a += x + y;
			}
			if(y > x){
				b += x + y;
			}
			if(y == x){
				a += x;
				b += y;
			}
		}
		cout << a << " " << b << endl;
	}
	return 0;
}

C++: #include <stdio.h>

void main() {
	int n, a, b;
	int suma = 0;
	int sumb = 0;
	bool endflg = false;
	while (1) {
		scanf_s("%d", &n);
		if (n == 0) {
			return 0;
		}
		int i;
		for (i = n; i > 0; i--) {
			scanf_s("%d %d", &a, &b);
			if (a > b) {
				suma = suma + a + b;
			}
			else if (b > a) {
				sumb = sumb + a + b;
			}
			else {
				suma = suma + a;
				sumb = sumb + b;
			}
		}
		printf("%d %d\n", suma, sumb);
		suma = 0;
		sumb = 0;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

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

int main(void){
	int n;
	int a = 0, b = 0;
	while(true){
		cin >> n;
		if(n == 0) break;
		rep(i, n){
			int x, y;
			cin >> x >> y;
			if(x > y){
				a += x + y;
			}
			if(y > x){
				b += x + y;
			}
			if(y == x){
				a += x;
				b += y;
			}
		}
		cout << a << " " << b << endl;
	}
	return 0;
}

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

int main(){
	int count;
	int aSum, bSum;
	int aCard, bCard;

	while(1){
		aSum = bSum = 0;
		cin >> count;
		if(!count) break;

		for(int i=0; i < count; i++){
			cin >> aCard >> bCard;
			if(aCard > bCard) aSum += aCard + bCard;
			else if(aCard < bCard) bSum += aCard + bCard;
			else {
				aSum += aCard;
				bSum += bCard;
			}
		}
		cout << aSum << " " << bCard << endl;
	}
}