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 <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> P;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main(void){
  int N;
  while(cin>>N){
    int p1=0,p2=0;
    if(N==0) break;
    REP(i,N){
      int n1,n2;
      cin>>n1>>n2;
      if(n1>n2){
        p1+=n1+n2;
      }else if(n1<n2){
        p2+=n1+n2;
      }else{
        p1+=n1;
        p2+=n2;
      }
    }
    cout<<p1<<" "<<p2<<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;
}

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

int main() {
	int num = 0;
	int a[10000] = { 0 };
	int	b[10000] = { 0 };
	int ap = 0;
	int	bp = 0;
	cin >> num;
	for (int i = 0; i < num; i++) {
		cin >> a[i] >> b[i];
		if (a[i] > b[i]) ap += a[i] + b[i];
			else if (a[i] < b[i]) bp += a[i] + b[i];
				else {
					ap += a[i];
					bp += b[i];
				}
		}
	cout << ap << " " << bp << endl;
	cin >> num;
}

C++: #include<stdio.h>

int main(){
	int i=0,w,x,a[10000],b[10000],aP[10000],bP[10000];
	while(i<10000){
		aP[i]=bP[i]=0;
	++i;
	}
	i=0;
	while(1){
	scanf("%d",&x);
	if(x==0){
	return 0;
	}
	while(i<x){
scanf("%d%d",&a[i],&b[i]);
	++i;
	}
	i=0;
	while(i<x){
		if(a[i]==b[i]){
			aP[w]=aP[w]+a[i];
			bP[w]=bP[w]+b[i];
		}else if(a[i]>b[i]){
		aP[w]=aP[w]+a[i]+b[i];
		}else{
		bP[w]=bP[w]+a[i]+b[i];
		}
		++i;
	}
	++w;
	}
	i=0;
	while(i<w){
	printf("%d %d\n",aP[w],bP[w]);
	}
}

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

int main(void) {
	int n;

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

		int sumA = 0, sumB = 0;
		int pointA, pointB;
		for (int i = 0; i < n; i++){

			cin >> pointA >> pointB;
			if (pointA > pointB) {
				sumA += (pointA + pointB);
			} else if (pointB > pointA) {
				sumB += (pointA + pointB);
			} else {
				sumA += pointA;
				sumB += pointA;
			}
		}
		cout << sumA << " " << sumB;
	}

	return 0;
}

C++: #include<iostream>

using namespace std;
#define MAX_N 10000

int N;//カードの枚数
int A[MAX_N],B[MAX_N];
  
int PA = 0,PB = 0;//A,Bのそれぞれの得点
int main(){
  scanf("%d",&N);//配られるカードの枚数
  for(int i = 0;i < N;i++){
    scanf("%d %d",&A[i],&B[i]);
    if(A[i] > B[i])
      PA += A[i]+B[i];
    else if(A[i] < B[i])
      PB += A[i]+B[i];
  }
  printf("%d %d\n",PA,PB);
  return 0;
 
}

C++: #include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n,a,b,countA=0,countB=0;
    do{
        cin>>n;
        if(n==0)break;
        for(int i=0;i<n;i++){
            cin>>a>>b;
            if(a>b){
                countA+=a+b;
            }else if(a<b){
                countB+=b+b;
            }//a==b
        }
        cout<<countA<<" "<<countB<<endl;
    }while(1);
}

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

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

int main() {
	int q[10000 - 1], w[10000 - 1];
	int n;
	int a = 0;
	int b = 0;
	int x = 1;
	while (x == 10000) {
		cin >> n;
		if (n == 0) {
			break;
		}

		for (int i = 1; i <= n; ++i) {
			int c, d;
			cin >> c >> d;
			if (c == d) {
				a = a + c;
				b = b + d;
			}
			else if (c > d) {
				a = a + c + d;
			}
			else {
				b = b + c + d;
			}
		}
		q[x] = a;
		w[x] = b;
		x++;
	}
	for (int j = 1; j <= x; ++j) {
		cout << q[j] << w[j] << endl;
	}
}

C++: #include <stdio.h>

int main(void){

 int s_num = 1;
 int sum1 = 0;
 int sum2 = 0;

 while(1){
 int i;
 scanf("%d",&s_num);
 if(s_num == 0) break;
 for(i = 0;i < s_num; i++){
  int sam1 = 0;
  int sam2 = 0;

  scanf("%d %d",&sam1,&sam2);
  
  if(sam1 > sam2){
   sum1 += (sam1 + sam2);
  }else if(sam1 < sam 2){
   sum2 += (sam1 +sam2);
  }else{
   sum1 += sam1;
   sum2 += sam2;
  }

  printf("%d %d\n",sam1.sam2);
 

 }

 return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
  int t;
  while(cin>>t && t > 0){
    int p1 = 0, p2 = 0;
    while(t > 0){
      int a = 0, b = 0;
      cin >> a >> b;
      if(a >= 0 && a <= 9 && a >= 0 && a <= 9){
        continue;
      }
      if(a > b){
        p1 += a + b;
      }
      else if(a < b){
        p2 += a + b;
      }
      else{
        p1 += a;
        p2 += b;
      }
      t--;
    }
    cout << p1 << " " << p2 << endl;
  }
  return 0;
}