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<stdio.h>
int main(void){
    int loop,a,b,c=0,d=0;
while(1){ scanf("%d",&loop);
    if(loop==0)break;
    for(;loop--;){
        scanf("%d %d",&a,&b);
        if(a!=b){
            if(a>b){
                c+=a+b;
            }else{
                d+=a+b;
            }
        }else{
            c+=a;
            d+=b;
        }
    }
    printf("%d %d\n",c,d);
}
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
int n;
while(cin>>n){
int a[10000]={},b[10000]={};
int ap=0,bp=0;
	for(int i=0;i<n;i++){
	cin>>a[n]>>b[n];
	if(a[n]>b[n]){
		ap+=a[n]+b[n];
	}else if(a[n]<b[n]){
		bp+=a[n]+b[n];
	}else{
		ap+=a[n];
		bp+=b[n];
	}
	}
	cout<<ap<<" "<<bp<<endl;
}

return 0;
}

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

int main(){
	int n;
	int point_a, point_b, a, b;

	point_a = point_b = 0;
	cin >> n;

	while(n > 0){
		cin >> a >> b;
		if(a > b)
			point_a += a+b;
		else if(a < b)
			point_b += a+b;
		else{
			point_a += a;
			point_b += b;
		}
		n--;
	}

	cout << point_a << " " << point_b << endl;

	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int n = 0;
	int p[10][2];
	int a = 0;
	int b = 0;
	cin >> n;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < 2; j++){
			cin >> p[i][j];
		}
		if (p[i][0] == p[i][1]){
			a = a + p[i][0];
			b = b + p[i][1];
		}
		else if (p[i][0] < p[i][1]){
			b = b + p[i][0] + p[i][1];
		}
		else if (p[i][0] > p[i][1]){
			a = a + p[i][0] + p[i][1];
		}
	}
	cout << a << " " << b << endl;
	return 0;
}

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

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

int main(){
 int n, a, b, a_sum, b_sum;
 while(cin>>n, n){
  a_sum=b_sum=0;
  while(n--){
   cin>>a>>b;
   if(a>b)a_sum+=a+b;
   else if(a<b)b_sum+=a+b;
   else a_sum+=a, b_sum+=b;
  }
  printf("%d %d\n", a_sum,b_sum);
 }
 return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int a=0, b=0,n,s,t;
	cin >> n; while (n != 0) {
		a = 0; b = 0;
		for (int i = 0; i < n; i++) {
			scanf("%d%d", &s, &t);
			if (s > t)a += s + t;
			else if (t > s)b += s + t;
			else { a += s; b += t; }
		}
		cout << a << " " << b << endl; cin >> n;
	}
	return 0;
}

C++: #include <cstdio>

int N;
int C[10000][2];

void solve() {
  int a = 0;
  int b = 0;
  for (int i = 0; i < N; i++) {
    int ac = C[i][0];
    int bc = C[i][1];
    if (ac > bc) {
      a += ac + bc;
    } else if (ac < bc) {
      b += ac + bc;
    } else {
      a += ac;
      b += bc;
    }
  }
  printf("%d %d\n", a, b);
}

int main() {
  for (;;) {
    scanf("%d", &N);
    if (N == 0) { break; }

    for (int i = 0; i < N; i++) {
      scanf("%d%d", &C[i][0], &C[i][1]);
    }
    solve();
  }
}

C++: #include<iostream>
using namespace std;
int main(){
  int i,k;
  k=0;
  int a,b;
  int suma[99]={0};
  int sumb[99]={0};
  while(1){
    int n;
    cin>>n;
    if(n==0) break;
    for(i=0;i<n;i++){
      cin>>a>>b;
      if(a>b) suma[k]=a+b+suma[k];
      if(a<b) sumb[k]=a+b+sumb[k];
      if(a==b){
        suma[k]=a+suma[k];
        sumb[k]=b+sumb[k];
      }
  }
  k++;
 }
  for (i = 0; i < k;i++) {
   cout<<suma[i]<<" "<<sumb[i]<<endl;
 }
 return 0;
}

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

