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++: #include "stdio.h"

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

C++: #include<iostream>
int main() {
	int n;
	std::cin >> n;
	int A = 0;
	int B = 0;
	int a,b;
	for (int i = 0; i < n; ++i) {
		std::cin >> a >> b;
		if (a > b) {
			A = A + a + b;
		}
		if (a < b) {
			B = B + a + b;
		}
		if (a == b) {
			A = A + a;
			B = B + b;
		}
	}
	std::cout << A <<" "<< B << std::endl;
	return 0;
}

C++: #include <iostream>

int main()
{
	int n;
	int a, b;
	int sa;
	int sb;
	
	do {
		std::cin >> n;
		for (int i = 0; i < n; i++)
		{
			sa = 0;
			sb = 0;
			std::cin >> a >> b;
			if (a > b) {
				sa += a + b;
			}
			else if (a == b) {
				sa += a;
				sb += b;
			}
			else {
				sb += a + b;
			}
		}
		std::cout << sa << " " << sb << std::endl;
	} while (n != 0);

	return 0;
}

C++: #include <iostream>

using namespace std;

int main() {

	int n, a, b, c, d;

	while(1) {
		cin >> n;
		if(n==0)
			break;
		a=0;
		b=0;
		while(n!=0) {
			cin >> c >> d;
			if(c>d)
				a+=c+d;
			else if(c<d)
				b+=c+d;
			else {
				a+=c;
				b+=d;
			}
	
			n--;
		}
		cout << a << " " << b << endl;
	}


	return 0;

}

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

C++: #include <iostream>
#define N 1000
using namespace std;
int main(){
    int n, scoreA, scoreB;
    while(cin >> n, n != 0){
        scoreA = 0; scoreB = 0;
        int a,b;
        for (int i = 0; i < n; i++){
            cin >> a >> b;
            if (a > b){
                scoreA += (a+b);
            }else if (b > a){
                scoreB += (a+b);
            }else{
                scoreA += a; scoreB += b;
            }
        }
        cout << scoreA << " " << scoreB << endl;
    }
    return 0;
}

C++: #include <cstdio>
int main(){
 int asum,bsum,a,b,n,i;
 asum=bsum=0;
 scanf("%d",&n);
 for(i=0;i<n;i++){
  scanf("%d %d",&a,&b);
  if (a>b) asum += a+b;
  if (a<b) bsum += a+b;
  if (a==b) { asum += a; bsum += b; }
 };
 printf("%d %d\n",asum,bsum);
 return 0;
};

C++: #include <stdio.h>

const int MAX_N=10000;
int a[MAX_N];
int b[MAX_N];
int n;
int A=0;int B=0;
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){
	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 <iostream>
#include <cstdio>
using namespace std;
int main(){
	int n,a,b;
	int num=0,sum=0;

	while(cin >> n, n){
	for(int i=0; i<n; i++){

		cin >> a >> b;

		if(a > b){
			
			num+=a+=b;
		}
		else if(a < b){
			
			sum+=b+=a;
		}
		else if(a == b){

			num+=a;
			sum+=b;
		}
	}

	cout << num << " " << sum << endl;
}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main() {
    while (1) {
        int n; cin >> n;
        if (n == 0) {
            break;
        }
        int score_a = 0, score_b = 0;
        for (int i=0; i<n; ++i) {
            int a,b;
            cin >> a >> b;
            if (a > b) {
                score_a += a + b;
            } else if (a < b) {
                score_b += a + b;
            } else {
                score_a += a;
                score_b += a;
            }
        }
        cout << score_a << ' ' << score_b << endl;
    }
    return 0;
}

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

int main() {

	//ifstream cin("INPUT.txt");
	//ofstream cout("OUTPUT.txt");

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

	while(cin >> n, n) {

		ap = 0; bp = 0;
		for(i = 0; i < n; i++) {
		cin >> a >> b;
			if(a < b) {
				bp += a;
				bp += b;
			} else if(b < a) {
				ap += a;
				ap += b;
			} else {
				ap += a;
				bp += b;
			}
		}

		cout << ap << " " << bp << endl;

	}

	return 0;

}

C++: #include <iostream>

using namespace std;

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

C++: #include <cstdio>

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

C++: #include <iostream>
#include <cstdio>
#include <cmath>

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


using namespace std;

int main(void){
    int a,b;
    int n;
    
    while (cin>>n && n){
        int s = 0 , t = 0;
        REP(i,n){
            cin >> a >> b;
            if (a>b)
                s += (a+b);
            else if (a<b)
                t += (a+b);
            else{
                s += a;
                t += b;
            }
        }
        cout << s << " " << t << endl;
    }
    
    return 0;
}

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

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

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<string>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,n) for(int i=1;i<=n;i++)

int main(){
	int n;
	scanf("%d",&n);
	
	int a=0,b=0;
	rep(i,n){
		int f,g;
		scanf("%d%d",&f,&g);
		
		if(f<g){
			a+=f+g;
		}
		if(f>g){
			b+=f+g;
		}
		if(f==g){
			a+=f;
			b+=g;
		}
	}
	printf("%d %d\n",b,a);
}

C++: #include <iostream>
using namespace std;
int main(){
	int n , i , j ;
	int total , result ;
	int a[10001] , b[10001];
	while(1){
		total =0 ;
		result = 0;
		cin >> n ;
		if( n==0 ) break;
		for( i=1 ; i<=n ; i++ ){
			cin >> a[i] >> b[i] ;
			if( a[i] > b[i] )
				total += a[i] + b[i];
			else if( a[i] < b[i] )
				result += a[i] + b[i];
			else {
				result += b[i];
				total += a[i];
			}
			cout << total <<" "<<result<<endl;
		}
	}
}

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

int main() {
    while (true) {
        int n;
        cin >> n;
        if (n==0) {
            break;
        }
        int PlayerA=0;
        int PlayerB=0;
        while (n--) {
            int scoreA;
            int scoreB;
            cin >> scoreA >> scoreB;
            if (scoreA>scoreB) {
                PlayerA+=scoreA+scoreB;
            } else if (scoreA<scoreB) {
                PlayerB+=scoreA+scoreB;
            } else {
                PlayerA+=scoreA;
                PlayerB+=scoreB;
            }
        }
        printf("%d %d\n",PlayerA,PlayerB);
    }
    return 0;
    
}