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 <bits/stdc++.h>
using namespace std;

#define times(n, i)      uptil(0, n, i)
#define upto(f, t, i)    for(decltype(t) _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(decltype(t) _##i = (t), i = (f); i < _##i; i++)
#define downto(f, t, i)  for(decltype(t) _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(decltype(t) _##i = (t), i = (f); i > _##i; i--)
#define unless(c) if(!(c))
#define until(c) while(!(c))
#define loop while(true)

#define all(v) v.begin(), v.end()
#define ln << "\n"

struct line{};

template<class T> istream& operator>>(istream& in, vector<T>& v) {
    times(v.capacity(), i) in >> v[i];
    return in;
}

template<class T> const ostream& operator<<(ostream& out, const vector<T>& v) {
    times(v.size(), i) out << (i ? " " : "") << v[i];
    return out;
}

template<class T, class...U> typename enable_if<is_same<T, line>::value, string>::type next(istream& in, const U&... args) {
    string s;
    getline(in, s, args...);
    return move(s);
}

template<class T, class...U> typename enable_if<!is_same<T, line>::value, T>::type next(istream& in, const U&... args) {
    T t(args...);
    in >> t;
    return move(t);
}
template<class T, class...U> auto next(const U&... args) -> decltype(next<T>(cin)) {
    return next<T>(cin, args...);
}

template<class T> T sum(const vector<T>& v) {
    T ans = T();
    for(const T& t : v) ans += t;
    return ans;
}

template<class T> T sum(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    T ans = T();
    for(typename vector<T>::iterator t = begin; t != end; t++) ans += *t;
    return ans;
}

template<class T> T min(const vector<T>& v) {
    return *min_element(v.begin(), v.end());
}

template<class T> T min(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    return *min_element(begin, end);
}

template<class T> T max(const vector<T>& v) {
    return *max_element(v.begin(), v.end());
}

template<class T> T max(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    return *max_element(begin, end);
}

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

    loop {
        int a = 0, b = 0, N = next<int>();
        unless(N) break;

        times(N, _) {
            int x = next<int>(), y = next<int>();
            if(x >= y) a += x;
            else       b += x;
            if(x <= y) b += y;
            else       a += y;
        }
        cout << a << " " << b ln;
    }

    return 0;
}

C++: #include<stdio.h>
int main(void)
{
    int i,a,b,c,d,e;
	while(1){
	scanf("%d",&a);
	if(a==0) break;
	d=0; e=0;
	for(i=0;i<a;i++){
	scanf("%d %d",&b,&c);
	if(b==c){
	d+=b;
	e+=c;
	}
	else if(b>c){
	d+=b+c;
	}
	else if(b<c){
	e+=b+c;
	}
	}
	}
	printf("%d %d\n",d,e);
	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]);
      A[0]={0},B[0]={0};
    }
  }
}

C++: #include<iostream>

using namespace std;

int main()
{
	while (1){
		int kaisu, ten1 = 0, ten2 = 0;
		cin >> kaisu;
		if (kaisu == 0)break;
		while (kaisu--)
		{
			int x, y;
			cin >> x >> y;
			if (x > y)
			{
				ten1 += x + y;
			}
			else if (x < y)
			{
				ten2 += x + y;
			}
			else
			{
				ten1 += x;
				ten2 += y;
			}
		}
		cout << ten1 << " " << ten2 << endl;;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main() {
	int n = 0;
	int aa, bb = 0;
	while (cin >> n, n != 0) {
		aa = 0;
		bb = 0;
		int a[10000] = {};
		int b[10000] = {};


		for (int i = 0; i < n; i++) {
			cin >> a[i] >> b[i];
		}
		for (int j = 0; j < n; j++) {
			if (a[j] > b[j]) {
				aa += a[j] + b[j];
			}
			else if (a[j] < b[j]) {
				bb += a[j] + b[j];
			}
			else if (a[j] == b[j]) {
				aa += a[j];
				bb += b[j];
			}
		}
		cout << aa << " " << bb << endl;

	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main() {
	int n,a,b;
	while (cin >> n && n) {
		int suma = 0, sumb = 0;
		for (int i = 1; i <= n; ++i) {
			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<iostream>
using namespace std;

int main() {
	int num;
	int score_a = 0;
	int score_b = 0;
	
	cin >> num;
	while (num != 0) {
		for (int i = 0; i < num; i++) {
			int a;
			int b;

			cin >> a >> b;
			if (a > b) {
				score_a += a + b;
			}else if (b > a) {
				score_b += a + b;
			}else {
				score_a += a;
				score_b += b;
			}
		}
		cout << score_a << " " << score_b << endl;
		score_a = 0;
		score_b = 0;
	}

	return 0;
}

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

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

C++: #include<iostream>
using namespace std;
int i, n, pA, pB, tA = 0, tB = 0;
int main () {
    whole(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<iostream>
using namespace std;
int main(){
  int n,m,t,mt,tt;
  while(cin>>n){
    if(n==0) break;
    mt = 0;
    tt = 0;
    for(int i=0;i<n;i++){
      cin >> m >> t;
      if(m>t) mt += (m+t);
      else if(t>m) tt += (m+t);
      else{
	mt += m;
	tt += t;
      }
    }
    cout << mt << ' ' << tt << endl;
  }
  return 0;
}

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

int main(){
    int n;
    int a_point = 0, b_point = 0;

    cin >> n;
    for(int i=1; i<=n; i++){
        int tmp1, tmp2;
        cin >> tmp1 >> tmp2;
        if(tmp1 > tmp2){
            a_point += tmp1 + tmp2;
        }else if (tmp1 < tmp2){
            b_point += tmp1 + tmp2;
        }else{
            a_point += tmp1;
            b_point += tmp2;
        }
    }
    cout << a_point << " " << b_point << endl;
    return 0;
}

C++: 3
9 1
5 4
0 8
3
9 1
5 4
1 0
3
9 1
5 5
1 8
0

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

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

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