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, i,A,B, resa, resb;
    while(cin >> n,n){
        resa=0;resb=0;
        for(i=0;i<n;i++){
             cin >> A >> B;
             if(A>B) resa += A+B;
             else if (A<B) resb += A+B;
             else {resa += A; resb +=B;};
        }
    cout << resa << " " << resb << endl;
    }
}

C++: #include<stdio.h>
int main(void)
{
	int n,a,b,i,k=0,h=0;
	
	scanf("%d",&n);
	for(i=0;i!=n;i++){
	    scanf("%d %d",&a,&b);
	    if(a>b){
		    k+=a+b;
		   }
	    else if(a==b){
			  k+=a;
			  h+=b;
			 }
	    else
		h+=a+b;
	}
	printf("%d %d",k,h);
return 0;	
}

C++: #include <stdio.h>

int main(void) {
	while (1) {
		int n;
		scanf("%d", &n);
		
		if (n == 0) {
			break;
		}
		
		int a_score = 0;
		int b_score = 0;
		
		int i;
		for (i = 0; i < n; i++) {
			int a;
			int b;
			scanf("%d %d", &a, &b);
			
			*(a >= b ? &a_score : &b_score) += a;
			*(b >= a ? &b_score : &a_score) += b;
		}
		
		printf("%d %d\n", a_score, b_score);
	}
	
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int point[2];
	enum {
		A,
		B,
	};
	int sum[2] = {};
	for (int i = 0; i < n; i++) {
		cin>>point[A]>>point[B];
		if (point[A]>point[B]) {
			for (auto j : point) {
				sum[A]+=j;
			}
		} else if(point[A] == point[B]) {
			for (auto j : sum) {
				j+=point[A];
			}
		} else {
			for (auto j : point) {
				sum[B]+=j;
			}
		}
	}
	cout<<sum[A]<<" "<<sum[B]<<endl;
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <sstream>
#include <fstream>
//#include <tuple>
#include <set>
#include <string.h>
#include <functional>

#define X first
#define Y second
#define MP make_pair
//#define MT make_tuple
#define REP(i, a, n) for(int (i) = (a); (i) < (n); ++(i))
#define FOR(i, n) REP(i, 0, n)
typedef long long ll;
using namespace std;
const int MAX = 101;

template<class T, class U>
void convert(T &t, U &u)
{
	stringstream ss;
	ss << t;
	ss >> u;
}

int main()
{
	int n;
	while (cin >> n && n){
		int a = 0, b = 0;
		FOR(i, n){
			int s, t; cin >> s >> t;
			if (s > t) a += s + t;
			else if (s < t) b += s + t;
			else a += s, b += t;
		}

		cout << a << " " << b << endl;
 	}

	return 0;
}

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

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

C++: #include <iostream>
using namespace std;
int main(void)
{
	for (;;)
	{
		int a,b,c,d;
		int e=0;
		int f=0;
		cin>>a;
		if (a==0)
		{
			break;
		}
		for (b=0;b<a;b++)
		{

			cin>>c>>d;
			if (c>d)
			{
				e=e+c+d;
			}
			else if (c<d)
			{
				f=f+d+c;
			}
			else if (c==d)
			{
				e=e+c;
				f=f+d;
			}
		}
		cout<<e<<" "<<f<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int N=0;
    while(cin >> N && N!=0) {
        vector<int> A(N), B(N);
        for(int i=0; i<N; ++i) cin >> A[i] >> B[i];

        int ret_a=0, ret_b=0;
        for(int i=0; i<N; ++i) {
            if(A[i] < B[i]) {
                ret_b += A[i]+B[i];
            } else if(A[i] > B[i]) {
                ret_a += A[i]+B[i];
            } else {
                ret_a += A[i]; ret_b = B[i];
            }
        }
        cout << ret_a << " " << ret_b << endl;
    }
}

C++: #include <iostream>

int main(int argc, char **argv)
{
	int a, b;
	int n;
	int acards[10000],bcards[10000];
	while(true){
		a = 0;
		b = 0;
		std::cin >> n;
		if(n == 0){
			break;
		}
		for(int i = 0; i < n; i++){
			std::cin >> acards[i] >> bcards[i];
			if(acards[i] < bcards[i]){
				b += bcards[i] + acards[i];
			}
			if(acards[i] > bcards[i]){
				a += bcards[i] + acards[i];
			}
			if(acards[i] == bcards[i]){
				a += acards[i];
				b += bcards[i];
			}
		}
		std::cout << a << " " << b << std::endl;
	}
	return 0;
}

C++: 
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <algorithm>

using namespace std;


bool solve(){
	int n;
	cin>> n;
	if(!n) return false;

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

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	while(solve()){};

	return 0;
}

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

using namespace std;

int main(){
	int lim;
	
	while( cin >> lim, lim != 0){
		int a = 0, b = 0;
		while(lim-- > 0){
			int n, m;
			cin >> n >> m;
			(n == m)? a+=n, b+=m:
			(n > m)? a += n+m: b += n+m;
		}
		printf("%d %d\n", a, b);
	}
	return 0;
}

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

return 0;
}

C++: #include<iostream>

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

C++: #include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
	long long int a,b,n,x,y;
	a=0;
	b=0;
	scanf("%lld",&n);
	for(long long int i=0;i<n;i++){
		scanf("%lld %lld",&x,&y);
		if(x>y) {a+=(x+y);}
		if(x<y) {b+=(x+y);}
		if(x==y){
			a+=x;
			b+=y;
		}
	}
	printf("%lld %lld\n",a,b);
	return 0;
}

C++: #include<iostream>
#include<string>
#include<sstream>
#include<cstdlib>

using namespace std;

int main(){
	while(1){
		string str;
		getline(cin,str);
		int n = atoi(str.c_str());
		if(n==0)break;
		int scoreA = 0, scoreB = 0;
		while(n--){
			getline(cin,str);
			stringstream ss(str);
			string tmp;
			getline(ss,tmp,' ');
			int a = atoi(tmp.c_str());
			getline(ss,tmp);
			int b = atoi(tmp.c_str());
			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<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cctype>
using namespace std;

int main(){
    int n;
    while(cin>>n){
        if(n==0)break;
        int ans1=0;
        int ans2=0;
        int num,sum;
        for(int i=0; i<n; i++){
            cin>>num>>sum;
            if(num>sum){
                ans1+=num;
                ans1+=sum;
            }
            if(num<sum){
                ans2+=num;
                ans2+=sum;
            }
            if(num==sum){
                ans1+=num;
                ans2+=sum;
            }
        }
        cout<<ans1<<" "<<ans2<<endl;
    }
    return 0;
}