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>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(c) (c).begin(),(c).end()
int main(){
	while(true){
		int n,a=0,b=0;
		cin >> n;
		if(!n) break;
		rep(i,n){
			int p,q;
			cin >> p >> q;
			if(p>q) a+=(p+q);
			else if(p<q) b+=(p+q);
			else{
				a+=p;
				b+=p;
			}
		}
		cout << a << " " << b << endl;
	}
	return 0;
}

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

C++: #include<stdio.h>


int main(){
	int n;
	int a=0,b=0;
	int apoint=0,bpoint=0;
	int i;

	scanf("%d",&n);

	while(n!=0){
		for(i=0;i<n;i++){
			scanf("%d %d",&a,&b);
			if(a<b){
				bpoint = bpoint + a + b;
			}if(a>b){
				apoint = apoint + a + b;
			}if(a==b){
				apoint= apoint + a;
				bpoint= bpoint + b;
			}
		}		
		printf("%d %d",apoint,bpoint);
		apoint=0;
		bpoint=0;
		scanf("%d",&n);
	}
}

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

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

int main(){
	int n,a,b;
	long suma=0,sumb=0;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a >> b;
		if(a>b) suma+=a+b;
		else sumb+=a+b;
	}
	printf("%ld %ld\n",suma,sumb);
}

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

C++: #include<stdio.h>

int main(){
	int n;
	int A=0;
	int B=0;
	int i=0;
	while(1){
	A=0;
	B=0;
	scanf("%d", &n);
	if(n==0){
	return 0;
	}
	int x[10000];
	int y[10000];
	i=0;
	while(i<n){
	scanf("%d", &x[i]);
	if(0>x[i] || 9<x[i]){
	return 0;
	}
	scanf("%d", &y[i]);
	if(0>y[i] || 9<y[i]){
	return 0;
	}
	++i;
}
	i=0;
	while(i<n){
	if(x[i]>y[i]){
	A=A+x[i]+y[i];
}else {
	if(x[i]<y[i]){
	B=B+x[i]+y[i];
}else{
	A=A+x[i];
	B=B+y[i];
			}
		}
	++i;
	}
	printf("%d %d\n", A, B);
	}
}

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

int main(){
	int match;
	cin >> match;
	
	int a,b;
	int score_a=0,score_b=0;
	for(int i=0;i<match;i++){
		cin >> a >> b;
		if(a > b) score_a += (a+b);
		else if(a < b) score_b+=(a+b);
            else{
                score_a+=a;score_b+=b;
            }
	}
    cout << score_a << " " << score_b<<endl;
    return 0;
}

C++: #include<iostream>
using namespace std;
int n[10000000],s1,s2;
int main(){
int p,a,b;
cin>>p;
for(int i=0;i<p;i++){
cin>>a>>b;
if(a>b){s1+=a+b;}
else if(b>a){s2+=a+b;}
else{s1+=a;s2+=b;
}
cout<<s1<<' '<<s2<<endl
}

C++: #include<iostream>
using namespace std;
static const int N = 10000;

int main() {
	int n;
	int i;
	int A[N];
	int B[N];
	int score_A = 0;
	int score_B = 0;

	while (1) {
		cin >> n;

		if (n == 0) break;

		for (i = 0; i < n; i++) {
			cin >> A[i];
			cin >> B[i];
		}

		for (i = 0; i < n; i++) {
			if (A[i] > B[i]) {
				score_A += A[i] + B[i];
			}
			else if (A[i] < B[i]) {
				score_B += A[i] + B[i];
			}
			else if (A[i] = B[i]) {
				score_A += A[i];
				score_B += B[i];
			}
		}

		cout << score_A << " " << score_B << endl;

		for (i = 0; i < n; i++) {
			score_A = 0;
			score_B = 0;
		}
	}
	return 0;
}

C++: #include <cstdio>

int main(){
	int a, b, c;
	int n_a[a];
	int n_b[a];
	scanf("%d", 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 a,b;
	int n;
	while(1){
		int aten = 0,bten = 0;
		cin >> n;
		if(n == 0){
					break;
				}
		for(int i = 0; i < n; i++){
		cin >> a >> b;
		if(a > b){
			aten = aten + a + b;
		}
		else if(a == b){
			aten = aten + a;
			bten = bten + a;
		}
		else{
			bten = bten + b + a;
	}
		}
	cout << aten << " " << bten << endl;
	}
	return 0;
}

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

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

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PA;
using namespace std;
#define MAX 1e7
int main(){
    int n;
    while(cin >> n,n){
        vi v(n+1,0);
        vi v2(n+1,0);
        int ans1 = 0; int ans2 =0;
        rep(i,n){
            cin >> v[i] >> v2[i];
            if(v[i]>v2[i])
                ans1+=v[i]+v2[i];
            else if(v[i] < v2[i])
                    ans2 += v[i]+v2[i];
            else{
                ans1+=v[i]; ans2= v2[i];}
        }
        cout << ans1 << " " << ans2 << 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;
	}
	}

	goto f;

flag:

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

	return 0;

}

C++: #include <cstdio>

using namespace std;

int main(){

  while(1){

  int n,a=0,b=0;

  scanf("%d",&n);

  if(n == 0) break;

  for(int i = 0;i < n;i++){
    int t1,t2;

    scanf("%d%d",&t1,&t2);

    if(t1 > t2){
      a += (t1+t2);
    }else if(t1 < t2){
      b += (t1+t2);
    }else{
      a += t1;
      b += t2;
    }
  }

  printf("%d %d\n",a,b);

  }

  return 0;

}