int main()
{	
	while(true){
		int n,a[10000]={},b[10000]={},ascore=0,bscore=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]){
				ascore+=a[i]+b[i];
			}else if(a[i]<b[i]){
				bscore+=a[i]+b[i];
			}else if(a[i]==b[i]){
				ascore+=a[i];
				bscore+=b[i];
			}
		}
	}
	cout<<ascore<<" "<<bscore<<endl;
	return 0;
}

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

int main(){
    const int MAX_N = 10000;
    int n;
    int a[MAX_N];
    int b[MAX_N];
    int aPoint=0;
    int bPoint=0;
    
    
    while(true){
        cin >> n;
        if(n==0){
            break;
        }
        for(int i=0;i<n;i++){
            cin >> a[i];
            cin >> b[i];
            if (a[i] > b[i]){
                aPoint += a[i]+b[i];
            }else if (a[i]<b[i]){
                bPoint += a[i]+b[i];
            }else{
                aPoint += a[i];
                bPoint += b[i];
            }
        }
        cout << aPoint << " ";
        cout << bPoint << "\n";
        aPoint = 0;
        bPoint = 0;
    }
}

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

int main()
{
 int t,aa,ab,ba,bb,ca,cb,pa,pb;
 cin>>t;
 cin>>aa>>ab;
 cin>>ba>>bb;
 cin>>ca>>cb;
 
 t=3;pa=0;pb=0;
 
 if(aa>ab){pa=pa+aa+ab;}
 if(aa<ab){pb=pb+aa+ab;}
 if(aa==ab){pa=pa+aa;pb=pb+ab;}

 if(ba>bb){pa=pa+ba+bb;}
 if(ba<bb){pb=pb+ba+bb;}
 if(ba==bb){pa=pa+ba;pb=pb+bb;}
 
 if(ca>cb){pa=pa+ca+cb;}
 if(ca<cb){pb=pb+ca+cb;}
 if(ca==cb){pa=pa+ca;pb=pb+cb;}

 cout<<pa<<" "<<pb<<'\n';

 return 0;
}

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


int main(){

    int n;
    int apt=0,bpt=0;
    int a[10000]={0};
    int b[10000]={0};
    cin >> n;
    for(int i=0; i < n; i++){
        cin >>a[i];
        cin >>b[i];
    }
    for(int i=0; i < n; i++){
        if(a[i]>b[i])apt+=a[i]+b[i];
        else if(a[i]<b[i])bpt+=a[i]+b[i];
        else apt+=a[i],bpt+=b[i];
        }
    cout<<apt<<' '<<bpt<<endl;
}

C++: #include <iostream>
using namespace std;
int main()
{
	int a = 1, e = 0, f = 0, c, d;
	while (1)
	{
		cin >> a;
		if (a != 0)
		{
			break;
		}
		e = 0;
		f = 0;
		for (int b = 0; b < a; b++)
		{
			cin >> c;
			cin >> d;
			if (c > d)
			{
				e += c;
				e += d;
			}
			else if (d > c)
			{
				f += c;
				f += d;
			}
			else
			{
				e += c;
				f += d;
			}
		}
		cout << e << " " << f << endl;
	}
	return 0;
}

C++: #include <stdio.h>

const int MAX_N=10000;
int a[MAX_N];
int b[MAX_N];
int n;
int A,B;
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){
         A=0;
         B=0;
	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<string>
#include<vector>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<sstream>
#include<functional>
#include<map>
#include<stack>
#include<set>
#include<cmath>

#define REP(i,s,e) for(int i=int(s);i<int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)

#define EPS 1e-6

using namespace std;

int main(){

	int n,a,b;

	while(true){

	cin >> n;

	if(n==0) break;

	int p=0; int q=0;
	rep(i,n){

	cin >> a >> b;

	if(a>b) p+=a+b;
	else if(a<b) q+=a+b;
	else{ p+=a; q+=b; }

	}

	cout << p << " " << q << endl;

	}

    return 0;

}

C++: #include<cstdio>
main(){
	int n;
	while(scanf("%d",&n),n){
		int a,b,c = 0,d = 0;
		while(n--)
			scanf("%d%d",&a,&b);c+=a>b?a+b:a==b?a:0;d+=b>a?a+b:a==b?b:0;
		printf("%d %d\n",c,d);
	}
}