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>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	for(int n;cin>>n,n;){
		int a=0,b=0;
		rep(i,n){
			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;
	}
	
	return 0;
}

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

int main(){
  int a, b;
  int n;
  while(cin >> n, n){
    int A, B;
    A = B = 0;
    for(int i = 0  ;i < n ; i++){
      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;
  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

int main(){
	int n;
	
	while(cin>>n,n){
		int totalA=0,totalB=0;
		for(int i=0;i<n;i++){
			int a,b;
			cin>>a>>b;
			if(a>b){
				totalA+=a+b;
			}
			else if(b>a){
				totalB+=a+b;
			}
			else{
				totalA+=a;
				totalB+=b;
			}
		}
		cout<<totalA<<" "<<totalB<<endl; 
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
	int n;
	int a,b;
	int sa=0,sb=0;//score
	
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a>>b;
		if(a<b){sb+=(a+b);}
		else if(a>b){sa+=(a+b);}
		else
		{
			sa+=a;
			sb+=b;
		}
	}
	cout<<sa<<" "<<sb<<"\n";
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

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

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen ("testcase.card0500", "r", stdin );
	string str = "";
	int n;

	while (getline (cin, str ) ){
		stringstream ssn(str);
		ssn >> n;
		if (n == 0 ){
			break;
		} // end if
		int sumA = 0, sumB = 0;
		int i;

		for (i = 0; i < n; ++i){
			int cardA = 0, cardB = 0;
			getline (cin, str );
			stringstream ss(str);
			
			ss >> cardA >> cardB;
			if (cardA > cardB ){
				sumA += (cardA + cardB);
			}else if (cardA < cardB){
				sumB += (cardA + cardB);
			}else{
				sumA += cardA;
				sumB += cardB;
			} // end if
		} // end for
		cout << sumA << ' ' << sumB << endl;

	} // end loop
	
	return 0;
}

C++: #include <iostream>

int main(void){
	int *cardsA,*cardsB;
	int cardNum,tempA,tempB,pointA=0,pointB=0,i=0;
while(true){
	std::cin >> cardNum;
	if(cardNum==0) return 0;
	cardsA=new int[cardNum];
	cardsB=new int[cardNum];
	for(;i<cardNum;++i){
		std::cin >> tempA >> tempB;
		cardsA[i]=tempA;
		cardsB[i]=tempB;
	}
	i=0;
	for(;i<cardNum;++i){
		if(cardsA[i]>cardsB[i]) pointA+=cardsA[i]+cardsB[i];
		if(cardsB[i]>cardsA[i]) pointB+=cardsA[i]+cardsB[i];
		if(cardsA[i]==cardsB[i]){
			pointA+=cardsA[i];
			pointB+=cardsA[i];
		}
	}
	std::cout << pointA << " " << pointB << std::endl;
	i=0;
	pointA=0;
	pointB=0;
	delete cardsA;
	delete cardsB;
}
	return 0;
}

C++: #include <stdio.h>

int main()
{
	int A,B,a,b,i,n;
	while(1){
	scanf("%d",&n);
	if(n==0) {break;}
	A=0;
	B=0;
	for(i=1;i<n+1;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;
}

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

int main() {
	int aten = 0,bten = 0,a,b;
	int n;
	cin >> n;
	while(true){
		if(n == 0){
			break;
		}
		cin >> a >> b;
		if(a > b){
			aten = aten + a + b;
		}
		else if(a == b){
			aten = aten + a;
			bten = bten + a;
		}
		else{
			bten = bten + b + a;
		}


	}
	cout << aten << " " << bten << endl;
	return 0;
}

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

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

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

int main()
{
	int n;
	int i;
	
	while(1)
	{
		cin >> n;
		if(n == 0) break;
		int as=0,bs=0;
		for(i=0;i<n;i++)
		{
			int a =0,b = 0;
			cin >> a >> b;
			if(a==b)
			{
				as += a;
				bs += b;
			}
			else if(a>b)
			{
				as += (a+b);
			}
			else
			{
				bs += (a+b);
			}
		}
		cout << as << " " << bs << endl;

	}
	
	return 0;
}

C++: 
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <algorithm>

using namespace std;


bool solve(){
	int n;
	cin>> n;
	if(!n) return false;

	int a=0,b=0;
	for(int i=0;i<n;i++){
		int x,y;
		cin>> x>> y;
		if(x==y){
			a+=x;
			b+=y;
		}
		x>y ? a+=(x+y) : b+=(x+y);
	}
	cout<< a<< " "<< b<< endl;
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	while(solve()){};

	return 0;
}

C++: #include <stdio.h>

int main(int ac, char** av) {
  int n, score_a = 0, score_b = 0;
  scanf("%d", &n);
  int *a = (int*) malloc(sizeof(int) * n);
  int *b = (int*) malloc(sizeof(int) * n);
  int i;
  for(i = 0; i < n; i++) {
    scanf("%d %d", a+i, b+i);
  }
  for(i = 0; i < n; i++) {
    if(a[i] > b[i]) {
      score_a += a[i] + b[i];
    } else if(a[i] < b[i]) {
      score_b += a[i] + b[i];
    } else if(a[i] == b[i]) {
      score_a += a[i];
      score_b += b[i];
    }
  }
  printf("%d %d\n", score_a, score_b);
  free(a);
  free(b);
  return 0;
}