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(){
  int i,k;
  k=0;
  int a,b;
  int suma[99],sumb[99];
  suma[99] = {};
  sumb[99] = {};
  while(1){
    int n;
    cin>>n;
    if(n==0) break;
    for(i=0;i<n;i++){
      cin>>a>>b;
      if(a>b) suma[k]=a+b+suma[k];
      if(a<b) sumb[k]=a+b+sumb[k];
      if(a==b){
        suma[k]=a+suma[k];
        sumb[k]=b+sumb[k];
      }
  }
  k++;
 }
  for (i = 0; i < k;i++) {
   cout<<suma[i]<<" "<<sumb[i]<<endl;
 }
 return 0;
}

C++: #include <cstdio>

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

C++: #include <iostream>
#include <cassert>
#define REP(i,l,n) for(int i=l;i<n;++i)
#define rep(i,n) REP(i,0,n)
int ansA,ansB;
int n;
int a,b;
using namespace std;
int main() {
  while(1){
    cin >> n;
    if(n==0) return 0;
    ansA = 0;
    ansB = 0;
    rep(i,n){
      cin >> a;
      cin >> b;
      if(a>b){
        ansA += a+b;
      }else if(b>a){
        ansB += a+b;
      }else{
        ansA += a;
        ansB += b;
      }
    }

    cout << ansA << " " << ansB << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  while (true) {
    int n; cin >> n;
    if (n == 0) break;
    V<> a(n), b(n); for (int i = 0; i < n; ++i) cin >> a[i] >> b[i];
    int sa = 0, sb = 0;
    for (int i = 0; i < n; ++i) {
      if (a[i] == b[i]) {
        sa += a[i];
        sb += b[i];
      } else {
        (a[i] > b[i] ? sa : sb) += a[i] + b[i];
      }
    }
    cout << sa << ' ' << sb << '\n';
  }
}

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

C++: #include <iostream>
using namespace std;
int main(){

	int n, a, b, ap = 0, bp = 0;

	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a >> b;

		//?????°?????´??°
		if (a > b)
			ap += a + b;
		else if (a < b)
			bp += a + b;
		else{
			ap += a;
			bp += b;
		}
	}

	cout << ap << ' ' << bp << endl;
}

C++: #include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cfloat>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define EACH( v, c ) for ( auto &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

int main()
{
	cin.tie( 0 );
	ios::sync_with_stdio( false );

	while ( true )
	{
		int n;
		cin >> n;

		if ( !n )
		{
			break;
		}

		int res1 = 0, res2 = 0;

		REP( i, 0, n )
		{
			int a, b;
			cin >> a >> b;

			if ( a == b )
			{
				res1 += a;
				res2 += b;
			}
			else if ( a < b )
			{
				res2 += a + b;
			}
			else
			{
				res1 += a + b;
			}
		}
		
		cout << res1 << ' ' << res2 << endl;
	}

	return 0;
}

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

int main() {
	int n;
	int a = 0, b = 0;

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

C++: #include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	while(cin>>n)
	{
		if(n == 0)
			break;
			
		int scoreA = 0, scoreB = 0;
		for(int i =0;i<n;i++)
		{
			int a, b;
			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>
using namespace std;

int main() {
	int suma, sumb, a, b, n;
	while (1) {
		suma = sumb = 0;
		cin >> n;
		if (n == 0) break;
		
		while (n--) {
			cin >> a >> b;
			if (a > b)
				suma += a + b;
			else if (a < b)
				sumb += a + b;
			else {
				suma += a;
				sumb += b;
			}
		}
		cout << suma << ' ' << sumb << 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);
      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>
using namespace std;
 
int main(){
	int a;
	int uma;
	int ushi;
	int b;
	int c;

	cin >> a;
	for (int i; i < a; i++){
		cin >> b;
		cin >> c;
		if (b>c){
			uma = uma + 2;
		}
		if(b=c){
			uma = uma + 1;
			ushi = ushi + 1;
		}
		else{
			ushi = ushi + 2;
		}
	}
	cout << uma << ushi;

}

C++: #include <cstdio>

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

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

C++: #include<stdio.h>

int main(){

int N;int A,B,SA=0,SB=0;
while(1){
SA=0,SB=0;

scanf("%d",&N);
if(N==0)break;
for(int i=0;i<N;i++){
scanf("%d %d",&A,&B);
if(A>B)SA=SA+A+B;
else if(B>A)SB=SB+A+B;
else SA+=A;SB+=B;
}

printf("%d %d\n",SA,SB);
}
return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	while(true){
  int a=0,b=0,N,Card[2];
  cin >> N;
  if(N==0)
 	break;
  for(int i=0;i<N;i++){
  	cin >> Card[0] >> Card[1];
  	int sum=Card[0]+Card[1],truth=(Card[0]>Card[1]);
  	a+=sum*truth;
  	b+=sum*!(truth);
  }
  cout << a << " "<< b << endl;
	}
  return 0;
}