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>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
int main(void){
int n,a,b,a1,b1;
while(1){
scanf("%d",&n);
a1=0;
b1=0;
if(n==0){break;}
for(int i=0;i<n;i++){
scanf("%d%d",&a,&b);
if(a>b){
a1=a+b;
}else if(b>a){
b1=a+b;
}else{
a1+=a;
b1+=b;
}
}
printf("%d %d\n",a1,b1);
}
return 0;
}

C++: #include<iostream>
using namespace std;
int i, n, pA, pB, tA = 0, tB = 0;
int main() {
    while(cin >> n) {
        if(n == 0) { break; }
        for (i=1; i<=n; i++) {
            cin >> pA >> pB;
            if (pA >pB) {
                tA += pA + pB;
            } else {
                if (pA < pB) {
                    tB += pA + pB;
                } else {
                    tA += pA;
                    tB += pB;
                }
            }
         }
         cout << tA << " " << tB << endl;
         tA = 0; tB = 0;
    }
    return 0;
}

C++: #include<stdio.h>
int main(void){
    int loop,a,b,c=0,d=0;
    scanf("%d",&loop);
    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 <bits/stdc++.h>
using namespace std;

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;

//-----------------------------------------------------------------------------

int n,a,b;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	while(true) {
		cin>>n;
		if(n==0) break;
		int A=0,B=0;
		REP(i,n) {
			cin>>a>>b;
			if(a>b) A+=a+b;
			else if(a<b) B+=a+b;
			else A+=a,B+=b;
		}
		cout<<A<<' '<<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;
	while(0){
		if (n == 0){
			break;
		}
		else{
			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 <stdio.h>
int main(){
int n,l,r,a,b;
while(1){
scanf("%d",&n);
if(n==0)return 0;
a=b=0;
while(n--){
scanf("%d%d",&l,&r);
if(l>r)a+=l+r;
if(r>l)b+=l+r;
if(l==r){
	a+=l;
	b+=r;
}
}
printf("%d %d\n",a,b);
}
}

C++: #include <stdio.h>

int main(){
	int a, b, as, bs, n;
	scanf("%d", &n);
	while(n != 0){
		as = 0;
		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);
		scanf("%d", &n);
	}
	return 0;
}

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

int main() {
	int n,i,result[2] = {0,0};
	cin >> n;
	int num[2];
	for(i = 0;i < n;i++){
		cin >> num[0] >> num[1];
		if(num[0] > num[1])result[0]+= num[0] + num[1];
		else if(num[0] < num[1])result[1]+= num[0] + num[1];
		else{
			result[0] += num[0];
			result[1] += num[1];
		}
	}
	cout << result[0] << " " << result[1] <<endl;
	return 0;
}

C++: #include <iostream>

using namespace std;

int main(void){
	int n;
	while(cin >> n){
		if(n == 0) break;
		int ap=0,bp=0;
		for(int i=0;i<n;i++){
			int a,b;
			cin >> a >> b;
			if(a > b){
				ap += a + b;
			}else if(a == b){
				ap += a;
				bp += b;
			}else{
				bp += a + b;
			}
		}
		cout << ap << " " << bp << "\n";
	}
}

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

int main()
{
    int n;
    while(cin >> n && n) {
        int p[2][10], s[2] = {0};
        for(int i=0; i < n; ++i) {
            cin >> p[0][i] >> p[1][i];
            if (!(p[0][i] || p[1][i])) continue;
            int sum = p[0][i]+p[1][i];
            if (p[0][i] > p[1][i]) s[0] += sum;
            else if (p[1][i] > p[0][i]) s[1] += sum;
            else s[0] += sum/2, s[1] += sum/2;
        }

        printf("%d %d\n", s[0], s[1]);
    }

    return 0;
}

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

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

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

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

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

int main(){
  int n;
  while(cin >> n && n){
    int A=0,B=0;
    for(int i=0;i<n;i++){
      int a,b;
      cin >> a >> b;
      if(a > b) A += a + b;
      else if(a < b) B += a + b;
      else {
	A += a;
	B += b;
      }
    }
    cout << A << ' '<< B << endl;
  }
}

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

int main()
{
	int n;
	while(cin>>n,n){
	int A=0,B=0;
	for(int i=0;i<n;i++){
		int x,y;
		cin>>x>>y;
		if(x>y)A+=x+y;
		else if(x<y)B+=x+y;
		else A+=x,B+=y;
		}
		cout<<A<<" "<<B<<"\n";
	}
	return 0;
}

C++: #include<iostream>

using namespace std;

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

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int n;
    while(cin >> n && n)
    {
        int a[n], b[n], asum = 0, bsum = 0;
        for(int i=0;i<n;i++) cin >> a[i] >> b[i];
        for(int i=0;i<n;i++)
        {
            if(a[i] > b[i]) asum += a[i] + b[i];
            else if(a[i] == b[i]) {asum += a[i];bsum += b[i];}
            else bsum += a[i] + b[i];
        }
        cout << asum << " " << bsum << "\n";
    }
    
    return 0 ;
}