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>
void judge(int n, int a[], int b[], int *result1, int *result2) {
	while (--n >= 0) {
		if (a[n] > b[n]) {
			*result1 += a[n] + b[n];
		}
		else if (a[n] < b[n]) {
			*result2 += a[n] + b[n];
		}
		else if (a[n] == b[n]) {
			*result1 += a[n];
			* result2 += b[n];
		}
	}
}
int main() {
	int a[10];
	int b[10];
	int n, t = 0;
int i;
	int result1 = 0, result2 = 0;
	int result[10][2];
	do {
		scanf("%d", &n);
		for (i = 0; i < n; i++) {
			scanf("%d %d", &a[i], &b[i]);
		}
		judge(n, a, b, &result1, &result2);
		result[t][0] = result1;
		result[t][1] = result2;
		result1 = 0;
		result2 = 0;
		t++;
	} while (n != 0);

	for (i = 0; i < t-1;i++) {
		printf("%d %d\n", result[i][0], result[i][1]);
	}

	return 0;
}

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

int N;
const int MAX_N = 10000;
int a[MAX_N];
int b[MAX_N];

int main()
{
	cin >> N;
	while(N){
		int geta=0,getb=0;
		for(int i=0;i<N;i++){
			cin >> a[i] >> b[i];
			if(a[i] > b[i])
				geta += a[i] + b[i];
			else if(a[i] < b[i])
				getb += a[i] + b[i];
			else{
				geta += a[i];
				getb += b[i];
			}
		}
		cout << geta << " " << getb << endl;
		cin >> N;
	}
	return 0;
}

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

int main()
{

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

	cin >> n;

	while(n > 0){
		n--;
		cin >> 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;
}

C++: #include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int main(){
    ios::sync_with_stdio(false);

    START:

    int n;
    int a = 0;
    int b = 0;
    cin >> n;
    if(n == 0) return 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;

    goto START;

    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
    while(1){
        int N,suma=0,sumb=0,x,y;
        cin >> N;
        if(N==0)    break;
        while(N--){
            cin >> x >> y;
            if(x>y) suma=suma+x+y;
            else    sumb=sumb+x+y;
        }
        cout << suma << " " << sumb << "\n";
    }
    return 0;
}

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

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

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

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

C++: #include <stdio.h>

int main() {
    while (1) {
        int n;
        scanf("%d", &n);
        if (n == 0) {
            break;
        }

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

C++: #include<iostream>
using namespace std;
int main(){
int n,sum;
int a[10000],b[10000];
while(cin>>n){
a[10000]={};
b[10000]={};
int ap=0,bp=0;
	for(int i=0;i<n;i++){
		cin>>a[n]>>b[n];
		sum=a[n]+b[n];
		if(a[n]>b[n]){
			ap+=sum;
		}else if(a[n]<b[n]){
			bp+=sum;
		}else{
			ap+=a[n];
			bp+=b[n];
		}
	}
	cout<<ap<<" "<<bp<<endl;
}

return 0;
}

C++: #include <stdio.h>
#include <iostream>
using namespace std;
int main (){
while (1){
int i,ny[100]={0},ny2[100]={0},sum=0,sum2=0;
scanf ("%d",&i);
if (i==0)break;
for (int s=0;s<i;s++){
        scanf ("%d%d",&ny[s],&ny2[s]);
}
for (int s=0;s<i;s++){
        if (ny[s]==ny2[s]){
        sum=sum+ny[s];
        sum2=sum2+ny2[s];
        }
        else if (ny[s]>ny2[s]){
                sum=sum+ny[s]+ny2[s];
        }
        else {
                sum2=sum2+ny[s]+ny2[s];
        }
}
printf ("%d %d\n",sum,sum2);
}
return -1;
}

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

}

C++: #include<iostream>
int rounds;
int Ascore, Bscore;
int Acard,Bcard;
int main(){
	while (true){
		std::cin >> rounds;
		if (rounds == 0)break;
		for (int i = 0; i < rounds; i++){
			std::cin >> Acard>> Bcard;
			if (Acard > Bcard){
				Ascore += (Acard + Bcard);
			}
			else if (Acard < Bcard){
				Bscore += (Acard + Bcard);
			}
			else{
				Ascore += Acard;
				Bscore += Bcard;
			}
		}
		std::cout << Ascore << " " << Bscore << "\n";
		Ascore = 0, Bscore = 0;
	}
	return 0;
}

C++: #include <cstdio>
int main(void)
{
  while(1){
    int n;
    scanf("%d",&n);
    if(!n) break;
    int ap=0,bp=0;
    for(int i=0;i<n;i++){
      int a,b;
      scanf("%d %d",&a,&b);
      if(a > b) ap+=a+b;
      else if(a < b) bp+=a+b;
      else { 
	ap += a;
	bp += b;
      }
    }
    printf("%d %d",ap,bp);
  }
}

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

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

C++: #include <iostream>

using namespace std;

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