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 main(void){
    int n, a, b, total_a, total_b;
    while(1){
        cin >> n;
        if(n == 0){
            break;
        }
        total_a = 0;
        total_b = 0;
        for(int i=1; i<=n; i++){
            cin >> a >> b;
            if(a > b){
                total_a += a + b;
            }
            else if(b > a){
                total_b += a + b;
            }
            else{
                total_a += a;
                total_b += b;
            }
        }
        cout << total_a << " " << total_b << endl;
    }
    return 0;
    
}

C++: #include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
  int n;
  while (true) {
    cin >> n;
    if (n == 0)
      break;
    int a = 0, b = 0, s, t;
    for (int i = 0; i < n; i++) {
      cin >> s >> t;
      if (s > t) {
        a += s + t;
      } else if (s < t) {
        b += s + t;
      } else {
        a += s;
        b += t;
      }
    }
    cout << a << ' ' << b << endl;
  }
  return 0;
}

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

int main(){
	for (;;){
		int n;
		cin >> n;
		if (n == 0) return 0;

		int p0=0, p1=0;

		for (int i = 0; i < n; ++i){
			int a, b;
			cin >> a >> b;
			if (a>b) p0 += a + b;
			else p1 += a + b;
		}
		cout << p0 << ' ' << p1 << endl;
	}
}

C++: #include<stdio.h>

int main(){
	int n;
	int A=0;
	int B=0;
	int i=0;
	scanf("%d", &n);
	int x[10000];
	int y[10000];
	while(i<n){
	scanf("%d", &x[i]);
	scanf("%d", &y[i]);
	++i;
}
	i=0;
	while(i<n){
	if(x[i]>y[i]){
	A=A+x[i]+y[i];
}else {
	if(x[i]<y[i]){
	B=B+x[i]+y[i];
}else{
	A=A+x[i];
	B=B+y[i];
			}
		}
	++i;
	}
	printf("%d %d\n", A, B);
}

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

int n, a, b, sa, sb;

int main(){
  for(;;){
    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{
            sa += a;
            sb += b;
          }
        }
        cout << sa << " " << sb;
      }
    }
  return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
  int a,b,n;
  int i;
  int ans=0,ans1=0;
  while(1){
    cin >> n;
    if(n==0)break;
    for(i=0;i<n;i++){
      cin >> a >> b;
      if(a>b){
	ans=ans+a+b;
      }
      else if(a<b){
	ans1=ans1+a+b;
      }
      else{
	ans+=a;
	ans1+=b;
      }
    }
    cout << ans << ' ' << ans1 << endl;
    ans=0;
    ans1=0;
  }
}

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

int main(){
  int n,i, a,b;

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

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

int main()
{
	int n=0,iCnt=0,iPoint1=0,iPoint2=0,iNum1=0,iNum2=0;

	vector<int> iSum1(10000);
	vector<int> iSum2(10000);

	while( 1 ){
		cin >> n;
		if( n == 0 ){ break; }
		else{
			for( int i=0;i<n;i++ ){
				cin >> iNum1 >> iNum2;
				if( iNum1 > iNum2 ){ iPoint1 += iNum1+iNum2; }
				else if( iNum1 < iNum2 ){ iPoint2 += iNum1+iNum2; }
				else if( iNum1 == iNum2 ){
					iPoint1 += iNum1;
					iPoint2 += iNum2;
				}
			}
			iSum1[iCnt] = iPoint1;
			iSum2[iCnt] = iPoint2;
			iCnt++;
			iPoint1 = 0;
			iPoint2 = 0;
		}
	}

	for( int i=0;i<iCnt;i++ ){
		cout << iSum1[i] << " " <<iSum2[i] << endl;
	}

	return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include "bits/stdc++.h"
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <list>
#define REP(i,a,b) for(i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define SQR(X)  ( (X)*(X) )
#define CUBE(X) ( (X)*(X)*(X) )
 
// #define int ll
 
using namespace std;
 
bool test = 0;
 
/* ?????????????????¬??¨ */
 
int main(){
  int i,j,k,l;
  int n;
  while(scanf("%d",&n) != EOF) {
    if(n == 0) break;
    int score[2] = {0};
    for(i=0;i<n;i++) {
      int num[2];
      cin >> num[0] >> num[1];
      auto sum = num[0]+num[1];
      if(num[0] > num[1]) score[0] += sum;
      else if(num[0] < num[1]) score[1] += sum;
      else {
        for(j=0;j<2;j++) score[i] += num[i];
      }
    }
    printf("%d %d\n",score[0],score[1]);
  }
  return 0;
}

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

using namespace std;


class Puzzle
{
public:


	void input()
	{

	}


	void play()
	{
		int N;

		while (1) {
			cin >> N;
			if (N == 0) return;

			int a = 0;
			int b = 0;
			int A = 0;
			int B = 0;

			for (int li = 0; li < N; li++) {
				cin >> a >> b;
				if (a > b) A = A + a + b;
				if (a < b) B = B + a + b;
				if (a == b) {
					A += a;
					B += b;
				}
			}

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

};


int main()
{
	Puzzle puz;

	puz.input();
	puz.play();

    return 0;
}

C++: #include<iostream>
#define N 10000 
using namespace std;
int main(){
  int a[N],b[N],n,scoreA,scoreB;
  while(cin >> n,n != 0){
   
    scoreA = 0; scoreB =0;
  for(int i = 0;i < n;i++){
    cin >> a[i] >> b[i];
  }
  for(int i = 0;i < n;i++){
    if(a[i] > b[i]){
      scoreA += a[i]+b[i];
    } else if(a[i] < b[i]){
      scoreB += a[i]+b[i];
    } else if(a[i]==b[i]){
      scoreA = scoreA + a[i]; scoreB += b[i];
    }
  }
   
  cout << scoreA <<" " << scoreB << endl;
  }
 
}

C++: #include<stdio.h>
int main(void)
{
	int n;
	int a,b;
	int i;
	int cnt[2];
	scanf("%d",&n);
	for(i=0;i<2;i++)	cnt[i]=0;
	
	for(i=0;i<n;i++){
		scanf("%d %d",&a,&b);
		if(a > b){
			cnt[0]+=a+b;
		}
		else if(a < b){
			cnt[1]+=a+b;
		}
		else{
			cnt[0]+=a;
			cnt[1]+=b;
		}
	}
	printf("%d %d\n",cnt[0],cnt[1]);
	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 tmpa, tmpb;
            cin >>tmpa >>tmpb;
            if(tmpa > tmpb){
                a += (tmpa + tmpb);
            } else if(tmpa == tmpb){
                a += tmpa;
                b += tmpb;
            } else{
                b += (tmpa + tmpb);
            }
        }
        cout <<a <<" " <<b <<endl;
    }
    return 0;
}

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

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

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

using namespace std;

int main(){
	int t = 0;
	while(cin >> t){
		if(t == 0) break;
		int score1 = 0;
		int score2 = 0;
		while(t > 0){
			t --;
			int card1;
			int card2;
			cin >> card1;
			cin >> card2;
			if(card1 > card2)
				score1 += card1 + card2;
			else if (card1 < card2)
				score2 += card1 + card2;
			else{
				score1 += card1;
				score2 += card2;
			}
			
		}
		cout << score1 << " " << score2 << endl;
	}
}