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;
    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;
            } else if(a < b) {
                B += a+b;
            } else {
                A += a;
                B += b;
            }
        }
        cout << A << " " << B << endl;
    }
}

C++: #include<iostream>

using namespace std;

int main()
{
	int kai,abe,isazi,abesum,isazisum;

	cin >> kai;
	while (kai!=0)
	{
		abesum = isazisum = 0;
		for (int i = 0; i < kai; i++)
		{
			cin >> abe;
			cin >> isazi;
			if (abe > isazi)
			{
				abesum += abe + isazi;
			}
			else if (abe<isazi)
			{
				isazisum += abe + isazi;
			}
			else if (abe == isazi)
			{
				abesum += abe;
				isazisum += isazi;
			}
		}
		cout << abesum << " " << isazisum << endl;
		cin >> kai;
	}

	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#include <cmath>
#include <cstdio>
using namespace std;

#define PI 4*atan(1);

int main(){
  int n;
  while(cin >> n && n != 0){
    int a, b, asum = 0, 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;
  }
}

C++: #include <iostream>

using namespace std;

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

C++: #include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const ll MOD = (ll) (1e9 + 7);
//const ll MOD = 998244353;
const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

void finish() {
    cout << -1 << endl;
    exit(0);
}

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << setiosflags(ios::fixed);


    int n;
    int a_sum, b_sum;

    while (1) {
        cin >> n;
        if (n == 0) break;
        a_sum = 0, b_sum = 0;

        rep(i, n) {
            int a, b;
            cin >> a >> b;
            if (a > b) a_sum += a + b;
            else if (a < b) b_sum += a + b;
            else a_sum += a, b_sum += b;
        }
        cout << a_sum << " " << b_sum << endl;
    }

    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>
int main(){
 long asum,bsum,a,b,n,i;
 scanf("%ld",&n);
 while(n>0){
 asum=bsum=0;
 scanf("%ld",&n);
 for(i=0;i<n;i++){
  scanf("%ld %ld",&a,&b);
  if (a>b) asum += a+b;
  if (a<b) bsum += a+b;
  if (a==b) { asum += a; bsum += b; }
 };
 printf("%ld %ld\n",asum,bsum);
 scanf("%ld",&n);
 }
 return 0;
};

C++: #include<iostream>
using namespace std;
int main() {
	int a[100] = { 0 }, b[100] = { 0 };
	int x;
	int n, m;
	int j = 0;
	int length;
	while (true) {
		cin >> x;
		if (x == 0){
			length = j;
			break;
		}
		for (int i = 0; i < x; i++) {
			cin >> n >> m;
			if (n > m) {
				a[j] += n + m;
			}
			else  if (n < m) {
				b[j] += n + m;
			}
			else {
				a[j] += n;
				b[j] += m;
			}
		}
		j++;
	}
	for (int i = 0; i < length; i++){
		cout << a[i] << " " << b[i] << endl;
	}
	char c;
	cin >> c;
}

C++: #include <iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	while(n!=0){
		int point[2];
		enum {
			A,
			B,
		};
		int sum[2] = {0,0};
		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>
using namespace std;

int A = 0, B = 0, j;

int main(){
    for(;;){
        if(cin >> j){
            if(j == 0){
                break;
            }
            for(int i = 0; i < j; i++){
                int as, bs;
                cin >> as >> bs;
                if(as > bs){
                    A += as + bs;
                }else if(as < bs){
                    B += as + bs;
                }else{
                    A += as;
                    B += bs;
                }
            }
            cout << A << " " << B << endl;
        }else{
            break;
        }
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)

int main() {
    int n, a, b;
    while(cin >> n, n){
        a = 0;
        b = 0;
        REP(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;
            }
        }
        cout << a << " " << b << endl;
    }
    return 0;
}

C++: #include<iostream>

using namespace std;

int main()
{
	int n;
	int a[10000], b[10000];
	int a_score = 0;
	int b_score = 0;
	int i;
	
	cin >> n;		//J[hÌ
	
	for(i = 0;i < n; i++){
		cin >> a[i];
		cin >> b[i];
		if((a[i] == 0)||(b[i] == 0)){
			break;
		}
	}
	
	for(; i > -1; i--){
		if(a[i] > b[i]){
			a_score += a[i] + b[i];
		}
		else if(a[i] < b[i]){
			b_score += a[i] + b[i];
		}
		else{
			a_score += a[i];
			b_score += b[i];
		}
	}
	cout << a_score << " " << b_score << endl;
}

C++: #include <stdio.h>

int main(void)
{

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

	scanf("%d", &n);

	for(int i = 0; i < n; i++){
		
		if(scanf("%d %d", &ac,&bc) == EOF)
			break;
		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;
}