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

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

using namespace std;

int main(void){
    // Your code here!
    while(true){
        int N;
        cin >> N;
        if(N == 0){
            break;
        }
        int sumA = 0;
        int sumB = 0;
        for(int i=0;i<N;i++){
            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<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
    int a,b;
    int input;
    while(1)
    {
        scanf("%d",&input);
        if(input == 0) break;
        int suma = 0;
        int sumb = 0;
        for(int i = 0;i < input;i++)
        {
            scanf("%d%d",&a,&b);
            if(a>b)
            {
                suma = suma +a +b;
            }
            else if(b>a)
            {
                sumb = sumb +a +b;
            }
            else if(a == b)
            {
                suma = suma+a;
                sumb += sumb+b;
            }
        }
        suma = suma+'0';
        sumb = sumb+'0';
        printf("%c %c\n",suma,sumb);
    }
    return 0;
}