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>
#include <deque>

using namespace std;
struct card{
	int a;
	int b;
};
int main(){
	deque<card> d;
	card e;
	int n;
	while(cin >> n,n){
		int ta=0,tb=0,flag=0;
		while(n--){
			cin >> e.a >> e.b;
			d.push_back(e);
			if(e.a==e.b)flag=1;
		}
		if(flag){
			while(!d.empty()){
				e=d.front();
				d.pop_front();
				ta+=e.a;tb+=e.b;
			}
		}else{
			while(!d.empty()){
				e=d.front();
				d.pop_front();
				if(e.a>e.b) ta+=(e.a+e.b);
				else tb+=(e.a+e.b);
			}
		}
		cout << ta <<" "<< tb << endl;
	}
	return 0;
}

C++: #include<iostream>
intscore_a,score_b;
intmain(void)
{
usingnamespacestd;
intn,data_a,data_b;
while(1)
{
cin>>n;
if(!n)break;
score_a=0;
score_b=0;
for(;n>0;n--){
cin>>data_a;
cin>>data_b;
if(data_a>data_b){
score_a+=(data_a+data_b);
}elseif(data_a<data_b){
score_b+=(data_a+data_b);
}else{
score_a+=data_a;
score_b+=data_b;
}
}
cout<<score_a<<""<<score_b<<endl;
}
return0;
}

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

int A = 0, B = 0, j;

int main(){
    for(;;){
        if(cin >> j){
            A = 0;
            B = 0;
            if(j == 0){
                break;
            }
            for(int i = 0; i < j; i++){
                int as, bs;
                cin >> as >> bs;
                if(as > bs){
                    A += as + bs;
                }else if(as < bs){
                    B += as + bs;
                }else{
                    A += as;
                    B += bs;
                }
            }
            cout << A << " " << B << endl;
        }else{
            break;
        }
    }
    return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <cmath>

using namespace std;

int main(int args, char *argc[]){
  int n;
  while(cin>>n){
    if(n==0)
      return 0;
    int a=0,b=0;
    for(int i=0;i<n;i++){
      int ia,ib;
      cin>>ia>>ib;
      if(ia==ib){
        a+=ia;
        b+=ib;
      }
      else if(ia<ib)
        b+=(ia+ib);
      else
        a+=(ia+ib);
    }
    printf("%d %d\n",a,b);
  }
  return 0;
}

C++: #include <iostream>
using namespace std;
int main(){ 
	int n;
	int a[3]={0};
	int b[3]={0};
	int A,B;
	for(int i=0;i<5;i++){
                cin>>n;
		if(n==0){break;}
		for(int j=0;j<n;j++){
			if(a[j]>b[j]){
				A+=a[j]+b[j];
			}
			else(a[j]<b[j]){
				B+=a[j]+b[j];
			}
		}
		cout<<A<<" "<<B<<endl;
	}
	
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int n;
	int a[3]={0};
	int b[3]={0};
	int A,B;
	for(int i=0;i<5;i++){
		cin>>n;
		if(n==0){break;}
		for(int j=0;j<n;j++){
			if(a[j]>b[j]){
				A+=a[j]+b[j];
			}
			else if(a[j]<b[j]){
				B+=a[j]+b[j];
			}
			else if(a[j]==b[j]){
				A+=a;
				B+=b;
			}
		}
		cout<<A<<" "<<B<<endl;
	}
	return 0;
}

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

int main()
{
  int n;
  int j, k;
  int suma, sumb;
  
  suma = sumb = 0;
  while (cin >> n){
    for (int i = 0; i < n; i++){
      cin >> j >> k;

      if (j < k){
        sumb += j + k;
     }
      else if (j > k){
        suma += j + k;
      }
     else {
        suma += j;
       sumb += k;
      }
    }
   cout << suma << " " << sumb << endl;
  }
  return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
main(){
  int n,a,b,A,B;
  while(1){
    cin >> n;
    if(!n)break;
    A = B = 0;
    for(int i=0;i<n;i++){
      cin >> a >> b;
      if(a>b){
	A += (a + b);
      }else if(a==b){
	A += a;
	B += b;
      }else {
	B += (a+b);
      }
    }
    cout << A << " " << B << endl;
  }
}

C++: #include<iostream>
using namespace std;
int i, n, pA, pB, tA = 0, tB = 0;
int main(){
while(cin >> n) {
if(n == 0) {break;}
for (i=1; i<=n; i++) {
cin >> pA >> pB;
if (pA > pB) {
tA += pA + pB;
} else {
if (pA < pB) {
tB += pA + pB;
} else {
tA += pA;
tB += pB;
}
}
}
cout << tA << "" << tB << endl;
tA = 0; tB = 0;
}
return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<math.h>
#include    <iomanip>
using namespace std;
int a,b;
int main(){
    int num;
    while(cin>>num&&num!=0){
        int pa=0,pb=0;
        for (int i=0; i<num; i++) {
            cin>>a>>b;
            if (a==b) {
                pa+=a;pb+=a;
            }else if(a>b){
                pa+=(a+b);
            }else{
                pb+=(a+b);
            }
        }
        cout<<pa<<" "<<pb<<endl;
    }
    return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
	int n, card[2][10000];
	while (scanf("%d", &n), n)
	{
		for (int i = 0; i < n; ++i)
			scanf("%d%d", card[0] + i, card[1] + i);
		int A, B;
		A = B = 0;
		for (int i = 0; i < n; ++i)
		{
			if (card[0][i] > card[1][i])
				A += card[0][i] + card[1][i];
			else if (card[0][i] < card[1][i])
				B += card[0][i] + card[1][i];
			else
			{
				A += card[0][i];
				B += card[1][i];
			}
		}
		printf("%d %d\n", A, B);
	}

	return 0;
}

C++: #include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
	long long int a,b,n,x,y;
	a=0;
	b=0;
	scanf("%lld",&n);
	for(long long int i=0;i<n;i++){
		scanf("%lld %lld",&x,&y);
		if(x>y) {a+=(x+y);}
		if(x<y) {b+=(x+y);}
		if(x==y){
			a+=x;
			b+=y;
		}
	}
	printf("%lld %lld\n",a,b);
}

C++: #include<iostream>
int main(){int n,c,d;while(std::cin>>n){int a=0,b=0;if(!n)return 0;while (n--){std::cin>>c>>d;if(c>d)a+=c+d;if(c==d){a+=c;b+=c;}if(c<d)b+=c+d;}printf("%d %d\n",a,b);}}

C++: #include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
    
    int n,a,b,sumA = 0,sumB = 0;
    
    
    while(1){
        cin >> n;
        if(!n) return 0;
        sumA = 0; sumB = 0;
        
        rep(i,0,n){
            cin >> a >> b;
            if(a > b){
                sumA += a+b;
            }
            else if(b > a){
                sumB += a+b;
            }
            else{
                sumA += a;
                sumB += b;
            }
        }
        cout << sumA << " " << sumB << endl;
    }
    return 0;
}

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