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 <bits/stdc++.h>
using namespace std;

int main(void) {
  int n;
  vector<int> A, B;
  int i = 0. j;
  int a, b;
  for(; i < 5; i++) {
    cin >> n;
    if(!n) break;
    A.push_back(0), B.push_back(0);
    for(j = 0; i < n; i++) {
      cin >> a >> b;
      if(a > b) A[i] += a;
      else if(a < b) B[i] += b;
      else A[i] += a, B[i] += b;
  }
  for(int i = 0; i < A.size(); i++) cout << A[i] << " " << B[i] << endl;
}

C++: #include<iostream>
#include<vector>
int main() {
	int i = 0;
	std::cin >> i;
	int A = 0, B = 0;
	std::vector<int> a, b;
	for (int j = 0; j < i; ++j) {
		std::cin >> a[j] >> b[j];
	}
	for (int j = 0; j < i; ++j) {
		if (a[j] > b[j]) {
			A += (a[j] + b[j]);
		}
		else if (a[j] < b[j]) {
			B += (a[j] + b[j]);
		}
		else {
			A += a[j];
			B += b[j];
		}
	}
	std::cout << A << " " << B << std::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 <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)

using namespace std;

int main(){
    while(true){
    int n;
    scanf("%d", &n);
    if(n==0) return 0;
    vector<int> a(n), b(n);
    REP(i, n)  scanf("%d %d", &a[i],&b[i]);
    int as=0, bs=0;
    REP(i,n){
        if(a[i]>b[i])as+=a[i]+b[i];
        else if(a[i]<b[i])bs+=a[i]+b[i];
        else {as+=a[i];bs+=b[i];}
    }
    printf("%d %d\n", as,bs);
    }
}

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

C++: #include <iostream>



int main () {
  int n, i;
  int left, right;
  int sum_a = 0, sum_b = 0;
  while (std::cin >> n) {
    if (n == 0) {
      break;
    }
    for (i = 0; i < n; i ++) {
      std::cin >> left >> right;

      if (left > right) sum_a += (left + right); 
      else if (left < right) sum_b += (left + right);
      else {
        sum_a += left;
        sum_b += right;
      }
    }
    std::cout << sum_a << " " << sum_b << std::endl;
  }
  return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int a=0, b=0,n,s,t;
	cin >> n;
	for (int i = 0; i < n; i++) {
		scanf("%d%d", &s, &t);
		if (s > t)a += s + t;
		else if (t > s)b += s + t;
		else { a += s; b += t; }
	}
	cout << a << " " << b << endl;
	return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
  int n, i, Apoint, Bpoint;
  int A[10000], B[10000];
  while(cin >> n ,n){
    Apoint = 0;
    Bpoint = 0;
    for(i=0; i<n; i++){
      cin >> A[i] >> B[i];
    }
    for(i=0; i<n; i++){
      if(A[i]>B[i])Apoint += A[i]+B[i];
      else if (A[i]<B[i])Bpoint += B[i]+A[i];
      else{
	Apoint += A[i];
	Bpoint += B[i];
      }
    }

    cout << Apoint << " " << Bpoint << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>

using namespace std;

int main()
{
	while(1)
	{
		int aSum(0),bSum(0);
		int n;

		cin >> n;
		
		if(n == 0)
			break;

		for(int i = 0;i < n;i++)
		{
			int a,b;
			cin >> a >> b;
		
			if(a > b){
				aSum += a + b;
			}else if(a < b){
				bSum += a + b;
			}else{
				aSum += a;
				bSum += b;
			}
		}
		cout << aSum << " " << bSum << " " << endl;

	}

	return 0;
}

C++: //
//  main.cpp
//  program
//
//  Created by h3032906 on 2016/11/24.
//  Copyright ?? 2016??´ h3032906. All rights reserved.
//

#include <iostream>

int main(int argc, const char * argv[]) {

    int n, a, b;
    int at = 0;
    int bt = 0;
    for( ; ; ){
        std::cin >> n;
        if(n == 0){
            break;
        }
        for(int i = 0; i < n; i++){
            std::cin >> a >> b;
            if(a > b){
                at = at + a + b;
            }
            else if(b > a){
                bt = bt + a + b;
            }
            else {
                at = at + a;
                bt = bt + b;
            }
        }
        std::cout << at << bt << std::endl;
        at = 0;
        bt = 0;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
/* Karen {{{
  ___  ____
 |_  ||_  _|
   | |_/ /    ,--.   _ .--.  .---.  _ .--.
   |  __'.   `'_\ : [ `/'`\]/ /__\\[ `.-. |
  _| |  \ \_ // | |, | |    | \__., | | | |
 |____||____|\'-;__/[___]    '.__.'[___||__]
}}} */
/* cpp template {{{*/
using namespace std;

#define endl '\n'

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define X real()
#define Y imag()
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()

typedef double D;
typedef long long ll;
typedef long double lb;
typedef complex<D> P;
typedef vector<P> VP;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<string, int> psi;

inline bool inside(int y,int x,int H,int W){return(y>=0&&x>=0&&y<H&&x<W);}
inline int in() {int x; std::cin >> x; return x;}

template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << endl;
}
template <typename T>
void print(T x) {
  std::cout << x << '\n';
}
/* }}} */
/* ?????° {{{*/
const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 9;
const D EPS  = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
/* }}} */

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  while (cin >> n, n){
    int sum1, sum2;
    sum1 = sum2 = 0;
    REP(i, n){
      int a = in(), b = in();
      if (a > b){
        sum1 += a + b;
      } else if (a < b){
        sum2 += a + b;
      } else {
        sum1 += a;
        sum2 += b;
      }
    }

    cout << sum1 << " " << sum2 << endl;
  }

}

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

C++: #include<iostream>
#include<stdio.h>
using namespace std;
int main(){
    int num;
    while(1){
        int a_score=0;
        int 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;
    }
    
}