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 <stdio.h>

int main(){
	int a[10000], b[10000];
	int sumA, sumB;
	int n;
	int i;
	
	sumA = 0;
	sumB = 0;
	
	while(1){
		scanf("%d", &n);
		
		if(n==0) break;
		
		for(i=0; i<n; i++){
			scanf("%d %d", a+i, b+i);
		}
		
		/*
		for(i=0; i<n; i++){
			printf("%d %d\n", a[i], b[i]);
		}
		*/
		
		for(i=0;i<n;i++){
			if(a[i] > b[i]) sumA += a[i]+b[i];
			if(a[i] < b[i]) sumB += a[i]+b[i];
			if(a[i] == b[i]){
				sumA += a[i];
				sumB += b[i];
			}
		}
		
		printf("%d %d\n", sumA, sumB);
		
		sumA = 0;
		sumB = 0;
		
	};
	
	return 0;
}

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

int main()
{
	int a;
	int r, l;

	while (cin >> a && (a != 0)){
		int rsum, lsum;
		rsum = 0;
		lsum = 0;
		for (int i = a; i > 0; i--){

			cin >> r;
			cin >> l;
			if (r > l){
				rsum += r + l;
			}
			else if (l > r){
				lsum += r + l;
			}
			else{
				rsum += r;
				lsum += l;
			}
		}
		cout << rsum << ' ' << lsum << endl;
	} 
}

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

using namespace std;

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

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

#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

int n;

int main(){
	while(1){
		cin >> n;
		if(!n){
			break;
		}
		int s = 0, p = 0;
		rep(i, n){
			int a, b;
			cin >> a >> b;
			s += (a + b);
			if(a >= b){
				p += a > b ? a + b : a; 
			}
		}
		cout << p << ' ' << s - p << endl;
	}
	return 0;
}

C++: //============================================================================
// Name        : svdzva.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
using namespace std;
int main() {
	while (true) {
		int n, play1 = 0, play2 = 0, card1[10000], card2[10000];
		cin >> n;
		if (n == 0)
			break;
		for (int i = 0; i < n; i++) {
			cin >> card1[i] >> card2[i];
			if (card1[i] > card2[i]) {
				play1 = play1 + card1[i] + card2[i];
			} else if (card1[i] < card2[i]) {
				play2 = play2 + card2[i] + card1[i];
			} else {
				play1 = play1 + card1[i];
				play2 = play2 + card2[i];
			}
		}
		cout << play1 <<" "<<play2 << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PA;
using namespace std;
#define MAX 1e7
int main(){
    int n;
    while(cin >> n,n){
        vi v(n+1,0);
        vi v2(n+1,0);
        int ans1 = 0; int ans2 =0;
        rep(i,n){
            cin >> v[i] >> v2[i];
            if(v[i]>v2[i])
                ans1+=v[i]+v2[i];
             if(v[i] < v2[i])
                ans2 += v[i]+v2[i];
             if(v[i] == v2[i]){
                ans1+=v[i]; ans2= v2[i];}
        }
        cout << ans1 << " " << ans2 << endl;
    }
}

C++: #include<iostream>
using namespace std;
int main(void){
  int n;
  cin>>n;
  int sumA=0,sumB=0,a,b;
  for(int i=0;i<n;i++){
    cin>>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<iostream>
using namespace std;

int main() {
	int num;
	int score_a = 0;
	int score_b = 0;
	int cnt = 0;
	
	cin >> num;
	while (num != 0) {
		for (int i = 0; i < num; i++) {
			int a;
			int b;

			cin >> a >> b;
			if (a > b) {
				score_a += a + b;
			}else if (b > a) {
				score_b += a + b;
			}else {
				score_a += a;
				score_b += b;
			}
		}
		cout << score_a << " " << score_b << endl;
		score_a = 0;
		score_b = 0;
		cnt++;
	}

	cnt = 0;
	return 0;
}

C++: #include <stdio.h>

int main(void) {
	int n, i, po[2] = {0}, ca[2];
	
	while(scanf("%d", &n)){
		if(!n)break;
	po[0] = 0;
	po[1] = 0;
	for(i = 0; n > i; i++){
		scanf("%d%d", &ca[0], &ca[1]);
		if(ca[0] > ca[1]) po[0] += ca[0]+ca[1];
		else if(ca[0] < ca[1]) po[1] += ca[0]+ca[1];
		else{ po[0] += ca[0]; po[1] += ca[1];}
	}
	printf("%d %d\n",po[0],po[1]);
	}
	return 0;
}

C++: #include<stdio.h>
int main()
{
	int n,a,b,x,y;
	while(scanf("%d",&n),n)
	{
		for(a=b=0;n--;)scanf("%d%d",&x,&y),x==y?a+=x,b+=y:((x>y?a:b)+=x+y);
		printf("%d %d\n",a,b);
	}
	return 0;
}

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

int main(){
	int z;
	int a=0;
	int b=0;
	std::cin>>z;
	std::vector<int> vec1(z);
	std::vector<int> vec2(z);
	for(int i=0;i<z;i++){
		std::cin>>vec1[i];
		std::cin>>vec2[i];
	}
	for(int i=0;i<z;i++){
		if(vec1[i]>vec2[i])a=a+vec1[i]+vec2[i];
		if(vec2[i]>vec1[i])b=b+vec1[i]+vec2[i];
		if(vec1[i]==vec2[i]){
			a=a+vec1[i];
			b=b+vec2[i];
		}
	}
	std::cout<<a<<" "<<b<<std::endl;
	return 0;
}

C++: #include<cstdio>
int main(){
    int a,b,n;
    while(scanf("%d",&n)!=EOF){
        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 <iostream>

using namespace std;

int main(){
	int n,a,b;
	while(cin >> n,n){
		int ta=0,tb=0;
		while(n--){
			cin >> a >> b;
			if(a>b)ta+=(a+b);
			else if(b>a)tb+=(a+b);
			else{
				ta+=a;tb+=b;
			}
		}
		cout << ta <<" "<< tb << endl;
	}
	return 0;
}

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

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

int main()
{
	int a;
	int r, l;
	int rsum, lsum;
	rsum = 0;
	lsum = 0;
	do{
		cin >> a;
		for (int i = a; i > 0; i--){

			cin >> r;
			cin >> l;
			if (r > l){
				rsum += r + l;
			}
			else if (l > r){
				lsum += r + l;
			}
			else{
				rsum += r;
				lsum += l;
			}
		}
		cout << r << ' ' << l << endl;
	} while (a != 0);
}