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 <cstdio>

using namespace std;

#define FOR( i, n ) for( int i = 0; i < n; ++i )

int main( void )
{
	int point_a = 0;
	int point_b = 0;

	while( 1 )
	{

	int n;
	scanf( "%d", &n );

	if( n == 0 )
		break;

	FOR( i, n )
	{
		int a, b;
		scanf( "%d %d", &a, &b );

		if( a > b )
		{
			// AÌ¿
			point_a += a+b;
		}
		else
		{
			if( a == b )
			{
				// ø«ª¯
				point_a += a;
				point_b += b;
			}
			else
			{
				// BÌ¿
				point_b += a+b;
			}
		}

	}

	// Ê
	printf( "%d %d\n", point_a, point_b );

	}

	return 0;
}

C++: #include <iostream>

using namespace std;

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

C++: #include<iostream>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,a=0,b=0,da,db;
  while(1){
  cin>>n;
  if(n==0) break;
  for(int i=0;i<n;i++){
    cin>>da>>db;
    if(da>db) a+=da+db;
    if(da<db) b+=db+da;
    if(da==db){
      a+=da;
      b+=db;
    }
  }
  cout<<a<<" "<<b<<endl;
  a=0;
  b=0;
  }
  return 0;
}

C++: #include<cstdio>
int main(){
    int ai,bi,as=0,bs=0,n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d%d",ai,bi);
        if(ai>bi) as+=ai+bi;
        else if(ai<bi) bs+=ai+bi;
        else{
            as+=ai;
            bs+=bi;
        }
    }
    printf("%d %d\n",as,bs);
}

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

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

C++: #include <iostream>
using namespace std;
 
int main() {
    int n;
    cin >> n;
    int num[10000][2] = {};
    int score[2] = {};

    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < 2; ++j){
            cin >> num[i][j];
        }
        if (num[i][0] > num[i][1])
        {
            score[0] += num[i][0] + num[i][1];
        } else if (num[i][0] == num[i][1])
        {
            score[0] += num[i][0];
            score[1] += num[i][1];
        } else{
            score[1] += num[i][0] + num[i][1];
        }
    }

    cout << score[0] << " " << score[1] << endl;

    return 0;
}

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

using namespace std;

int main(){
	int n;
	while(scanf("%d",&n)){
		if(n==0)
		break;
		int a,b,suma=0,sumb=0;
		for(int i=0;i<n;i++){
			scanf("%d %d",&a,&b);
			if(a>b)
			suma+=a+b;
			else if(b>a)
			sumb+=a+b;
			else{
				suma+=a;
				sumb+=b;
			}
		}
		printf("%d %d\n",suma,sumb);
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n,a,b,countA=0,countB=0;
    cin>>n;
    if(n!=0){
    do{
        for(int i=0;i<n;i++){
            cin>>a>>b;
            if(a>b){
                countA+=(a+b);
            }else if(a<b){
                countB+=(a+b);
            }//a==b
        }
        cout<<countA<<" "<<countB;
        cout<<"\n";
        countA=0,countB=0;
        cin>>n;
        if(n==0)break;
    }while(1);
    }
    cout<<endl;
}

C++: #include<cstdio>

int n;

int main(){
	int A,B,Aanswer=0,Banswer=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d %d",&A,&B);
		if(A>B)Aanswer+=A+B;
		else if(A<B)Banswer+=A+B;
		else{
			Aanswer+=A;
			Banswer+=B;
		}
	}
	printf("%d %d\n",Aanswer,Banswer);
	return 0;
}

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

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

C++: #define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
typedef pair <int,PP> PPP;

static const double eps = 1e-8;

int main(){
	int n;
	while(~scanf("%d",&n)){
		if(n==0) break;
		int lSum=0,rSum=0;
		for(int i=0;i<n;i++){
			int lhs,rhs;
			scanf("%d %d",&lhs,&rhs);
			if(lhs > rhs) lSum += lhs + rhs;
			else if(lhs < rhs) rSum += lhs + rhs;
			else if(lhs == rhs){
				rSum += rhs;
				lSum += lhs;
			}
		}

		printf("%d %d\n",lSum,rSum);
	}
}

C++: #include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n,a,b,x=0,y=0;
  while(n!=0){
    cin>>n;
    if(n==0)continue;
    rep(i,n){
      cin>>a>>b;
      if(a==b){
	x+=a;
	y+=b;
      }
      else if(a>b)x+=(a+b);
      else if(a<b)y+=(a+b);
    }
    cout<<x<<" "<<y<<endl;
    x=0;
    y=0;
  }
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b,aa=0,ab=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a>>b;
    if(a>b){
      aa+=a+b;
    }
    if(a<b){
      ab+=a+b;
    }
    if(a==b){
      aa+=a;
      ab+=b;
    }
  }
  cout<<aa<<' '<<ab<<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;
			if (a == b){ p0 += a; p1 += a; }
			if (a<b) p1 += a + b;
		}
		cout << p0 << ' ' << p1 << endl;
	}
}

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

int main()
{

	int n;
	int a=0,b=0;
	int ac,bc;

	cin >> n;

	while(n > 0){
		n--;
		cin >> ac >> bc;
		if(ac > bc)
			a += ac + bc;
		else if(ac < bc)
			b += ac + bc;
		else
			a += ac, b = bc;
	}
	printf("%d %d\n", a,b);


	return 0;
}

C++: #include <iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;

int main()
{
    int  a=0,b=0,a1=0,b1=0,i=0,n=0,j=0;
    for(i=1;;i++){
        cin >> n;
        if(n==0)break;
        for(j=0;j<n;j++){
            cin >> a >> b;
            if(a>b){
                a1+=a+b;
            }
            if(a<b){
                b1+=a+b;
            }
            if(a==b){
                a1+=a;
                b1+=b;
            }

        }
        cout << a1 << ' ' << b1 <<endl;
        a1=b1=0;
    }
    //cout << b;
}

C++: #include <stdio.h>
int main(void)
{
	int a[100], i, j, m, n, b[100], A = 0, B = 0;
	while (1) {
		scanf("%d", &n);
		if (n == 0) {
			break;
		}
		for (i = 0; i < n; i++) {
			scanf("%d %d", &a[i], &b[i]);
		}
		for (i = 0; i < n; i++) {
			if (a[i] > b[i]) {
				A = A + a[i] + b[i];
			}
			else if (a[i] == b[i]) {
				A = A + a[i];
				B = B + b[i];
			}
			else {
				B = B + a[i] + b[i];
			}
		}
		printf("%d %d \n", A, B);
		A = 0;
		B = 0;
	}
}

C++: #include <iostream>

using namespace std;

int main(){
  int n,l,r,a,b;
  while(cin>>n,n){
    a=b=0;
    while(n--){
      cin>>l>>r;
      if(l==r){
	a+=l;b+=l;
      }
      else (r<l)?a+=l+r:b+=l+r;
    }
    cout<<a<<' '<<b<<endl;
  }
  return 0;
}