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 <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>

using namespace std;

int main() {
	int n;
	cin >> n;
	int a = 0, b = 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 {
			a += x;
			b += y;
		}
	}
	cout << a << b << endl;
	return 0;
}

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

int main(){
	int n, a, b;
	while (true)
	{
		int point_a = 0, point_b = 0;
		cin >> n;
		if (cin.eof()||n==0) { break; }
		for(int i =0;i<n;i++){
			cin >> a >> b;
			if(a==b){
				point_a += a;
				point_b += b;
			}
			else if (a>b){
				point_a += a + b;
			}
			else {
				point_b += a + b;
			}
		}
		cout << a << " " << b << endl;
	}
}

C++: #include<iostream>

int main(){

	int n;

	int a=0, b=0;

	int x, y;

	f:

	std::cin >> n;

	if (n == 0)
		goto flag;

	for (int i = 0; i < n; i++) {
		std::cin >> x >> y;
		if (x > y)
			a += (x + y);
		if (x < y)
			b += (x + y);
		if (x == y){
			a += x;
		b += y;
	}
	}

	std::cout << a << ' ' << b << std::endl;

	goto f;

flag:

	std::cout << "" << std::endl;

	return 0;

}

C++: #include<stdio.h>

int main(){
	int i=0,w=0,x,a[10000],b[10000],aP[10000],bP[10000];
	while(i<10000){
		aP[i]=bP[i]=0;
	++i;
	}
	i=0;
	while(1){
	scanf("%d",&x);
	if(x==0){
	return 0;
	}
	while(i<x){
scanf("%d%d",&a[i],&b[i]);
	++i;
	}
	i=0;
	while(i<x){
		if(a[i]==b[i]){
			aP[w]=aP[w]+a[i];
			bP[w]=bP[w]+b[i];
		}else if(a[i]>b[i]){
		aP[w]=aP[w]+a[i]+b[i];
		}else{
		bP[w]=bP[w]+a[i]+b[i];
		}
		++i;
	}
	++w;
	}
	i=0;
	while(i<w){
	printf("%d %d\n",aP[w],bP[w]);
	}
}

C++: #include <iostream>

using namespace std;

int main() {
  for (;;) {
    int n, pa = 0, pb = 0;
    cin >> n;
    if (!n) return 0;
    for (int i = 0; i < n; i++) {
      int a, b;
      cin >> a >> b;
      if (a == b) {
        pa += a;
        pb += b;
      } else
        (a > b ? pa : pb) += a + b;
    }
    cout << pa << ' ' << pb << endl;
  }
}

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

int main(){
	
	int n,j=0;
	int A[10000], B[10000];
	
	
	while(j<5){
	
	int scoreA=0,scoreB=0;
		cin>>n;
		if(n==0){break;}
	for(int i=0;i<n;i++)
	{
		
		cin >>A[i];
		cin>>B[i];
		if(A[i]>B[i])
		{scoreA+=(A[i]+B[i]);}
			
		else if(A[i]<B[i])
			{scoreB+=(A[i]+B[i]);}
		else if(A[i]==B[i])
				{scoreA+=A[i];
				scoreB+=B[i];}
	}
		cout<<scoreA<<" "<<scoreB<<endl;
		j++;
	}
	return 0;
}

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

int main(void) {
	int i, n, a, b, as = 0, bs = 0;
	cin >> n;

	for(i=0 ; i<n ; i++) {
		cin >> a >> b;
		if(a > b)		{ as += a + b; }
		else if(a < b)	{ bs += a + b; }
		else 			{ as += a; bs += b; }
	}
	cout.form("%d %d\n", as, bs);
	return 0;
}

C++: #include <iostream>

using namespace std;

int main() {

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

  return 0;
}

C++: #include <iostream>
using namespace std;
int main(){

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

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

		//?????°?????´??°
		if (a > b)
			ap += a + b;
		else if (a < b)
			bp += a + b;
		else{
			ap += a;
			bp += b;
		}
	}

	cout << ap << ' ' << bp << endl;
}

C++: #include<stdio.h>

int main(){

int N;int A,B,SA=0,SB=0;
while(1){
SA=0,SB=0;

scanf("%d",&N);
if(N==0)break;
for(int i=0;i<N;i++){
scanf("%d %d",&A,&B);
if(A>B)SA=SA+A+B;
else if(B>A)SB=SB+A+B;
}

printf("%d %d\n",SA,SB);
}
return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
  int n,l,r,a,b;
  while(cin>>n,n){
    a=b=0;
    while(n--){
      cin>>l>>r;
      if(l>r) a+=l+r;
      else if(r>l) b+=l+r;
      else{
	a+=l;b+=r;
      }
    }
    cout<<a<<' '<<b<<endl;
  }
  return 0;
}

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

int main(){
	int a=0,b=0,ca,cb,n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>ca>>cb;
		if(ca>cb)a+=(ca+cb);
		else if(ca<cb)b+=(ca+cb);
		else{
			a+=ca;
			b+=cb;
		}
	}
	cout<<a<<' '<<b<<endl;
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define REP(i,N) for(int i = 0; i < (int)N; i++)

int main(){
	int n;
	int reta,retb;
	while(cin >> n){
		if(n==0)break;
		reta=retb=0;
		REP(i,n){
			int a,b;
			cin >> a >> b;
			if(a > b){
				reta += a+b;
			}else if(b > a){
				retb += a+b;
			}else{
				reta += a;
				retb += b;
			}
		}
		cout << reta << " " << retb << endl;
	}
	return 0;
}

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

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

C++: #include<bits/stdc++.h>

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define For(i,a) FOR(i,0,a)
#define REP(a) For(i,a)

typedef long long ll;

using namespace std;

int main(){
	int times;
	while(1){
	  ll ans[2]={};
		scanf("%d",&times);
		if(times==0)break;
		REP(times){
			ll tmp[2];
			scanf("%d %d",&tmp[0],&tmp[1]);
			if(tmp[0]<tmp[1])ans[1]+=tmp[0]+tmp[1];
			else if(tmp[0]>tmp[1])ans[0]+=tmp[0]+tmp[1];
			else{ans[0]+=tmp[0];ans[1]+=tmp[1];}
		}
		printf("%d %d\n", ans[0], ans[1]);
	}
	return 0;
}

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

int main(){
int n,a,b;
int sumA=0,sumB=0;
while(cin>>n){
	sumA=0,sumB=0;
for(int i=0;i<n;i++){
cin>>a>>b;
if(a>b){
sumA+=a;
sumA+=b;
}
if(a==b){
sumA+=a;
sumB+=b;
}
if(a<b){
sumB+=a;
sumB+=b;
}}
printf("%d %d",sumA,sumB);
}}

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

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

#define rep(v,c) for(int v=0; v<(int)c; ++v)

using pint=pair<int,int>;

pint solve(int 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;
  }
  return pint(A,B);
}

int main(void){
  int n;
  vector<pint> ans;
  while(1){
    cin>>n;
    if(n==0) break;
    auto rec=solve(n);
    ans.push_back(rec);
  }
  rep(i,ans.size()){
    int a,b; tie(a,b)=ans[i];
    cout<<a<<" "<<b<<endl;
  }
}

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