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

int main(void)
{
    int i;
    int num, x, y;
    int p1 = 0;
    int p2 = 0;

    for (;;) {
        scnaf("%d", &num);
        if (num == 0) {
            break;
        }

        for (i = 0; i < num; i++) {
            scanf("%d %d", &x, &y);
            if (x > y) {
                p1 += (x+y);
            }
            else if (x < y) {
                p2 += (x+y);
            }
            else {
                p1 += x;
                p2 += y;
            }
        }
        printf("%d %d\n", p1, p2);
    }

    return 0;
}

C++: #include <iostream>
#define REP(i, a, n) for(int i = a; i < n; i++)
using namespace std;


int n;
int a, b;
int A, B;

int main(void) {
  while(1) {
    cin >> n;
    if(n == 0) break;

    A = 0;
    B = 0;

    REP(i, 0, n) {
      cin >> a >> b;
      if(a > b) A += a + b;
      if(a < b) B += a + b;
      if(a == b) A += a, B += b;
    }

    cout << A << " " << B << endl;
  }

  return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
	int n,a,b,pa,pb;

	while(1){
		cin >> n;
		if(n != 0){
			pa = pb = 0;

			for(; n > 0; n--){
				cin >> a;
				cin >> b;

				if(a > b){
					pa += a + b;
				}else if(a < b){
					pb += a + b;
				}else{
					pa += a;
					pb += b;
				}
			}

			cout << pa << " " << pb << endl;
		}else{
			break;
		}
	}

	return 0;
}

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

C++: #include <iostream>

using namespace std;

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

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

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

C++: #include<bits/stdc++.h>
using namespace std;
int a[10000],b[10000],c[10000]={0},d[10000]={0},t;
int main(){
    int i=0;
    while(1){
        cin>>t;
        if(t==0)break;
        for(int z=0;z<t;z++){
            cin>>a[i]>>b[i];
            if(a[i]>b[i]){
                c[i]+=a[i]+b[i];
            }else if(b[i]>a[i]){
                d[i]+=a[i]+b[i];
            }else{
                c[i]+=a[i];
                d[i]+=b[i];
            }
        }
        cout<<c[i]<<" "<<d[i]<<endl;
        i++;
    }
    return 0;
}

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

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

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

using namespace std;
struct card{
	int a;
	int b;
};
int main(){
	deque<card> d;
	card e;
	int n;
	while(cin >> n,n){
		int ta=0,tb=0,flag=0;
		while(n--){
			cin >> e.a >> e.b;
			d.push_back(e);
			if(e.a==e.b)flag=1;
		}
		if(flag){
			while(!d.empty()){
				e=d.front();
				d.pop_front();
				ta+=e.a;tb+=e.b;
			}
		}else{
			while(!d.empty()){
				e=d.front();
				d.pop_front();
				if(e.a>e.b) ta+=(e.a+e.b);
				else tb+=(e.a+e.b);
			}
		}
		cout << ta <<" "<< tb << endl;
	}
	return 0;
}

C++: #include<cstdio>

int n;

int main(){
	while(1){
		int A,B,Aanswer=0,Banswer=0;
		scanf("%d",&n);
		if(n==0)return 0;
		for(int i=0;i<n;i++){
			scanf("%d %d",&A,&B);
			if(A>B)Aanswer+=A+B;
			else if(A<B)Banswer+=A+B;
			else{
				Aanswer+=A;
				Banswer+=B;
			}
		}
		printf("%d %d\n",Aanswer,Banswer);
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <queue>
#include <algorithm>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const double pi=acos(-1);

int n;

int main(){
	while(1){
		cin>>n;
		if(n==0) break;
		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<stdio.h>
#include<iostream>
using namespace std;
int main(){
int card[100],i,j,a=0,b=0,c=1,n;
cin>>n;
while(n!=0){
for(i=0;i<2*n;i++){
cin>>card[i];
}
for(i=0;i<2*n;i=i+2){
if(card[i]>card[c]){
a=a+card[i]+card[c];
}
else if (card[i]==card[c]){
a=a+card[i];
b=b+card[c];
}
else{
b=b+card[i]+card[c];
}
c=c+2;
}
cout<<a<<" "<<b<<endl;
}
cin>>n;
}
return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include "bits/stdc++.h"
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <list>
#define REP(i,a,b) for(i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define SQR(X)  ( (X)*(X) )
#define CUBE(X) ( (X)*(X)*(X) )
 
// #define int ll
 
using namespace std;
 
bool test = 0;
 
/* ?????????????????¬??¨ */
 
int main(){
  int i,j,k,l;
  int n;
  while(scanf("%d",&n) != EOF) {
    if(n == 0) break;
    int score[2] = {0};
    for(i=0;i<n;i++) {
      int num[2];
      cin >> num[0] >> num[1];
      auto sum = num[0]+num[1];
      if(num[0] > num[1]) score[0] += sum;
      else if(num[0] < num[1]) score[1] += sum;
      else {
        for(j=0;j<2;j++) score[i] += num[i];
      }
    }
    printf("%d %d\n",score[0],score[1]);
  }
  return 0;
}

C++: #include <iostream>
using namespace std;
 
int main() {
  int n, a, b, pointA, pointB;

  cin >> n;
  while(n != 0) {
    

    pointA = 0;
    pointB = 0;

    for(int i = 0; i < n; i++) {
      cin >> a >> b;
 
      if(a > b) {
        pointA += (a + b);
      } else if(a > b) {
        pointB += (a + b);
      } else {
        pointA += a;
        pointB += b;
      }
    }

    cout << a << ' ' << b << ' ' << endl;
    cin >> n;
  }   
 
  return 0;
}