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>

using namespace std;

int main()
{
	int n;
	int a[20000], b[20000];
	int a_score;
	int b_score;
	int score_stock[20000][2];
	int i, j;
	for(j = 0;;j++){
		a_score = 0;
		b_score = 0;
		cin >> n;		//J[hÌ
		if(n == 0){
			break;
		}
		
		for(i = 0;i < n; i++){
			cin >> a[i];
			cin >> b[i];
		}
		
		for(; i > -1; i--){
			if(a[i] > b[i]){
				a_score += a[i] + b[i];
			}
			else if(a[i] < b[i]){
				b_score += a[i] + b[i];
			}
			else{
				a_score += a[i];
				b_score += b[i];
			}
		}
		score_stock[j][0] = a_score;
		score_stock[j][1] = b_score;
	}
	for(i = 0; i < j; i++){
		cout << score_stock[i][0] << " "<<score_stock[i][1] << endl;
	}
}

C++: #include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i;
  int a,b,c,d,n;
  while(cin>>n&&n){
    c=d=0;
    for(i=0;i<n;i++){
      cin>>a>>b;
      if(a>b)
	c+=a+b;
      else if(a<b)
	d+=a+b;
      else{
	c+=a;
	d+=b;
      }
    }
    cout<<c<<" "<<d<<endl;
  }
  return 0;
}

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

C++: #include <cstdio>

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

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

int main() {
	int aten = 0,bten = 0,a,b;
	int n;
	cin >> n;
	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 + b;
		}
		else{
			bten = bten + a + b;
		}


	}
	cout << aten << " " << bten << endl;
	return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;
#define pi 3.141592653589793283462
int main(){
	int n;
	int ca=0;
	int cb=0;
	int ia,ib;
	while(1){
		cin>>n;
		if(n==0)
			break;
		for(int i=0;i<n;i++){
		cin>>ia>>ib;
		if(ia>ib)
			ca+=(ia+ib);
		else if(ia<ib)
			cb+=(ia+ib);
		else{
			ca+=ia;
			cb+=ib;
		}
	}
		cout<<ca<<" "<<cb<<endl;
   }
	return 0;
}

C++: #include <stdio.h>
 
int main(void){
    int n;
    int a,b;
    int aSum=0, bSum=0;
    
    scanf("%d", &n);
    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<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<string>
using namespace std;


int main() {

	int n;
	int a, b;
	int ascore = 0, bscore = 0;
	for (;;) {
		cin >> n;
		if (n == 0) break;

		for (int i = 0; i < n; i++) {
			cin >> a >> b;

			if (a > b) ascore += (a + b);
			else if (a < b)bscore += (a + b);
			else {
				ascore += a;
				bscore += b;
			}



		}

		printf("%d %d\n", ascore, bscore);
		ascore = 0;
		bscore = 0;
	}

	//system("pause");
	return 0;
}

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

int main(){

	int n, x, y, pt1, pt2;

	while(cin >> n){
		pt1 = 0;
		pt2 = 0;
	
		if(n == 0) break;
		
		for(int i=0; i<n; i++){
			cin >> x >> y;
			
			if(x > y) pt1 += x + y;
			else if(x < y) pt2 += x + y;
			else {
				pt1 += x;
				pt2 += y;
			}
		}
		
		cout << pt1 << " " << pt2 << endl;
	}

	return 0;

}

C++: #include<iostream>

using namespace std;
#define MAX_N 10000

int N;//カードの枚数
int A[MAX_N],B[MAX_N];
int PA[MAX_N],PB[MAX_N];
int Cou = 0;//何回目の勝負か記憶しておく

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

C++: #include <cstdio>
int main(){
	int a, b, c;
	scanf("%d", a);
	int n_a[a];
	int n_b[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 <stdio.h>

int main () {
    int a, b, n, scorea, scoreb;
    while (1) {
        scanf("%d", &n);
        if (n == 0) break;
        while (n--) {
            scanf("%d %d", &a, &b);
            if (a == b) {
                scorea += a;
                scoreb += b;
            }
            else if (a > b) {
                scorea += a + b;
            } else {
                scoreb += a + b;
            }
        }
        printf("%d %d\n", scorea, scoreb);
    }

    return 0;
}

C++: #include<iostream>

using namespace std ;

int main()
{
	int n ;
	while( cin >> n , n )
	{
		int a ,b ;
		int acnt = 0 , bcnt = 0 ;
		while( n )
		{
			n-- ;
			cin >> a >> b ;
			if( a == b )
			{
				acnt += a ;
				bcnt += b ;
			}
			else
			{
				a > b ? acnt += a + b : bcnt += a + b ;
			}
		}
		cout << acnt << ' ' << bcnt << endl ;
	}
	return 0 ;
}

C++: #include <stdio.h>
#include<math.h>
using namespace std;



int main(){
	int A,B,a,b,n;

	while(true){
		scanf("%d",&n);
		if(n == 0)break;
		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);
	}

    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
int n,a,b,pa,pb;
cin>>n;
for(;n!=0;){
pa=0;pb=0;
for(int i=0;i<n;i++){
cin>>a;
cin>>b;
if(a==b){pa+=a; pb+=a;}
if(a>b){pa+=a+b;}
if(a<b){pb+=a+b;}
}
cout<<pa<<" "<<pb<<endl;
}
return 0;
}

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

C++: // aoj-5000.cpp

#include <cstdio>

int main() {
	int i;
	int cards, a, b, scoreA = 0, scoreB = 0;

	// read number of cards
	scanf("%d", &cards);

	for (i=0; i<cards; ++i) {
		scanf("%d %d", &a, &b);
		if (a > b) {
			scoreA += (a + b);
		} else if (b > a) {
			scoreB += (a + b);
		} else {
			scoreA += a;
			scoreB += b;
		}
	}

	printf("%d %d", scoreA, scoreB);

	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main() {
  int k;
  while(1) {
    cin >> k;
    if(k == 0) break;
    int a,b;
    int A = 0;
    int B = 0;
    for(int c = 0; c < k; ++c) {
      cin >> a >> b;
      if(a > b) {
        A += a + b;
      }else if(a == b) {
        A += a;
        B += b;
      }else if(a < b) {
        B += a + b;
      }
      cout << A << " " << B << endl;
    }
  }
}

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


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

	for(int n; 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 << endl;
	}

	return EXIT_SUCCESS;
}