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=-1;
    int a,b;
    while(cin>>n,n!=0){
       
        int sumA = 0;
        int sumB = 0;
        
        for(int i=0;i<n;i++){
            cin >> a >> b;
        
            if(a>b){
                sumA = sumA+a+b;
            }else if(a==b){
                sumA +=a;
                sumB +=a;
            }else if(b>a){
                sumB = sumB+a+b;
            }      
        }
        cout << sumA << " " << sumB << endl;
    }

    return 0;
}

C++: #include <cstdio>

using namespace std;

int main()
{
	int n;
	int a, b;
	int a_s, b_s;
	
	while (scanf("%d", &n), n != 0){
		a_s = b_s = 0;
		
		while (n != 0){
		scanf("%d %d", &a, &b);
		
		if (a > b) a_s += a + b;
		else if (a < b) b_s += b + a;
		else {
			a_s += a;
			b_s += b;
		}
		n--;
		}
		
		printf("%d %d\n", a_s, b_s);
	}
}

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

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

int main(){
  int n;
  for(;;){
    cin >> n;
    if(!n) { break; }
    int a, b;
    int asum = 0, bsum = 0;
    for(int 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;
  }
  return 0;
}

C++: #include <iostream>
using namespace std;
int main()
{
	int a = 1, e = 0, f = 0, c, d;
	while (a != 0)
	{
		cin >> a;
		e = 0;
		f = 0;
		for (int b = 0; b < a, a != 0; b++)
		{
			cin >> c;
			cin >> d;
			if (c > d)
			{
				e += c;
				e += d;
			}
			else if (d > c)
			{
				f += c;
				f += d;
			}
			else
			{
				e += c;
				f += d;
			}
		}
		cout << e << " " << f << endl;
	}
	return 0;
}

C++: #include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 

using namespace std;

void main()
{
	int n,ca,cb,A,B;

	cin>>n;
	while(n>0){
		ca=cb=A=B=0;
		for(int i=0;i<n;i++){
			cin>>ca>>cb;
			if(ca>cb) A+=ca+cb;
			else if(cb>ca) B+=ca+cb;
			else{A+=ca;B+=cb;}
		}
		cout<<A<<" "<<B<<endl;
		cin>>n;
	}

}

C++: //
//  main.cpp
//  program
//
//  Created by h3032906 on 2016/11/24.
//  Copyright ?? 2016??´ h3032906. All rights reserved.
//

#include <iostream>

int main(int argc, const char * argv[]) {

    int n, a, b;
    int at = 0;
    int bt = 0;
    for( ; ; ){
        std::cin >> n;
        if(n == 0){
            break;
        }
        for(int i = 0; i < n; i++){
            std::cin >> a >> b;
            if(a > b){
                at = at + a + b;
            }
            else if(b > a){
                bt = bt + a + b;
            }
            else {
                at = at + a;
                bt = bt + b;
            }
        }
        std::cout << at << bt << std::endl;
        at = 0;
        bt = 0;
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int a,b,n,ansa=0,ansb=0;

	for(;;){
		cin>>n;
		if(n==0)break;
		ansa=0;
		ansb=0;
		for(int i=0;i<n;i++){
			cin>>a>>b;
			if(a>b){
				ansa=ansa+a+b;
			}
			else if(a<b){
				ansb=ansb+a+b;
			}
			else if(a==b){
				ansa=ansa+a;
				ansb=ansb+b;
			}
		}
		cout<<ansa<<" "<<ansb<<endl;
	}


	return 0;
}

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

int main(){
	int a;
	int uma;
	int ushi;
	int b;
	int c;
	int i;
	while (true){
		cin >> a;
		if (a == 0){ break; }
		else{
			while (true){
				if (i<a){
					cin >> b;
					cin >> c;
					if (b>c){
						uma = uma + b + c;
					}
					if (b == c){
						uma = uma + b;
						ushi = ushi + c;
					}
					else{
						ushi = ushi + b + c;
					}
					i++;
				}if (i = a){ break; }
			}
			cout << uma << " " << ushi << endl;
			uma = 0;
			ushi = 0;
			i = 0;
		}
	}
}

C++: //Bokann ga bokka--nn!!
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
int main(){
	while(1)
	{
		int n;
		scanf("%d",&n);
		if(!n) return 0;
		int a=0,b=0;
		for(int i=0;i<n;i++)
		{
			int x,y;
			scanf("%d %d",&x,&y);
			if(x>y) a+=x+y;
			else if(x<y) b+=x+y;
			else { a+=x; b+=y;}
		}
		printf("%d %d\n",a,b);
	}
}

C++: #include<iostream>
using namespace std;
int main()
{
  int n,a,b,A,B;
  while(cin>>n,n){
    A=B=0;
    while(n-->0){
      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,a,b;
int sumA=0,sumB=0;
while(cin>>n){
	sumA=0,sumB=0;
for(int i=0;i<n;i++){
cin>>a>>b;
if(a>b){
sumA+=a;
sumA+=b;
}
if(a==b){
sumA+=a;
sumB+=b;
}
if(a<b){
sumB+=a;
sumB+=b;
}}
printf("%d %d",sumA,sumB);
}}

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

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

int main(){
	int a, b, n, sa, sb;
	while(1){
		sa = sb = 0;
		cin >> n;
		if( n == 0 )	break;
		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;
	}
	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++: // aoj-5000.cpp

#include <cstdio>

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

	while (1) {
		// read number of cards
		scanf("%d", &cards);
		if (cards == 0) break;
		scoreA = 0;
		scoreB = 0;
	
		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\n", scoreA, scoreB);
	}

	return 0;
}

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

int main()
{
	int n,PointA=0,PointB=0;
	short A,B,a=1;
	cin>>n;
	
	while(n!=0 || a==5){
		for(int i=0;i<n;i++){
			cin>>A>>B;
			if(A>B){
				PointA+=A+B;
			}
			else if(A<B){
				PointB+=A+B;
			}
			else if(A==B){
				PointA+=A;
				PointB+=B;
			}
		}
		cout<<PointA<<" "<<PointB<<endl;
		PointA=0,PointB=0;
	        a++;
		cin>>n;
	}
	
	return 0;
}

C++: #include <stdio.h>

int main(void)
{

	int n;
	int a=0,b=0;
	int ac,bc;

	scanf("%d", &n);

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


	return 0;
}