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

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

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-9)
#define MOD (int)(1e9+7)
#define INF numeric_limits<int>::infinity()
#pragma endregion


int main()
{
    int n;
    cin >> n;
    vi v(2,0);
    rep(i,n) {
        int a, b;
        cin >> a >> b;
        if (a>b) {
            v[0] += a + b;
        } else if (a<b) {
            v[1] += a + b;
        } else {
            v[0] += a;
            v[1] += b;
        }
    }
    printf("%d %d\n", v[0], v[1]);
    return 0;
}

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

C++: aaaa

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

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

int main() {
	int a,b,n;
	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>
#define fo(i,a) for(i = 0;i < a;i++)
using namespace std;
int main(void)
{
	int n,a=0,b=0,x,y,i;
	
	cin >> n ;
	while(n != 0){
		fo(i,n){
			cin >> x >> y ;
			if(x > y) a += x + y ;
			else if(x < y) b += x + y ;
			else{
				a += x ;
				b += y ;
			}
		}
		
		cout << a << " " << b << endl ;
		a = 0 ;
		b = 0 ;
		cin >> n ;
	}
	
	return 0;
}

C++: int main() {
	int num = 0;
	int a[10000] = { 0 };
	int	b[10000] = { 0 };
	cin >> num;
	while (num != 0) {
		int ap = 0;
		int	bp = 0;
		for (int i = 0; i < num; i++) {
			cin >> a[i] >> b[i];
			if (a[i] > b[i]) ap += a[i] + b[i];
			else if (a[i] < b[i]) bp += a[i] + b[i];
			else {
				ap += a[i];
				bp += b[i];
			}
		}
		cout << ap << " " << bp << endl;
		cin >> num;
	}
}