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, pointA, pointB;

  cin >> n;
  while(n != 0) {
    

    pointA = 0;
    pointB = 0;

    for(int i = 0; i < n; i++) {
      cin >> a >> b;
 
      if(a > b) {
        pointA += (a + b);
      } else if(a > b) {
        pointB += (a + b);
      } else {
        pointA += a;
        pointB += b;
      }

    cout << a << ' ' << b << ' ' << endl;
    cin >> n;
  }   
 
  return 0;
}

C++: #include <iostream>

using namespace std;

int main(int argc, char const* argv[])
{
  int n, score_a, score_b, a, b;
  while (cin >> n) {
    if (n == 0) break;

    score_a = 0;
    score_b = 0;

    for (int i = 0; i < n; i++) {
      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;
  }
  return 0;
}

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

int main() {
	int n;
	while(1){
		cin >> n;
		if(n == 0) break;
		int a[10000], b[10000], A=0, B=0;
		for(int i=0; i<n; i++){
			cin >> a[i] >> b[i];
			int sum = a[i]+b[i];
			if(a[i]>b[i]) A += sum;
			if(a[i]==b[i]){
				A += a[i];
				B += b[i];
			}
			if(a[i]<b[i]) B += sum;
		cout << A << ' ' << B << endl;	
		}
		cout << A << ' ' << B << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>

using namespace std;

int main()
{
	
	while(1)
	{
		int aSum(0),bSum(0);
		int n;

		cin >> n;
		
		if(n == 0)
			break;
		
		cout << endl;

		for(int i = 0;i < n;i++)
		{
			int a,b;
			cin >> a >> b;
		
			if(a > b){
				aSum += a + b;
			}else if(a < b){
				bSum += a + b;
			}else{
				aSum += a;
				bSum += b;
			}
		}
		cout << aSum << " " << bSum << " ";
	}
	return 0;
}

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

int main()
{
	int n,p[10000],r[10000],pt[10000] = {0},rt[10000] = {0},j = 0,count = 0;

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

		count++;

		for(int i=0; i<n; i++){
			cin>>p[i]>>r[i];
			if(p[i] > r[i])
				pt[j] = pt[j] + p[i] + r[i];
			else if(p[i] < r[i])
				rt[j] = rt[j] + p[i] + r[i];
			else{
				pt[j] += p[i];
				rt[j] += r[i];
			}
		}
		j++;
	}
	for(int k=0; k<count; k++)
		cout<<pt[k]<<" "<<rt[k]<<endl;

	return 0;

}

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  while(cin >> n, n) {
    int A = 0, B = 0;
    rep(i, n) {
      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;
  }

  return 0;
}

C++: #include <stdio.h>

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

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

  return 0;
}

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

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
#include <cstdio>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  int n;
  int sa,sb;
  while(cin>>n,n){
  sa = sb = 0;
  while(n--){
    int a,b;
    cin>>a>>b;
    if(a>b){
      sa += a + b;
    }else if(a == b){
      sa += a;
      sb += b;
    }else{
      sb += a + b;
    }
  }

  cout<< sa << " " << sb << endl;
  }
}

C++: #include <iostream>
int main()
{
	int card;
	std::cin >> card;
	int a[10000], b[10000];
	int ascore = 0, bscore = 0;
	for (int i = 0; i < card; i++) {
		std::cin >> a[i] >> b[i];
		if (a[i] > b[i]) {
			ascore = ascore + (a[i] + b[i]);
		}
		else if (b[i] > a[i]) {
			bscore = bscore + (a[i] + b[i]);
		}
		else {
			ascore = ascore + a[i];
			bscore = bscore + b[i];
		}
	}
	std::cout << ascore << " " << bscore << std::endl;
	return 0;
}

C++: #include <iostream>

int score_a, score_b;

int main(void)
{
    using namespace std;
    int n, data_a, data_b;

    while(1)
    {
        cin >> n;
        if(!n) break;
        score_a = 0;
        score_b = 0;
        for(; n > 0 ; n--) {
            cin >> data_a;
            cin >> data_b;
            if (data_a > data_b) {
                score_a += (data_a + data_b);
            } else if(data_a < data_b) {
                score_b += (data_a + data_b);
            } else {
                score_a += data_a;
                score_b += data_b;
            }
        }
        cout << score_a << " " << score_b << endl;
    }

    return 0;
}

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

int main() {
    int N=0;
    cin >> N;
    vector<int> A(N), B(N);
    for(int i=0; i<N; ++i) cin >> A[i] >> B[i];

    int ret_a=0, ret_b=0;
    for(int i=0; i<N; ++i) {
        if(A[i] < B[i]) {
            ret_b += A[i]+B[i];
        } else if(A[i] > B[i]) {
            ret_a += A[i]+B[i];
        } else {
            ret_a += A[i]; ret_b = B[i];
        }
    }
    cout << ret_a << " " << ret_b << endl;
}

C++: //https://onlinejudge.u-aizu.ac.jp/challenges/sources/JOI/Prelim/0500?year=2006

#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;
    while (cin >> n, n) {
        int sumA = 0, sumB = 0;
        for (int i = 0; i < n; ++i) {
            int a, b;
            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 n;
	int a[10001] , b[10001];
	int scoreA=0 , scoreB=0;
	int i;
	while(1){
		cin>>n;
		if(n==0) break;
		for(i=0 ; i<n ; i++){
			cin >> a[i] >> b[i];
			if(a[i]>b[i]){
				scoreA+=a[i]+b[i];
			} else if (a[i]<b[i]){
				scoreB+=a[i]+b[i];
			} else {
				scoreA+=a[i];
				scoreB+=b[i];
			}
		}
		cout << scoreA << " " << scoreB << endl;
	}
	return 0;
}