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 <iostream>
using namespace std;

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

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

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

int main(){
    int n;
    int a_point = 0, b_point = 0;

    while(cin >> n, n != 0){
        for(int i=1; i<=n; i++){
            int tmp1, tmp2;
            cin >> tmp1 >> tmp2;
            if(tmp1 > tmp2){
                a_point += tmp1 + tmp2;
            }else if (tmp1 < tmp2){
                b_point += tmp1 + tmp2;
            }else{
                a_point += tmp1;
                b_point += tmp2;
            }
        }
        cout << a_point << " " << b_point << endl;
    }
    return 0;
}

C++: #include <cstdio>

int main(){
	int A, B, N;
	int As, Bs;

	while (1){
		scanf("%d", &N);
		if (N == 0) break;
		As = Bs = 0;
		for (int i = 0; i < N; i++){
			scanf("%d %d", &A, &B);
			if (A > B) {
				As += A + B;
			}
			else if(A < B){
				Bs += A + B;
			} else {
				As += A;
				Bs += B;
			}
		}
		printf("%d %d\n", As, Bs);
	}

	return 0;
}

C++: #include <cstdio>

int main(void){
	int a, b, c;
	scanf("%d", a);
	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,apoint=0,bpoint=0;
	cin >> n;
	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;
}

C++: #include <iostream>
using namespace std;
int main(){
	int n;
	int a[3]={0};
	int b[3]={0};
	int A,B;
	for(int i=0;i<5;i++){
		cin>>n;
		if(n==0){break;}
		for(int j=0;j<n;j++){
			cin>>a[j]>>b[j];
			if(a[j]>b[j]){
				A+=a[j]+b[j];
			}
			else if(a[j]<b[j]){
				B+=a[j]+b[j];
			}
			else if(a[j]==b[j]){
				A+=a[j];
				B+=b[j];
			}
		}
		cout<<A<<" "<<B<<endl;
	}
	return 0;
}

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

int main(){
int a;
int uma;
int ushi;
int b;
int c;
int i;
while (true){
cin >> a;
if (a == 0){ break; }
else{
	while (true){
	if (i<a){
	cin >> b;
	cin >> c;
	if (b>c){
		uma = uma + b + c;
	}
	else if (b == c){
		uma = uma + b;
		ushi = ushi + c;
	}
	else{
	ushi = ushi + b + c;
	}
	i = i + 1;
}if (i == a){ break; }
}
cout << uma << " " << ushi << endl;
uma = 0;
ushi = 0;
i = 0;
}
}
}

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

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

C++: #include <iostream>

using namespace std;

int main()
{
	int n;
	int a,b;
	int sa,sb;//score
	
	cin>>n;
	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<<a<<" "<<b<<"\n";
	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

int n, a, b;

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

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

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

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

int main(){
int n,a,b;
int sumA=0,sumB=0;
while(cin>>n){
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;
}}}

C++: #include<iostream>
using namespace std;
int main(){
    int n=1,A=0,B=0;
    while(n!=0){
        cin>>n;
        if(n==0){break;}
        for(int i=0;i<n;i++){
            int ap=0,bp=0;
            cin>>ap;
            cin>>bp;
            if(ap<bp){
                B=B+ap+bp;
            }
            if(ap>bp){
                A=A+ap+bp;
            }
            if(ap==bp){
                A=A+ap;
                B=B+bp;
            }
        }
        cout<<A<<" "<<B<<endl;
        A=0;B=0;
    }
    return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
	int n;
	int a[10000],b[10000];
	
	while(cin>>n && n!=0){
		int point_a=0;
		int point_b=0;

		for(int i=0;i<n;i++){
			cin>>a[i]>>b[i];
			if(a[i] > b[i]){
				point_a+=(a[i] + b[i]);
			}else if(a[i] == b[i]){
				point_a+=a[i];
				point_b+=b[i];
			}else{
				point_b+=(a[i] + b[i]);
			}
		}
		cout<<point_a<<" "<<point_b<<endl;
	}
	return 0;
}

C++: #include <iostream>

int main() {
	int n, a_s, b_s, *a, *b;
	std::cin >> n;
	while (n) {
		a_s = b_s = 0;
		a = new int[n];
		b = new int[n];
		for (int i; i<n; i++) {
			std::cin >> a[i] >> b[i];
		}
		for (int i; i<n; i++) {
			if (a[i] > b[i]) {
				a_s += a[i] + b[i];
			} else if (a[i] < b[i]) {
				b_s += a[i] + b[i];
			} else {
				a_s += a[i], b_s += b[i];
			}
		}
		std::cout << a_s << " " << b_s << std::endl;
		delete a;
		delete b;
		std::cin >> n;
	}
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

ll n, a, b, suma = 0, sumb = 0;

int main(){
	cin >> n;
	REP(i, n){
		cin >> a >> b;
		if (a > b){
			suma += (a + b);
		}
		else if (a < b){
			sumb += (a + b);
		}
		else {
			sumb += b;
			suma += a;
		}
	}
	cout << suma << " " << sumb << endl;
}