Go: package main

import (
	"fmt"
)

// Game is one game.
type Game struct {
	pointA, pointB int
}

func main() {
	var n int
	game := &Game{0, 0}
	fmt.Scanf("%d", &n)
	for n != 0 {
		game.initGame()
		game.execGame(n)
		game.printResult()
		fmt.Scanf("%d", &n)
	}
}

func (game *Game) execGame(n int) {
	var a, b int
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a)
		fmt.Scanf("%d", &b)
		switch {
		case a == b:
			game.pointA += a
			game.pointB += b
		case a > b:
			game.pointA += a + b
		case b > a:
			game.pointB += a + b
		}
	}
}

func (game *Game) initGame() {
	game.pointA = 0
	game.pointB = 0
}

func (game *Game) printResult() {
	fmt.Println(game.pointA, game.pointB)
}

C++: #include<iostream>

int main(){
	int n,A_point,B_point,A,B;
	std::cin>>n;
	for(int i=0;i<n;++i){
		std::cin>>A>>B;
		if(A>B)
			A_point+=A+B;
		else if(A==B){
			A_point+=A;
			B_point+=B;
		}
		else B_point+=A+B;
	}
	std::cout<<A_point<<' '<<B_point<<std::endl;
	return 0;
}

C++: #include <iostream>

using namespace std;

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

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

int main() {
	int q[10001], w[10001];
	
	int x = 1;
	while (1) {
		int n;
		int a = 0;
		int b = 0;
		cin >> n;
		if (n == 0) {
			break;
		}

		for (int i = 1; i <= n; ++i) {
			int c, d;
			cin >> c >> d;
			if (c == d) {
				a = a + c;
				b = b + d;
			}
			else if (c > d) {
				a = a + c + d;
			}
			else {
				b = b + c + d;
			}
		}
		q[x] = a;
		w[x] = b;
		x = x + 1;
	}
	for (int j = 1; j <= x-1; ++j) {
		cout << q[j]<< w[j] << endl;
	}
}

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;
}