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>
using namespace std;
int main(){
	int pa=0, pb=0;

	int n;

	while(cin >> n){
	int a[n], b[n];
	for(int i=0; i<n; i++){
		cin >> a[i] >> b[i];
	}
	for(int i=0; i<n; i++){
		if(a[i]>b[i]) pa+=a[i]+b[i];
		if(a[i]<b[i]) pb+=a[i]+b[i];
	}
	cout << pa << " " << pb << endl;
	}
return 0;
}

C++: 
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int scA=0;
  int scB=0;
  while(1){
  cin>>n;
  if(n==0)break;
  for(int i=0;i<n;i++){
    int a,b;
    cin>>a>>b;
    if(a>b)scA+=a+b;
    if(a<b)scB+=a+b;
    if(a==b){
      scA+=a;
      scB+=b;
    }
  }
    cout<<scA<<' '<<scB<<endl;
  }

  return 0;
  
}

C++: #include <iostream>

int main() {
    int n = 100;
    while (n != 0) {
        std::cin >> n;
        int a[n];
        int a_point = 0;
        int b_point = 0;

        if (n == 0) {
            return 0;
        } else {
            for (int i = 0; i < 2 * n; i++) {
                std::cin >> a[i];
            }

            for (int i = 0; i < 2*n; i=i+2) {
                if (a[i] > a[i+1]) {
                    a_point += a[i] + a[i+1];
                } else if (a[i] < a[i+1]) {
                    b_point += a[i] + a[i+1];
                } else {
                    a_point += a[i];
                    b_point += a[i+1];
                }
            }
        }
        std::cout << a_point << " " << b_point << std::endl;
    }
}

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

int main(void)
{
  while (true){
    int n;
    int a_ans = 0, b_ans = 0;
    int a, b;

    cin >> n;
    if (n == 0) break;

    for (int i = 0; i < n; i++){
      cin >> a >> b;

      if (a > b){
        a_ans += a + b;
      }
      else if (a < b){
        b_ans += a + b;
      }
      else{
        a_ans += a;
        b_ans += b;
      }
    }

    cout << a_ans << " " << b_ans << endl;
  }

  return 0;
}

C++: #include<iostream>
#include<vector>
int main() {
	int vec=0;
	int n;
	int a=0;
	int b=0;
	int game_a, game_b;
	std::vector<int>veca, vecb;
	while (1) {
		std::cin >> n;
		if (n == 0)break;
		else {
			for (int i = 0; i < n; ++i) {
				std::cin >> game_a>>game_b;
				if (game_a == game_b) { a += game_a; b += game_b; }
				else if (game_a > game_b)a += game_a + game_b;
				else b += game_a + game_b;
			}
			veca.push_back(a); vecb.push_back(b); a = 0; b = 0;
		}
	}
	for (int i = 0; i < veca.size(); ++i) {
		std::cout << veca[i] <<" "<<vecb[i]<< std::endl;
	}
	return 0;
}

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

int main(){
while(1){
int n;
cin >> n;
if(n == 0)break;
int a=0,b=0,c=0;
for(int i=0;i<n;i++){
int x,y;
cin >> x >> y;
if(x>y)a+=x+y;
else if(x<y)b+=x+y;
else c+=x;
}
cout << a+c << " " << b+c << endl;
}
}

C++: #include "stdio.h"

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

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

C++: #include <iostream>

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

	return 0;
}

C++: #include <iostream>

using namespace std;

int main() {

	int n, a, b, c, d;

	while(1) {
		cin >> n;
		if(n==0)
			break;
		a=0;
		b=0;
		while(n!=0) {
			cin >> c >> d;
			if(c>d)
				a+=c+d;
			else if(c<d)
				b+=c+d;
			else {
				a+=c;
				b+=d;
			}
	
			n--;
		}
		cout << a << " " << b << endl;
	}


	return 0;

}

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

C++: #include <iostream>
#define N 1000
using namespace std;
int main(){
    int n, scoreA, scoreB;
    while(cin >> n, n != 0){
        scoreA = 0; scoreB = 0;
        int a,b;
        for (int i = 0; i < n; i++){
            cin >> a >> b;
            if (a > b){
                scoreA += (a+b);
            }else if (b > a){
                scoreB += (a+b);
            }else{
                scoreA += a; scoreB += b;
            }
        }
        cout << scoreA << " " << scoreB << endl;
    }
    return 0;
}

C++: #include <cstdio>
int main(){
 int asum,bsum,a,b,n,i;
 asum=bsum=0;
 scanf("%d",&n);
 for(i=0;i<n;i++){
  scanf("%d %d",&a,&b);
  if (a>b) asum += a+b;
  if (a<b) bsum += a+b;
  if (a==b) { asum += a; bsum += b; }
 };
 printf("%d %d\n",asum,bsum);
 return 0;
};

C++: #include <stdio.h>

const int MAX_N=10000;
int a[MAX_N];
int b[MAX_N];
int n;
int A=0;int B=0;
void solve(){
	for(int i=0;i<n;i++){
		if(a[i]>b[i]){
			A+=a[i]+b[i];
		}
		else if(a[i]<b[i]){
			B+=a[i]+b[i];
		}
	}
}
int main(){
 while(1){
	scanf("%d",&n);
	if(n==0){
		break;
	}
	for(int i=0;i<n;i++){
	scanf("%d%d",&a[i],&b[i]);
	}
	solve();
	printf("%d %d\n",A,B);
 }
   return 0;
}

C++: #include <iostream>
#include <cstdio>
using namespace std;
int main(){
	int n,a,b;
	int num=0,sum=0;

	while(cin >> n, n){
	for(int i=0; i<n; i++){

		cin >> a >> b;

		if(a > b){
			
			num+=a+=b;
		}
		else if(a < b){
			
			sum+=b+=a;
		}
		else if(a == b){

			num+=a;
			sum+=b;
		}
	}

	cout << num << " " << sum << endl;
}
	return 0;
}

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

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

int main() {

	//ifstream cin("INPUT.txt");
	//ofstream cout("OUTPUT.txt");

	int n, a, b, ap, bp, i;

	while(cin >> n, n) {

		ap = 0; bp = 0;
		for(i = 0; i < n; i++) {
		cin >> a >> b;
			if(a < b) {
				bp += a;
				bp += b;
			} else if(b < a) {
				ap += a;
				ap += b;
			} else {
				ap += a;
				bp += b;
			}
		}

		cout << ap << " " << bp << endl;

	}

	return 0;

}

C++: #include <iostream>

using namespace std;

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