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 n[10000000],s1,s2;
int main(){
int p,a,b;
while(true){
s1=0;s2=0;
cin>>p;
for(int i=0;i<p;i++){
cin>>a>>b;
if(a>b){s1+=a+b;}
else if(b>a){s2+=a+b;}
else{s1+=a;s2+=b;}
}
cout<<s1<<' '<<s2<<endl;
}
}

C++: #include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

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 vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;


int main() {
	int n;

	while(cin >> n, n) {
		int scoreA = 0, scoreB = 0;

		REP(i, n) {
			int a, b, sum;
			cin >> a >> b;
			sum = a+b;

			if(a > b) {
				scoreA += sum;
			} else if(a < b) {
				scoreB += sum;
			} else {
				scoreA += a;
				scoreB += b;
			}
		}

		cout << scoreA << " " << scoreB << endl;
	}
	return 0;
}

C++: #include<iostream>

int main() {

	int n;

	int a[1000];

	int b[1000];

	for (int i = 0; i < 1000; i++){
		a[i] = 0;
	b[i] = 0;
}

	int x, y;

	int j=0;

	f:

	std::cin >> n;

	if (n == 0)
		goto flag;

	for (int i = 0; i < n; i++) {
		std::cin >> x >> y;
		if (x > y)
			a[j] += (x + y);
		if (x < y)
			b[j] += (x + y);
		if (x == y){
			a[j] += x;
		b[j] += y;
	}
	}

	j++;

	goto f;

flag:

	for(int i=0;i<j;i++)
	std::cout << a[i] << ' ' << b[i] << std::endl;

	return 0;

}

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

C++: #ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;

int main ()
{
	int N;
	while( cin >> N , N )
	{
		int a , b , c=0 , d=0;
		for( size_t i = 0; i < N; i++ )
		{
			cin >> a >> b;
			if( a == b )
			{
				c += a;
				d += b;
			}else a < b ? d += a + b : c += a + b;
		}
		cout << c << " " << d << endl;
	}
}

C++: #include<cstdio>
int main()
{
    int n,A=0,B=0,a,b;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d%d",&a,&b);
        if(a>b)A=A+a+b;
        else if(a<b)B=B+a+b;
        else
        {
            A+=a;
            B+=b;
        }
    }
    printf("%d %d\n",A,B);
    return 0;
}

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

int main() {
	int a;
	while (cin >> a, a) {
		int A = 0, B = 0;
		for (int b = 0; b < a; b++) {
			int c, d;
			cin >> c >> d;
			if (c > d)A += c + d;
			else if (c < d)B += c + d;
			else { A += c; B += d; }
		}
		cout << A << " " << B << endl;
	}
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<string>

using namespace std;

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

int main(){
	while(1){
	int n;
	scanf("%d",&n);
	if(n==0)break;
	int a=0,b=0;
	rep(i,n){
		int f,g;
		scanf("%d%d",&f,&g);
		
		if(f<g){
			a+=f+g;
		}
		if(f>g){
			b+=f+g;
		}
		if(f==g){
			a+=f;
			b+=g;
		}
	}
	printf("%d %d\n",b,a);
	}
}

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

int main(){
  int n;
  while(cin >> n && n){
    int A=0,B=0;
    for(int i=0;i<n;i++){
      int a,b;
      cin >> a >> b;
      if(a > b) A += a + b;
      else if(a < b) B += a + b;
      else {
	A += a;
	B += b;
      }
    }
    cout << A << ' '<< B << endl;
  }
}

C++: #include<iostream>
using namespace std;
int main(){
	int maisuu, a[15000], b[15000], a_p = 0, b_p = 0;
	cin >> maisuu;
	if (maisuu == 0){
		return 1;
	}
	for (int i = 0; i < maisuu; i++){
		cin >> a[i];
		cin >> b[i];
	}
	for (int i = 0; i < maisuu; i++){
		if (a[i] < b[i]){
			b_p += a[i] + b[i];
		}
		else if (a[i]>b[i]){
			a_p += a[i] + b[i];
		}
		else if (a[i] == b[i]){
			a_p += a[i];
			b_p += b[i];
		}
	}
	cout << a_p << " " << b_p << endl;
	return 0;
}

C++: #include <cstdio>
using namespace std;
int main()
{
	int a=0,b=0,n,x,y;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d %d",&x,&y);
		if(x>y) a+=x+y;
		else if(x<y) b+=x+y;
		else{
			a+=x;
			b+=y;
		}
	}
	printf("%d %d\n",a,b);
	return 0;
}

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