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 <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int N=0;
    while(cin >> N && N!=0) {
        vector<int> A(N), B(N);
        for(int i=0; i<N; ++i) cin >> A[i] >> B[i];

        int ret_a=0, ret_b=0;
        for(int i=0; i<N; ++i) {
            if(A[i] < B[i]) {
                ret_b += A[i]+B[i];
            } else if(A[i] > B[i]) {
                ret_a += A[i]+B[i];
            } else {
                ret_a += A[i]; ret_b = B[i];
            }
        }
        cout << ret_a << " " << ret_b << endl;
    }
}

C++: #include <iostream>

int main(int argc, char **argv)
{
	int a, b;
	int n;
	int acards[10000],bcards[10000];
	while(true){
		a = 0;
		b = 0;
		std::cin >> n;
		if(n == 0){
			break;
		}
		for(int i = 0; i < n; i++){
			std::cin >> acards[i] >> bcards[i];
			if(acards[i] < bcards[i]){
				b += bcards[i] + acards[i];
			}
			if(acards[i] > bcards[i]){
				a += bcards[i] + acards[i];
			}
			if(acards[i] == bcards[i]){
				a += acards[i];
				b += bcards[i];
			}
		}
		std::cout << a << " " << b << std::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;
			continue;
		}
		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<iostream>
#include<cstdio>

using namespace std;

int main(){
	int lim;
	
	while( cin >> lim, lim != 0){
		int a = 0, b = 0;
		while(lim-- > 0){
			int n, m;
			cin >> n >> m;
			(n == m)? a+=n, b+=m:
			(n > m)? a += n+m: b += n+m;
		}
		printf("%d %d\n", a, b);
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
int n,a,b,pa,pb;
pa=0;pb=0;
cin>>n;
for(;;){
for(int i=0;i<n;i++){
cin>>a;
cin>>b;
if(a==b){pa+=a; pb+=a;}
if(a>b){pa+=a+b;}
if(a<b){pb+=a+b;}
}
if(n==0){break;}
cout<<pa<<" "<<pb<<endl;
}

return 0;
}

C++: #include<iostream>

int main(){
	while(1){
		int n;
		std::cin >> n;
		if(n == 0)break;
		int a = 0, b = 0;
		for(int i = 0; i < n; ++i){
			int a1,b1;
			std::cin >> a1 >> b1;
			if(a1 > b1) a += a1 + b1;
			else if(a1 < b1) b += a1 + b1;
			else a += a1, b += b1;
		}
		std::cout << a << " " << b << std::endl;
	}
	return 0;
}

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

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

using namespace std;

int main(){
	while(1){
		string str;
		getline(cin,str);
		int n = atoi(str.c_str());
		if(n==0)break;
		int scoreA = 0, scoreB = 0;
		while(n--){
			getline(cin,str);
			stringstream ss(str);
			string tmp;
			getline(ss,tmp,' ');
			int a = atoi(tmp.c_str());
			getline(ss,tmp);
			int b = atoi(tmp.c_str());
			if(a>b)scoreA+=(a+b);
			else if(b>a) scoreB+=(a+b);
			else{
				scoreA+=a;
				scoreB+=b;
			}
		}
		cout<<scoreA<<" "<<scoreB<<endl;
	}
	return 0;
}

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

int main(){
    int n;
    while(cin>>n){
        if(n==0)break;
        int ans1=0;
        int ans2=0;
        int num,sum;
        for(int i=0; i<n; i++){
            cin>>num>>sum;
            if(num>sum){
                ans1+=num;
                ans1+=sum;
            }
            if(num<sum){
                ans2+=num;
                ans2+=sum;
            }
            if(num==sum){
                ans1+=num;
                ans2+=sum;
            }
        }
        cout<<ans1<<" "<<ans2<<endl;
    }
    return 0;
}

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

int main(int argc, char* argv[]) {
  int ina, inb, n;
  cin >> n;
  while(n != 0){
    int a=0, b=0;
    for(int i=0;i<n;i++){
      cin >> ina >> inb;
      if(ina > inb){
        a += ina+inb;
      }else if(ina < inb){
        b += ina+inb;
      }else{
        a += ina;
        b += inb;
      }
    }
    cout << a << " " << b << endl;
    cin >> n;
  }

  return 0;
}

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

C++: #include<iostream>
using namespace std;
static const int N = 10000;

int main() {
	int n;
	int i;
	int A[N];
	int B[N];
	int score_A = 0;
	int score_B = 0;

	cin >> n;
    
	for (i = 0; i < n; i++) {
		cin >> A[i];
		cin >> 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("A????????????%d,B????????????%d", score_A, score_B);

	return 0;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000009
#define EPS 1E-9

int n;
int a, b;

int main()
{
  while((cin >> n) && n){
    int res[2] = {0};
    while(n--){
      cin >> a >> b;

      if(a >  b){ res[0] += a + b;  continue; }
      if(a <  b){ res[1] += a + b;  continue; }
      res[0] += a;
      res[1] += b;
    }

    cout << res[0] << " " << res[1] << endl;
  }

  return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int n;
	int a[3]={0};
	int b[3]={0};
	int A,B;
	for(int i=0;i<5;i++){
		cin>>n;
		if(n==0){break;}
		for(int j=0;j<n;j++){
			if(a[j]>b[j]){
				A+=a[j]+b[j];
			}
			else if(a[j]<b[j]){
				B+=a[j]+b[j];
			}
			else if(a[j]==b[j]){
				A+=a[j];
				B+=b[j];
			}
		}
		cout<<A<<" "<<B<<endl;
	}
	return 0;
}