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 <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
  int n;
  int a,b,sum1,sum2;
  while(cin>>n){
  for(int i=1;i<=n;i++){
    cin>>a>>b;
    if(a>b) {sum1=sum1+a+b;}
    else if(a<b) {sum2=sum2+a+b;}
    else if(a==b) {sum1=sum1+a;sum2=sum2+b;}
    }
    if(sum1!=0||sum2!=0){cout<<sum1<<" "<<sum2<<endl;}
    sum1=0,sum2=0;
  }
  return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<string.h>
using namespace std;
int main(){
	int n;
	int sa=0, sb=0;
	int a, b;
	while (1){
		cin >> n;
		if (n == 0){
			break;
		}
		for (int i = 0; i < n; i++){
			cin >> a >> b;
			if (a>b){
				sa = sa + a + b;
			}
			else if (a < b){
				sb = sb + a + b;
			}
			else{
				sa = sa + a;
				sb = sb + b;
			}
		}
		cout << sa << " "<< sb<<endl;
		sa=0;
		sb=0;

	}
	return 0;
}

C++: #include <iostream>

int main(){
    int n,p1=0,p2=0;
    std::cin >> n;
    while( n != 0){
        for(int i=0;i<n;i++){
            int a ,b;
            std::cin >> a >> b;
            if(a > b){
                p1 += a+b;
            }
            if(b > a){
                p2 += a+b;
            }
            if(a==b){
                p1 += a;
                p2 += b;
            }
        }
        std::cout << p1 << ' ' << p2 << std::endl;
        std::cin >> n;
        p1 = 0;p2=0;
    }
}

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

C++: #include<iostream>
using namespace std;
 
int main () {
    int n, i,A,B, resa =0, resb =0;
    while(cin >> n,n){
        for(i=0;i<n;i++){
             cin >> A >> B;
             (A > B)? resa +=(A+B):resb+=(A+B);
             if(A==B) {resa += A; resb +=B;};
        }
    cout << resa << " " << resb << endl;
    }
}

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

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <sstream>
#include <vector>
#include <string>
#include <iomanip>
#include <bitset>
using namespace std;
#define INF	100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i,n) for(int i = 0; i < n; i++)
#define sz(x) ((int)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).begin(), (x).end(), greater<int>() )
#define clr(a,b) memset((a),(b),sizeof(a))
typedef pair<int, int> P;
typedef long long int ll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<P, vector<P>, greater<P> > PQ;

int n,a,b,A,B;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	while(cin >> n){
		if(n == 0) break;
		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;
	}
}

C++: #include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
using namespace std;

int n,a,b;

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

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

using namespace std;

int main(){
        while(true){
                int pa = 0, pb = 0;      
                int a, b, n, i;
                scanf("%d", &n);
                if(!n) break;
                for(i = 0; i < n; i++){
                        scanf("%d%d", &a, &b);
                        if(a > b)
                                pa += a + b;
                        else if(b > a)
                                pb += a + b;
                        else if(a == b){
                                pa += a;
                                pb += b;
                        }
                }
                printf("%d %d\n", pa, pb);
        }
        return 0;
}

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

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <ctime>
#include <vector>
#include <stack>

using namespace std;
////////////////*My library*////////////////////////
#define rep_to(a,i,n) for(int i=a;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_r(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) cout<<x<<endl
#define s_1(x) cin>>x
#define s_2(x,y) cin>>x>>y
////////////////////////////////////////////////////

////////////////////////
/*prime()*/
/*primecount()*/
/*sort()*/
/*imos???*/
/*????????¢?´¢*/
/*??±???????????¢?´¢*/
/*???????¨???????*/
///////////////////////

int main()
{
	int N;
	int a,b;
	while(1)
	{
		s_1(N);
		if(N==0)break;

		int sumA=0,sumB=0;
		rep(i,N)
		{
			s_2(a,b);
			if(a>b)sumA+=(a+b);
			else if(a<b) sumB+=(a+b);
			else 
			{
				sumA+=a;
				sumB+=b;
			}
		}
		cout<<sumA<<" "<<sumB<<endl;
	}

	return 0;
}

C++: #include <stdio.h>

main()
{
	int A,B,a,b,i,n;
	while(1)
	while(scanf("%d",&n)){
	if(n==0) break;
	A=0;
	B=0;
		for(i=1;i<n+1;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 <iostream>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main() {
    int n, a, b;
    while (cin >> n) {
        int apt = 0, bpt = 0;
        rep(i, n) {
            cin >> a >> b;
            if (a > b) {
                apt += a + b;
            }
            else if (a < b) {
                bpt += a + b;
            }
            else {
                apt += a;
                bpt += b;
            }
        }
        cout << apt << " " << bpt << endl;
    }
    return 0;
}

C++: #include <iostream>

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++){
			if(a[j]>b[j]){
				A+=a[j]+b[j];
			}
			else if(a[j]<b[j]){
				B+=a[j]+b[j];
			}
		}
		cout<<A<<" "<<B<<endl;
	}
	
	return 0;
}