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>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n, a, b;
    while(cin >> n, n){
        int as = 0, bs = 0;
        rep(i,n){
            cin >> a >> b;
            if(a > b){
                as += (a + b);
            }else if(a < b)
                bs += (a + b);
            else{
                as += a;
                bs += b;
            }
        }
        cout << as << ' ' << bs << endl;
    }
}

C++: #include<iostream>
using namespace std;
 
int main(){
	int a;
	int uma;
	int ushi;
	int b;
	int c;

	while (true){
		cin >> a;
		if (a == 0){ break; }
		else{
			for (int i; i < a; i++){
				cin >> b;
				cin >> c;
				if (b>c){
					uma = uma + b + c;
				}
				if (b == c){
					uma = uma + b;
					ushi = ushi + c;
				}
				else{
					ushi = ushi + b + c;
				}
			}
		}
		cout << uma << " " << ushi;
uma=0;
ushi=0;
	}
}

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

int main(){
    while(true){
    int n, getA = 0, getB = 0;
    cin >> n;
    if(n == 0) break;
    int A,B;
    for(int i = 0; i < n; i++){
        cin >> A >> B;
        if( A > B ) getA += A + B;
        else if( A < B ) getB += A + B;
        else{
            getA += A;
            getB += B;
        }
    }
    cout << getA << " " << getB << endl;
    }
    return 0;
}

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

	for(;;){
		cin>>n;
		if(n==0)break;
		ansa=0;
		ansb=0;
		for(int i=0;i<n;i++){
			cin>>a>>b;
			if(a>b){
				ansa=ansa+a+b;
			}
			else if(a<b){
				ansb=ansb+a+b;
			}
			else if(a==b){
				ansa=ansa+a;
				ansb=ansb+b;
			}
		}
		cout<<ansa<<" "<<ansb<<endl;
	}


	return 0;
}

C++: #include <iostream>
#include <functional>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <map>
#include <cmath>

using namespace std;

namespace _{struct _{_(){ // initialize
  cin.tie(0); ios::sync_with_stdio(false);
}}_;}
template <typename T, size_t size>
inline size_t len(const T (&)[size]) { return size; }
#define println(s) cout << s << '\n';
#define str to_string
#define rep(i, n) for (int i=0; i<int(n); i++)
#define all(c) (c).begin(), (c).end()


int main() {
  while (true) {
    int n; cin >> n;
    if (n == 0) break;

    int A = 0;
    int B = 0;
    rep(i, n) {
      int a, b;
      cin >> a >> b;
      if (a == b) {
        A += a; B += b;
      } else if (a > b)
        A += (a+b);
      else
        B += (a+b);
    }

    cout << A << " " << B << endl;
  }
  return 0;
}

C++: #include <iostream>

int main(){
	int n;
	while( std::cin >> n, n ){
		int sum_pt[2] = { 0, 0 };
		int pt[2];

		while( n-- ){
			std::cin >> pt[0] >> pt[1];

			if( pt[0] > pt[1] ){
				sum_pt[0] += pt[0] + pt[1];
			}else if( pt[0] < pt[1] ){
				sum_pt[1] += pt[0] + pt[1];
			}else{
				sum_pt[0] += pt[0];
				sum_pt[1] += pt[1];
			}
		}

		std::cout << sum_pt[0] << " " << sum_pt[1] << std::endl;
	}

	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <cstring>
#include <functional>

using namespace std;

#define REP(i,a,b) for((i)=(a);(i)<(int)(b);(i)++)
#define rep(i,n) REP(i,0,n)
#define foreach(itr,c) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)

int main(){
  int i,j,k,n;

  while(1){
    int ares = 0, bres = 0;
    cin >> n; if(n == 0) break;
    while(n--){
      int a, b;
      cin >> a >> b;
      if(a == b){ares += a; bres += b;}
      if(a > b) ares += (a + b);
      if(a < b) bres += (a + b);
    }
    cout << ares << " " << bres << endl;
  }

  return 0;
}

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

using namespace std;


int main(){
	int n, a, b, ta, tb;

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

		for (int i = 0; i < n; i++){
			cin >> a >> b;
			if (a == b){
				ta += a;
				tb += b;
			}
			else{
				a>b ? ta += a + b : tb += a + b;
			}
		}

		cout << ta << " " << tb << endl;
	}
	return 0;
}

C++: #include<cstdio>
#include<cstdlib>
#include<iostream>
#include<string>
#include<map>
#include<vector>

using namespace std;

int main(){
  
  int n,anum,bnum;
  int as, bs;
  
  as = bs = 0;
  
  while(1){
    scanf("%d",&n);
    
    if(n == 0) break;  
    
    for(int i = 0 ; i < n ; i++){
      scanf("%d%d",&anum,&bnum);
      
      if(anum == bnum){
	as += anum;
	bs += bnum;
      }
      
      else if(anum > bnum){
	as += anum;
	as += bnum; 
      }
      
      else if(anum < bnum){
	bs += anum;
	bs += bnum; 
      }  
    }
    
    printf("%d %d\n",as,bs);
  }
  return 0;
}

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

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

C++: #include <iostream>

int main(){
    
    int num,a,b,resa=0,resb=0;
    
    std::cin>>num;
    
    for(int i=0;i<num;i++){
        std::cin>>a>>b;
        if(a>b)
            resa+=a+b;
        else
        if(a<b)
            resb+=a+b;
        else
            if(a==b)
                resa+=a,resb+=b;
    }
    
    std::cout<<resa<<' '<<resb<<std::endl;
    
    return 0;
}

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

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

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

int main(){
    int n,i,j,p1,p2;
    while(1){
        cin >> n;
        if(n == 0){
            break;
        }
        p1=0;
        p2=0;
        for(int k=0;k<n;k++){
            cin >> i >> j;
            if(i > j){
                p1 += i + j;
            }
            else if(i < j){
                p2 += i + j;
            }
            else if(i == j){
                p1 += i;
                p2 += j;
            }
        }
        cout << p1 << " " << p2 << endl;
    }
}

C++: #include<stdio.h>
int main(void)
{
	int n;
	int a,b;
	int a1,b1;
	int i;
	a1=0;
	b1=0;
	scanf("%d",&n);
	while(n!=0){
		for(i=0;i<n;i++){
			scanf("%d %d",&a,&b);
			if(a>b){
				a1+=a;
				a1+=b;
			}
			else if(a<b){
				b1+=a;
				b1+=b;
			}
			else{
				a1+=1;
				b1+=1;
			}
		}
		printf("%d %d",a1,b1);
		scanf("%d",&n);
	}
	return 0;
}