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 <iostream>
using namespace std;
    
int n, a, b, sa, sb;
    
int main(){
  for(;;){
    sa = 0;
    sb = 0;
    cin >> n;
    if(n == 0){
      break;
    }else{
      for(int i = 0; i < n; i++){
        cin >> a >> b;
        if(a < b){
          sb += a + b;
        }else if(a > b){
          sa += b + a;
        }else if(a == b){
          sa += a;
          sb += b;
        }
      }
      cout << sa << " " << sb << endl;
    }
  }
  return 0;
}

C++: #include <stdio.h>

int n, A[11234], B[11234];
int ans[2];

int main(void) {
	while (true) {
		scanf("%d", &n);
		for (int i = 0; i < n; ++i) { scanf("%d%d", &A[i], &B[i]); }

		for (int i = 0; i < n; ++i) {
			if (A[i] > B[i]) { ans[0] += A[i] + B[i]; }
			else if (A[i] < B[i]) { ans[1] += A[i] + B[i]; }
			else { ans[0] += A[i], ans[1] += B[i]; }
		}

		printf("%d %d\n", ans[0], ans[1]);
	}
	return 0;
}

C++: #include <iostream>
#define N 1000
using namespace std;
int main(){
    int n, scoreA, scoreB;
    while(cin >> n, n != 0){
        scoreA = 0; scoreB = 0;
        int a,b;
        for (int i = 0; i < n; i++){
            cin >> a >> b;
            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 <sstream>
#include <stdio.h>
#include <vector>
#include <string>
using namespace std;

int main(void) {
	int a=0,b=0,n=1;
	long ra = 0,rb = 0;
	vector<string> r;
	while (n!=0)
	{
	cin >> n;
	if (n == 0){break;}
	for (int i=0; i<n; i++)
	{
		scanf("%d %d",&a,&b);
		if (a>b)
		{
			ra+=a+b;
		} else if(a<b)
		{
			rb+=a+b;
		} else {
			ra+=a;
			rb+=b;
		}
	}
	ostringstream os;
	os << ra << " " << rb;
	r.push_back(os.str());
	}
	for (int i=0; i<r.size(); i++)
	{
		cout << r[i] << endl;
	}
	return 0;
}

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

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

struct player{
    int point;
    int card[10000];
    inline player(){point = 0;}
};

int main()
{
    int loop = 1;
    player a, b;
    while(1) {
        cin >> loop;
        if(loop == 0) break;
        for(int c = 0; c < loop; c++)
        {
            cin >> a.card[c];
            cin >> b.card[c];
        }

        for(int c = 0; c < loop; c++)
        {
            if(a.card[c] < b.card[c])
            {
                b.point += a.card[c] + b.card[c];
                continue;
            }
            if(a.card[c] == b.card[c])
            {
                 a.point += a.card[c];
                 b.point +=b.card[c];
                 continue;
            }
            a.point += a.card[c] + b.card[c];
        }
     cout << a.point << " " << b.point << endl;   
    }
    return EXIT_SUCCESS;
}

C++: #include <iostream>
using namespace std;
int main(){
	int n;
	do{
		cin >> n;
		if(n != 0)
		{
			int a[n], b[n], aRes = 0, bRes = 0;
		
			for (int i = 0; i < n; ++i)
			{
				cin >> a[i] >> b[i];
				if(a[i] > b[i])
				{
					aRes += (a[i] + b[i]);
				}
				else if(a[i] < b[i])
				{
					bRes += (a[i] + b[i]);
				}
				else{
					aRes += a[i];
					bRes += b[i];
				}
			}
		
			cout << aRes << " " << bRes;
		}
	}while(n != 0);
}

C++: #include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;

int main()
{
	int num, wk, tk, A, B;

	while( cin >> num )
	{
		if(!num) break;
		A = 0; B = 0;

		for(int i = 0; i < num; i++)
		{
			cin >> wk >> tk;
			if(wk > tk)
			{
				A += wk + tk;
			}
			else if(wk < tk) 
			{
				B += wk + tk;
			}
			else
			{
				A += wk;
				B += tk;
			}
		}

		printf("%d %d\n", A, B);
		
	}
}

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

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

int main(){
	int a;
	int uma;
	int ushi;
	int b;
	int c;
	int i;
	while (true){
		cin >> a;
		if (a == 0){ break; }
		else{
			for (i < a; i++){
				cin >> b;
				cin >> c;
				if (b>c){
					uma = uma + b + c;
				}
				if (b == c){
					uma = uma + b;
					ushi = ushi + c;
				}
				else{
					ushi = ushi + b + c;
				}
			}
		}
		cout << uma << " " << ushi << endl;
		uma = 0;
		ushi = 0;
		i = 0;
	}
}

C++: #include<iostream>

using namespace std;

int main(void) {
	int num, a, b;
	int resa, resb;
	int i;

	while(true) {
		cin >> num;
		if(num == 0) { break; }
		resa = resb = 0;
		for(i = 0; i < num; i++) {
			cin >> a >> b;
			if(a > b) { resa += a + b; }
			else if(a < b) { resb += a + b; }
			else { resa += a; resb += b; }
		}
		cout << resa << " " << resb << endl;
	}

	return 0;
}

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

int main(void)
{
	int n;
	int a_sum = 0;
	int b_sum = 0;
	
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++){
		int a, b;
		scanf("%d %d", &a, &b);
		
		if (a == b){
			a_sum += a;
			b_sum += b;
		}
		else if (a > b){
			a_sum = a_sum + a + b;
		}
		else {
			b_sum = b_sum + a + b;
		}
	}
	
	printf("%d %d\n", a_sum, b_sum);
	
	return (0);
}

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

int main(){
  int n;
  while(scanf("%d\n", &n)){
    int asum = 0, bsum = 0, a[10000], b[10000];
    if(n == 0) return 0;

    for(int i = 0;i < n;i++) scanf("%d %d\n", &a[i], &b[i]);
    for(int i = 0;i < n;i++){
      if(a[i] > b[i]) asum += a[i]+b[i];
      else if(a[i] < b[i]) bsum += a[i]+b[i];
      else {
         asum += a[i];
         bsum += b[i];
      }
   }
   printf("%d %d\n", asum, bsum);
  }
}

C++: /*
 * 500.cpp
 *
 *  Created on: 2012/06/24
 *      Author: shimomire
 */
#include <iostream>
#include<string>
#include <complex>
#include<list>
#include<float.h>
#include <functional>
#include <vector>
#include <map>
#include <queue>

using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define REP0(i,n)   REP(i,0,n)
#define foreach(it,o) for(__typeof((o).begin()) it=(o).begin(); it!=(o).end(); ++it)
typedef complex<double> P;
bool operator <(const P& a, const P& b) {
	return abs(a) < abs(b);
}
int n;

int main(){
	while(true){
		cin >> n;
		if(n==0){
			break;
		}
		int ap=0,bp=0;
		REP0(i,n){
			int tmpa,tmpb;
			cin>> tmpa>> tmpb;
			if(tmpa>tmpb){
				ap+=tmpa+tmpb;
			}else if(tmpa< tmpb){
				bp+=tmpa+tmpb;
			}else{
				ap+=tmpa;
				bp+=tmpb;
			}
		}
		cout<< ap<< " "<< bp<< endl;
	}
}

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

int main(){
	int n,a,b;
	long suma=0,sumb=0;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a >> b;
		if(a>b) suma+=a+b;
		else sumb+=a+b;
	}
	cout << suma << " " <<  sumb << endl;
}