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 <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;
}

C++: #include <iostream>
#include <set>
#include <cmath>

using namespace std;
typedef unsigned short Int;
typedef set<Int> Set;

static const Int MAX = (Int)(-1);
Set P;

void makeprimes(){
  P.insert(2);
  Int n = 3;
  while(n != MAX){
    Int rt = sqrt(n);
    Set::iterator it = P.begin();
    bool isprime = true;
    while(1){
      if(n%(*it) == 0){
        isprime = false;
        break;
      }
      if(rt < *it){
        break;
      }
      ++it;
    }
    if(isprime){
      P.insert(n);
    }
    n+=2;
  }
}

int main(void){
  makeprimes();
  Int n;
  while(cin >> n , n){
    int c = 0;
    if(P.find(n-2) != P.end()){
      c++;
    }
    for(Int i = 3; i <= n/2; i += 2){
      if(P.find(i) != P.end() && P.find(n-i) != P.end()){
        c++;
      }
    }
    cout << c << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
 
#define ascent(i, a, b) for(int (i) = (a); (i) < (b); (i) ++)

using namespace std;

int main() {
  int n;
  while(true) {
    cin >> n;
    if(n == 0) break;

    int a, b;
    int pa = 0, pb = 0; 
    while(n) {
      cin >> a >> b;
      if(a > b) {
	pa += a + b;
      }
      else if(a < b) {
	pb += a + b;
      }
      else {
	pa += a;
	pb += b;
      }
      n --;
    }

    cout << pa << " " << pb << endl;
  }
      
  return 0;
}

C++: #include <cstdio>
#include <algorithm>
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);}
		if(x<y) {b+=(x+y);}
		if(x==y){
			a+=x;
			b+=y;
		}
	}
	printf("%lld %lld\n",a,b);
	return 0;
}

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

int main(){
	int i;
	int N,a,b,scorsole= 0;
	int score[1000][2] = {0};
	while(1){
		cin >> N;
		if(N == 0)
			break;
		for(i = 0;i < N;i++){
			cin >> a >> b;
			if(a > b)
				score[scorsole][0] += a+b;
			else if(a == b){
				score[scorsole][0] = a;
				score[scorsole][1] = b;
			}
			else
				score[scorsole][1] += a+b;
		}
		scorsole++;
	}
	for(i = 0;i < scorsole;i++){
		cout << score[i][0] << " " << score[i][1] << endl;
	}
	return 0;
}

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

C++: #include <iostream>
int main(){
	int n=0,A=0,B=0;
	std::cin>>n;
	for(int i=0;i<n;i++){
		int a=0,b=0;
		std::cin>>a>>b;
		int ab=a+b;
		if(a>b){
			A+=ab;
		}else{
			if(a<b){
				B+=ab;
			}
		}
	}
	std::cout<<A<<" "<<B<<std::endl;
	return 0;
}

C++: #include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
  int a,b,n;
  int ai,bi;
  while(cin>>n,n){
	  a=b=0;
	  for(int i=0;i<3;i++)
	  {
		  cin>>ai>>bi;
		  if(ai>bi) a+=ai+bi;
		  else if(bi>ai) b+=ai+bi;
		  else{
			  a+=ai;
			  b+=bi;
		  }
	  }
	 printf("%d %d\n",a,b);
  }
    return 0;
}

C++: #include<iostream>
using namespace std;
int i, n, pA, pB, tA = 0, tB = 0;
int main(){
while(cin >> n) {
if(n == 0) { break; }
for (i=1; i<=n; i++) {
cin >> pA >> pB;
if (pA > pB) {
tA += pA + pB;
} else {
if (pA < pB) {
tB += pA + pB;
} else {
tA += pA;
tB += pB;
}
}
}
cout << tA << "" << tB << endl;
tA = 0; tB = 0;
}
return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <iostream>

using namespace std;

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

C++: #include<iostream>
#include<math.h>
#include <string>
#include <stack>
#include<stdio.h>
#include <queue> 
#include <functional>
#define rep(i,n) for (int i=0; i < (int)(n); i++)

using namespace std;

int main(){
	
	stack<int> st; // スタックを宣言＋初期化
	
	int i,j,k;
	int arr[100];
	string str;
	stack<int> intStack; // 整数値を格納するスタックを宣言
    stack<string> strStack; // 文字列を格納するスタックを宣言	
	queue<int> ique; // 整数値を格納するキューを宣言
	
	while(1){
		int a=0,b=0,c=0,d=0,e=0,num;
	cin >> num;
	
	if (num==0) return 0 ;
	
	rep(i , num){
		
		cin >>  a >> b ;
		
		if(a < b ) d += a + b;
		else if(b < a) c+= a+ b;
		else{
			c+= a;
			 d+=a;
		}
		 
	}
	
	cout << c << " " << d << endl;
	}
		
	return 0;
		
}

C++: #include <iostream>
int main(){
	int n=0,A=0,B=0;
	while(std::cin >> n, n){
		for(int i=0;i<n;i++){
			int a=0,b=0;
			std::cin>>a>>b;
			int ab=a+b;
			if(a>b){
				A+=ab;
			}else{
				if(a<b){
					B+=ab;
				}else{
					A+=a;
					B+=b;
				}
			}
		}
		std::cout<<A<<" "<<B<<std::endl;
		A=0,B=0;
	}
	return 0;
}

C++: def main():
    while 1:
        n = input()
        if n == 0:
            break

        sum_a = 0
        sum_b = 0
        
        for i in range(n):
            a,b = map(int, raw_input().split())

            if a > b:
                sum_a = sum_a + a + b
            elif a < b:
                sum_b = sum_b + a + b
            elif a == b:
                sum_a = sum_a + a
                sum_b = sum_b + b

        print("%s %s" %(sum_a,sum_b))
        return 0
                
if __name__ == "__main__":
    main()

C++: #include<iostream>

using namespace std;

int main(){

  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    int A=0,B=0;
    //??????????????°??????????????¨???
    for(int i=0;i<n;i++){
      int a,b;
      cin>>a>>b;    
      if(a>b)A+=a+b;
      if(a<b)B+=a+b;
      if(a==b){
	A+=a;
	B+=b;
      }
    }
    cout<<A<<" "<<B<<endl;
  }




  return 0;
}

C++: #define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
  
using namespace std;
  
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
  
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)c.size())
 
typedef unsigned long long ull;
const int INF = (int)1e8;
 
int main(){
    int n;
    while(cin>>n,n){
        int a=0,b=0;
        FOR(i,n){
            int x,y; cin>>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;
}