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>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    while(cin >> n, n)
    {
        int A = 0, B = 0;
        for(int i = 0; i < n; i++)
        {
            int a, b;
            cin >> a >> b;
            if(a == b)
            {
                A += a;
                B += b;
            }
            else if(a > b)
            {
                A += a + b;
            }
            else
            {
                B += a + b;
            }
        }
        cout << A << " " << B << endl;
    }
    return 0;
}

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

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

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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)+1):((m)-(n)+1)),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long INTEGER;
typedef double FLOAT;

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

int main()
{
entry:;

  int n; cin >> n;

  if (!n) return 0;

  int A = 0;
  int B = 0;
  rep (i, n) {
    int a, b; cin >> a >> b;
    if (a > b) {
      A += a + b;
    } else if (a == b) {
      A += a;
      B += b;
    } else {
      B += a + b;
    }
  }
  cout << A << ' ' << B << endl;

  goto entry;

  return 0;
}

C++: #include<iostream>
#include<vector>
#include<queue>
#include<vector>
#include<map>
#include<algorithm>

using namespace std;

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

		int a = 0;
		int b = 0;
		for (int i = 0; i < n; ++i) {
			int s, t;
			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>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <set>
#include <cmath>
#include <map>


int main(int,char**){
	int n;
	int a,b;
	while(std::cin >> n){
		if(!n) break;
		int aScore(0),bScore(0);
		while(n--){
			std::cin >> a>>b;
			if(a==b) 
				aScore+=a,bScore+=b;
			else if(a>b)
				aScore+=(a+b);
			else 
				bScore+=(a+b);
		}
		std::cout << aScore << ' ' << bScore << std::endl;
	}
	return 0;
}

C++: #include<stdio.h>

int main{
	int n;
	int A=0;
	int B=0;
	int i=0;
	scanf("%d", &n);
	int x[n];
	int y[n];
	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>
#include <string>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <stdlib.h>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		if(n==0) break;
		int a[n],b[n],at=0,bt=0;
		for(int i=0;i<n;i++){
			cin>>a[i]>>b[i];
			if(a[i]>b[i]){
				at=at+a[i]+b[i];
			}
			else if(a[i]==b[i]){
				at=at+a[i];
				bt=bt+b[i];
			}
			else{
				bt=bt+a[i]+b[i];
			}
		}
		cout<<at<<" "<<bt<<endl;
	}
    return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	while(n!=0)
		int point[2];
		enum {
			A,
			B,
		};
		int sum[2] = {};
		for (int i = 0; i < n; i++) {
			cin>>point[A]>>point[B];
			if (point[A]>point[B]) {
				for (auto j : point) {
					sum[A]+=j;
				}
			} else if(point[A] == point[B]) {
				for (auto j : sum) {
					j+=point[A];
				}
			} else {
				for (auto j : point) {
					sum[B]+=j;
				}
			}
		}
		cout<<sum[A]<<" "<<sum[B]<<endl;
		cin>>n;
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cstring>
#define rep(i,j) FOR(i,0,j)
#define FOR(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int main(){
	int n;
	while(cin>>n,n){
		int a=0,b=0,c,d;
		rep(i,n){
			cin>>c>>d;
			if(c>d)a+=c+d;
			else if(c<d)b+=c+d;
			else{
				a+=c;
				b+=d;
			}
		}
		cout<<a<<" "<<b<<endl;
	}
}

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

using namespace std;

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

  
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	while (true){
		int n, A[10000] = {}, B[10000] = {}, tenA = 0, tenB = 0;
		cin >> n;
		if (n == 0) break;
		for (int i = 0; i < n; i++){
			cin >> A[i] >> B[i];
			if (A[i] > B[i]){
				tenA += A[i] + B[i];
			}
			if (A[i] == B[i]){
				tenA += A[i];
				tenB += B[i];
			}
			if (A[i] < B[i]){
				tenB += A[i] + B[i];
			}
		}
		cout << tenA << ' ' << tenB << endl;
	}
	return 0;
}

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

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

C++: #include <stdio.h>
 
int main(){
 int n;
 scanf("%d",&n);
 while(n){
  int a=0,b=0,aa,bb;
  for(int i=n;i>0;i--){
   scanf("%d %d",&aa,&bb);
   if(aa>bb){
    a+=aa+bb;
   }else if(aa<bb){
    b+=aa+bb;
   }else{
    a+=aa;
    b+=bb;
   }
  }
  printf("%d %d\n",a,b);
  scanf("%d",&n);
 }
}

C++: #include <algorithm>
#include <cstdio>
#include <functional>

using namespace std;

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


    }
    return 0;

}

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