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++: <?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;
}

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

int main () {
    int n, i,A,B, resa =0, resb =0;
    while(cin >> n,n){
        for(i=0;i<n;i++){
           　cin >> A >> B;
             (A > B)? resa +=A:resb+=B;
             if(A==B) {resa += A; resb +=B;};
        }
    cout << resa << " " << resb << endl;
    }
}

C++: #include<stdio.h>
#include<iostream>
using namespace std;
int main(){
int card[100],i,j,a=0,b=0,c=1,n;
cin>>n;
while(n!=0){
for(i=0;i<2*n;i++){
cin>>card[i];
}
for(i=0;i<2*n;i=i+2){
if(card[i]>card[c]){
a=a+card[i]+card[c];
}
else if (card[i]==card[c]){
a=a+card[i];
b=b+card[c];
}
else{
b=b+card[i]+card[c];
}
c=c+2;
}
cout<<a<<" "<<b<<endl;
c=1;
a=0;
b=0;
cin>>n;
}
return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
typedef long long int ll;

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

C++: //
//  main.cpp
//  program
//
//  Created by h3032906 on 2016/11/24.
//  Copyright ?? 2016??´ h3032906. All rights reserved.
//

#include <iostream>

int main(int argc, const char * argv[]) {

    int n, a, b;
    int at = 0;
    int bt = 0;
    for( ; ; ){
        std::cin >> n;
        if(n == 0){
            break;
        }
        for(int i = 0; i < n; i++){
            std::cin >> a >> b;
            if(a > b){
                at = at + a + b;
            }
            else if(b > a){
                bt = bt + a + b;
            }
            else {
                at = at + a;
                bt = bt + b;
            }
        }
        std::cout << at << bt << std::endl;
        at = 0;
        bt = 0;
    }
    return 0;
}

C++: #include <stdio.h>

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