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;
#define MAX 10010

int main()
{
    int n;
    while(cin >> n)
    {
        if(n==0)break;
        int pointa=0, pointb =0;
        int carda,cardb;
        for(int i=0;i<n;i++)
        {
            cin >> carda >> cardb;
            if( carda > cardb ){pointa += (carda+cardb); continue;}
            else if( carda<cardb ){pointb += (carda+cardb); continue;}
            else
            {
                pointa += carda;
                pointb += cardb;
                continue;
            }
        }
        cout << pointa  << " " << pointb << endl;
    }

    return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
	int n;
	int a,b;
	int sa=0,sb=0;//score
	
	
	while(cin>>n&&n!=0){
	for(int i=0;i<n;i++)
	{
		cin>>a>>b;
		if(a<b){sb+=(a+b);}
		else if(a>b){sa+=(a+b);}
		else
		{
			sa+=a;
			sb+=b;
		}
	}
	cout<<sa<<" "<<sb<<"\n";
	sa=0;sb=0;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(void){
  int n;
  while(cin>>n&&n!=0){
    int sumA=0,sumB=0,a,b;
    for(int i=0;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++: //============================================================================
// Name        : svdzva.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
#include<algorithm>
using namespace std;

int main() {
	int n, play1 = 0, play2 = 0, card1[10000], card2[10000];
	while (true) {
		cin >> n;
		for (int i = 0; i < n; i++) {
			cin >> card1[i] >> card2[i];
			if (card1[i] > card2[i]) {
				play1 = play1 + card1[i] + card2[i];
			} else if (card1[i] < card2[i]) {
				play2 = play2 + card2[i] + card1[i];
			} else {
				play1 = play1 + card1[i];
				play2 = play2 + card2[i];
			}
		}
	}
	cout << play1 << " " << play2 << endl;
	return 0;
}

C++: <?php 
    $sc = new Scanner();
    while(true){
        $turn = $sc->nextInt();
        if($turn==0) {
            break;
        }
        $a_point=0;
        $b_point=0;
        for($i=0;$i<$turn;$i++){
            $a=$sc->nextInt();
            $b=$sc->nextInt();
            if($a>$b){
                $a_point += $a+$b;
            }else if ($a<$b) {
                $b_point += $a+$b;
            }else {
                $a_point+=$a;
                $b_point+=$b;
            }
        }
        echo $a_point,' ',$b_point,'\n';
    }
    class Scanner {
        private $arr = [];
        private $count = 0;
        private $pointer = 0;
        public function next() {
            if($this->pointer >= $this->count) {
                $str = trim(fgets(STDIN));
                $this->arr = explode(' ', $str);
                $this->count = count($this->arr);
                $this->pointer = 0;
            }
            $result = $this->arr[$this->pointer];
            $this->pointer++;
            return $result;
        }
        public function hasNext() {
            return $this->pointer < $this->count;
        }
        public function nextInt() {
            return (int)$this->next();
        }
        public function nextDouble() {
            return (double)$this->next();
        }
    }
    class out {
        public static function println($str) {
            echo $str . PHP_EOL;
        }
    }
 ?>

C++: #include <stdio.h>

int main(){
	long long Right_Point = 0;
	long long Left_Point = 0;

	int Right_Card, Left_Card;

	int kaisuu;

	Right_Point = 0;
	Left_Point = 0;
	scanf("%d", &kaisuu);
	for (int a = 0; a < kaisuu; a++){
		scanf("%d", &Right_Card);
		scanf("%d", &Left_Card);
		if (Right_Card == Left_Card){
			Right_Point += Right_Card;
			Left_Point += Left_Card;
		}
		else if (Right_Card < Left_Card){
			Left_Point += (Right_Card + Left_Card);
		}
		else if (Left_Card < Right_Card){
			Right_Point += (Right_Card + Left_Card);
		}
	}
	printf("%lld %lld\n", Right_Point, Left_Point);
	return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  while(cin >> n&&n){
    ll a,b,A=0,B=0;
    rep(i,n){
      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<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n,a,b,x=0,y=0;
  while(n!=0){
    cin>>n;
    if(n==0)continue;
    rep(i,n){
      cin>>a>>b;
      if(a==b){
	x+=a;
	y+=b;
      }else if(a>b)x+=a+b;
      else if(a<b)y+=a+b;
    }
    cout<<x<<" "<<y<<endl;
    x=0;
    y=0;
  }
  return 0;
}

C++: #include <cstdio>
int main(){
	int a, b, c;
	scanf("%d", &a);
	b = 0;
	c = 0;
	int n_a[a];
	int n_b[a];
	for(int i=0; i<a; i++){
		scanf("%d %d", &n_a[i], &n_b[i]);
	}
	for(int i=0; i<a; i++){
		if(n_a[i] > n_b[i]){
			b += n_a[i]+n_b[i];
		}else if(n_a[i] < n_b[i]){
			c += n_a[i]+n_b[i];
		}else if(n_a[i] == n_b[i]){
			b += n_a[i];
			c += n_b[i];
		}
	}
	printf("%d %d", b, c);
	return 0;
}

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

int main(){
	int i,n,a,b;
	long apoint=0,bpoint=0;
	while(1){
		cin >> n;
		if(!n) break;
		for(i=0;i<n;i++){
			cin >> a;
			cin >> b;
			if(a>b){apoint+=a;apoint+=b;}
			else if(b>a){bpoint+=a;bpoint+=b;}
			else {apoint+=a;bpoint+=b;}
		}
		cout << apoint <<' ' << bpoint << endl;
		apoint=0;bpoint=0;
	}
	return 0;
}