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 n,a,b;
	int suma,sumb;
	while(cin>>n,n){
		suma=sumb=0;
		for(int i=0; i<n; i++){
			cin>>a>>b;
			if      ( a<b ){
				sumb += a+b;
			}else if( a>b ){
				suma += a+b;
			}else{
				suma += a;
				sumb += b;
			}
		}
		printf("%d %d\n",suma,sumb);
	}
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

int main(){
    int n;
    scanf("%d\n", &n);
    vector<int> a(n), b(n);
    for(int i=0;i<n;++i) scanf("%d %d\n", &a[i],&b[i]);
    int as=0, bs=0;
    for(int i=0;i<n;++i){
        if(a[i]>b[i])as+=a[i]+b[i];
        else if(a[i]<b[i])bs+=a[i]+b[i];
        else {as+=a[i];bs+=b[i];}
    }
    printf("%d %d\n", as,bs);
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <queue>
#include <stack>
#include <set>

using namespace std;

#define ALL(co) co.begin(), co.end()
#define tpl(...) make_tuple(__VA_ARGS__)

typedef long long LL;
typedef pair<int, int> P; typedef pair<int, P> IP; typedef pair<P, P> PP;
typedef vector<int> Array; typedef vector<vector<int> > Array2;
typedef vector<LL> LArray; typedef vector<P> PArray; typedef vector<string> SArray;

const int INF = 1 << 29;
const LL LINF = 1LL << 60;

inline int getInt() { int itiv; return (cin >> itiv, itiv); }
template <typename T> void readAll(vector<T>& vec) { for (int i = 0, size = vec.size(); i < size; i++) cin >> vec[i]; }
template <typename T, typename U> void readAll(vector<pair<T, U> >& vec) { for (int i = 0, size = vec.size(); i < size; i++) cin >> vec[i].first >> vec[i].second; }
template < typename T > inline string toString( const T &a ){ ostringstream oss; oss << a; return oss.str(); };
inline bool between(int min, int max, int n) { return min <= n && n <= max; }
inline bool inRange(int begin, int end, int n) { return begin <= n && n < end; }
inline bool inRange(int size, int n) { return 0 <= n && n < size; }

int dx[] = { -1, 0, 1, 0 }, dy[] = { 0, -1, 0, 1 };
int dr[] = { 0, -1, 0, 1 }, dc[] = { -1, 0, 1, 0 };

int m, n;

int main(void)
{
	ios::sync_with_stdio(false);
	while(cin >> n && n)
	{
		int a = 0, b = 0;
		for (int i = 0; i < n; i++)
		{
			int ta, tb;
			cin >> ta >> tb;
			if(ta == tb) {}
			else if(ta > tb)
			{
				ta += tb;
				tb = 0;
			}
			else
			{
				tb += ta;
				ta = 0;
			}
			a += ta;
			b += tb;
		}

		cout << a << ' ' << b << endl;
	}
	return 0;
}

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

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

C++: #include <iostream>

using namespace std;

int main()
{
	int n, a, b, bt, at;

	while (cin >> n){
		at = bt = 0;

		for (int i = 0; i < n; i++){
			cin >> a >> b;
			if (a < b) bt += a + b;
			else at += a + b;
		}
		cout << at << " " << bt << endl;
	}
	return (0);
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a,b;
    a=b=0;
    while(n--){
        int x,y;
        cin>>x>>y;
        if(x>y)a+=x+y;
        else if(x<y)b+=x+y;
        else {
            a+=x;
            b+=x;
        }
    }
    return 0;
}

C++: #import<cstdio>
int main(){int n,a,b,x,y,i;for(;x=y=0,scanf("%d",&n),n;printf("%d %d\n",x,y))for(i=n;scanf("%d%d",&a,&b),i;--i)(a-b)?x+=a,y+=b:(a>b?x:y)+=a+b;}

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

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

int main(){
	int n,a,b;
	long suma=0,sumb=0;
	do{
		cin >> n;
		for(int i=0;i<n;i++){
			cin >> a >> b;
			if(a>b) suma+=a+b;
			else if(a<b) sumb+=a+b;
			else{suma+=a;sumb+=b;}
		}
		printf("%ld %ld\n",suma,sumb);
	}while(n!=0);
	return 0;
}

C++: #include<stdio.h>
#include<stdlib.h>
void judge(int n, int a[], int b[], int *result1, int *result2) {
	while (--n >= 0) {
		if (a[n] > b[n]) {
			*result1 += a[n] + b[n];
		}
		else if (a[n] < b[n]) {
			*result2 += a[n] + b[n];
		}
		else if (a[n] == b[n]) {
			*result1 += a[n];
			* result2 += b[n];
		}
	}
}
int main() {
	int a[10];
	int b[10];
	int n, t = 0;
	int result1 = 0, result2 = 0;
	int result[10][2];
	do {
		scanf_s("%d", &n);
		for (int i = 0; i < n; i++) {
			scanf_s("%d %d", &a[i], &b[i]);
		}
		judge(n, a, b, &result1, &result2);
		result[t][0] = result1;
		result[t][1] = result2;
		result1 = 0;
		result2 = 0;
		t++;
	} while (n != 0);

	for (int i = 0; i < t-1;i++) {
		printf("%d %d\n", result[i][0], result[i][1]);
	}

	return 0;
}

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

C++: #include <iostream>

using namespace std;

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

C++: #include <stdio.h>

int main () {
    int a, b, n, scorea, scoreb;
    while (1) {
        scanf("%d", &n);
        if (n == 0) break;

        scorea = scoreb = 0;
        while (n--) {
            scanf("%d %d", &a, &b);
            if (a == b) {
                scorea += a;
                scoreb += b;
            }
            else if (a > b) {
                scorea += a + b;
            } else {
                scoreb += a + b;
            }
        }
        printf("%d %d\n", scorea, scoreb);
    }

    return 0;
}

C++: #include<stdio.h>

int main(void){
	
	while(1){
		int n;
		int p1,p2;
		scanf("%d",&n);
		if(n==0){
			break;
		}
		p1=p2=0;
		for(int i=0;i<n;i++){
			int a,b;
			scanf("%d%d",&a,&b);
			if(a>b){
				p1+=a+b;
			}else if(a<b){
				p2+=a+b;
			}else{
				p1+=a;
				p2+=b;
			}
		}
		printf("%d %d\n",a,b);
	}
	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()