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<cstdlib>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void)
{
    int a,b;
    int input;
    while(1)
    {
        scanf("%d",&input);
        if(input == 0) break;
        char suma[1000000],sumb[1000000];
        int karia = 0,karib = 0;
        for(int i = 0;i<input;i++)
        {
            scanf("%d %d",&a,&b);
            if(a>b) karia+=a+b;
            else if(a<b) karib += a+b;
            else
            {
                karia += a;
                karib += b;
            }
        }
        sprintf(suma,"%d",karia);
        sprintf(sumb,"%d",karib);
        printf("%s %s\n",suma,sumb);

    }
    return 0;
}

C++: #include<cstdio>

using namespace std;

int A=0,B=0;

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

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

class game{
	int length;
	int cur;
	int *r,*l;
	int r_score,l_score;
public:
	game(int _l){
		length = _l;
		r = new int [length];
		l = new int [length];
		r_score = 0;
		l_score = 0;
		cur = 0;
	}
	~game(){
		delete [] r;
		delete [] l;
	}
	void run();
	void insert(int,int);
};

void game::run(){
	for(int i = 0;i < length;i++){
		if(r[i] < l[i]){
			l_score += r[i] + l[i];
		}else if(r[i] > l[i]){
			r_score += r[i] + l[i];
		}else{
			l_score += l[i];
			r_score += r[i];
		}
	}
	cout<<l_score<<" "<<r_score<<endl;
}

void game::insert(int l_card,int r_card){
	r[cur] = r_card;
	l[cur] = l_card;
	cur++;
}

int main(){
	list<game*> lst;
	while(1){
		int read;
		cin>>read;
		if(read == 0){
			break;
		}
		game *g = new game(read);
		for(int i = 0; i < read;i++){
			int r_card,l_card;
			cin>>l_card>>r_card;
			//cout<<l_card<<","<<r_card<<endl;
			g->insert(l_card,r_card);
		}
		lst.push_back(g);
	}

	for(auto it = lst.begin();it != lst.end();it++){
		(*it)->run();
		delete (*it);
	}
	return 0;
}

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

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

C++: 
//Feel free to follow me.
//https://twitter.com/NishiakiGames

#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,a[10000],b[10000],countA,countB;
    while(cin>>n,n!=0){
        countA=0,countB=0;
        for(int i=0;i<n;i++){
            cin>>a[i]>>b[i];
            if(a[i]>b[i]){
                countA+=(a[i]+b[i]);
            }else if(a[i]<b[i]){
                countB+=(a[i]+b[i]);
            }else{//a[i]==b[i]
                countA+=a[i];
                countB+=b[i];
            }
        }
        cout<<countA<<" "<<countB<<endl;
    }
    return(0);
}

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

int main()
{
	int kaisuu, a, b, sum[10] = {0,0,0,0,0,0,0,0,0,0};
	cin >> kaisuu;
	for (int i = 0; i < kaisuu; i++)
	{
		cin >> a >> b;
		if (a > b)
		{
			for (int j = 0 ; j <= 1 ; j++)
			{
				sum[j] = a + b;
				sum[0] += sum[j];
			}
		}

		if (a < b)
		{
			for (int j = 0; j <= 1; j++)
			{
				sum[j] = a + b;
				sum[1] += sum[j];
			}

		}
		
		if (a == b)
		{
			sum[2] = a;
			sum[3] = b;
		}
	}
	cout << endl;
		cout << sum[0] + sum[2] << " " << sum[1] + sum[3] << endl;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stdlib.h>
#include <time.h>
#include <queue>
#include <sstream>
using namespace std;
int main(void){
	int n;
	while(cin >> n){
		if(n == 0)break;
		int a = 0; 
		int b = 0;
		for(int i = 0; i < n; i++){
			int r, l;
			cin >> l >> r;
			if(r < l){
				a += r+l;
			}else if(r > l){
				b += r+l;
			}else if(r == l){
				a += l;
				b += r;
			}
		}
		cout << a << " " << b << endl;
	}
}

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

C++: #include<cstdio>

using namespace std;

int A=0,B=0;

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

C++: #include <stdio.h>
int n,i,j,k;
int A[1],B[1];
int main(){
  for(;;){
    scanf("%d",&n);
    if(n==0){
      return 0;
    } else {
      for(i=0;i<n;i++){
      scanf(" %d %d",&j,&k);
      if(j>k){
        A[0]+=(j+k);
      } else if(j<k){
        B[0]+=(j+k);
      } else if(j==k){
        A[0]+=j;
        B[0]+=k;
      }
    }
    printf("%d %d\n",A[0],B[0]);
  }
}
}

C++: #include <iostream>

using namespace std;

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

C++: #include <iostream>

int main(void)
{
    int i,n, data_a, data_b;
    int a[10000], b[10000];
    int score_a, score_b;

    std::cin >> n;

    score_a = 0;
    score_b = 0;
    for(i=0 ; i<n ; i++) {
        std::cin >> data_a;
        std::cin >> data_b;
        if (data_a > data_b) {
            score_a += (data_a + data_b);
        } else if(data_a < data_b) {
            score_b += (data_a + data_b);
        } else {
            score_a += data_a;
            score_b += data_b;
        }
    }

    std::cout << score_a;
    std::cout << " ";
    std::cout << score_b << std::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\n", scoreA, scoreB);

	return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#define MAX 10000
using namespace std;
int n,m,a[MAX],b[MAX];
string S;

int main(){
    while (1) {
        int p;
        cin >> p;
        if (p!=0) {
            int suma=0,sumb=0;
            for (int i = 0; i<p; i++){
                cin >> n >> m;
                if (n>m) {
                    suma += (n+m);
                }
                if (n<m){
                    sumb += (n+m);
                }
                if (n==m) {
                    suma += n;
                    sumb += m;
                }
            }
            cout << suma << " "<<sumb <<"\n";
        }else{
            break;
        }
    }
    
}