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(void){
	int n;
	while( cin >> n, n){
		int ap=0,bp=0,at,bt;
		for(int i=0;i<n;i++){
			cin >> at  >> bt;
			if(at>bt)
				ap+=at+bt;
			else if(bt>at)
				bp+=at+bt;
			else{
				ap+=at;
				bp+=bt;
			}
		}
	cout << ap << ' ' << bp << endl;
	}
	
return 0;
}

C++: #include<stdio.h>
#include<iostream>
using namespace std;
int main(){
int card[100],i,j,a=0,b=0,c=1,n;
cin>>n;
for(i=0;i<2*n;i++){
cin>>card[i];
}
for(i=0;i<2*n;i=i+2){
if(card[i]>card[c]){
a=a+card[i]+card[c];
}
else if (card[i]==card[c]){
a=a+card[i];
b=b+card[c];
}
else{
b=b+card[i]+card[c];
}
c=c+2;
}
cout<<a<<" "<<b<<endl;
return 0;
}

C++: #include<iostream>
#define rep(i,a) for(int i = 0; i < a; i++)
using namespace std;

int main(){
	int n, a, b;
	int a_ans = 0, b_ans = 0;
	while(cin >> n, n){
		rep(i, n){
			cin >> a >> b;
			if(a > b){
				a_ans += (a + b);
			}else if(b > a){
				b_ans += (a + b);
			}else{
				a_ans += a;
				b_ans += b;
			}
		}
		cout << a_ans << " " << b_ans << endl;
		a_ans = 0; b_ans = 0;
	}
}

C++: #include<iostream>
#include<string>
#include<sstream>
#include<cstdlib>

using namespace std;

int main(){
	while(1){
		string str;
		getline(cin,str);
		int n = atoi(str.c_str());
		if(n==0)break;
		int scoreA = 0, scoreB = 0;
		while(n--){
			getline(cin,str);
			stringstream ss(str);
			string tmp;
			getline(ss,tmp,' ');
			int a = atoi(tmp.c_str());
			getline(ss,tmp);
			int b = atoi(tmp.c_str());
			if(a>b)scoreA+=(a+b);
			else scoreB+=(a+b);
		}
		cout<<scoreA<<" "<<scoreB<<endl;
	}
	return 0;
}

C++: #include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
 
using namespace std;
 
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
 
const int INF=1<<29;
const double EPS=1e-9;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main(){
	int n;
	while(true){
		int a=0,b=0;
		cin >> n;
		if(n == 0){
			break;
		}
		rep(i,n){
			int buf,buf2;
			cin >> buf >> buf2;

			if(buf > buf2){
				a += buf + buf2;
			}else if(buf < buf2){
				b += buf + buf2;
			}else{
				a += buf;
				b += buf2;
			}
		}
		cout << a << " " << b << endl;
	}
}

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

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

int main()
{
  int n;
  int j, k;
  int suma, sumb;
  
  suma = sumb = 0;
  while (cin >> n){
    if (n == 0){
      break;
    }
    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<iostream>

int main() {

	int n;

	int a[1000];

	int b[1000];

	for (int i = 0; i < 1000; i++){
		a[i] = 0;
	b[i] = 0;
}

	int x, y;

	int j=0;

	f:

	std::cin >> n;

	if (n == 0)
		goto flag;

	for (int i = 0; i < n; i++) {
		std::cin >> x >> y;
		if (x > y)
			a[j] += (x + y);
		if (x < y)
			b[j] += (x + y);
		if (x == y){
			a[j] += x;
		b[j] += y;
	}
	}

	j++;

	goto f;

flag:

	for(int i=0;i<j;i++)
	std::cout << a[i] << ' ' << b[i] << std::endl;

	return 0;

}

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

C++: #include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<long long,int> P;
static const int INF=1<<24;

int n;
int a[1010],b[1010];

int main(){
	while(cin>>n,n){
		rep(i,n){
			cin>>a[i]>>b[i];
		}
		int ans1=0,ans2=0;
		rep(i,n){
			if(a[i]<b[i]){
				ans2+=a[i]+b[i];
			}
			else if(a[i]==b[i]){
				ans1+=a[i];
				ans2+=b[i];
			}
			else{
				ans1+=a[i]+b[i];
			}
		}
		cout<<ans1<<" "<<ans2<<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<iostream>
using namespace std;
#define MAX 10010

int main()
{
    int n;
    while(cin >> n)
    {
        if(n==0)break;
        int pointa=0, pointb =0;
        int carda,cardb;
        for(int i=0;i<n;i++)
        {
            cin >> carda >> cardb;
            if( carda > cardb ){pointa += (carda+cardb); continue;}
            else if( carda<cardb ){pointb += (carda+cardb); continue;}
            else
            {
                pointa += carda;
                pointb += cardb;
                continue;
            }
        }
        cout << pointa  << " " << pointb << endl;
    }

    return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
	int n;
	int a,b;
	int sa=0,sb=0;//score
	
	
	while(cin>>n&&n!=0){
	for(int i=0;i<n;i++)
	{
		cin>>a>>b;
		if(a<b){sb+=(a+b);}
		else if(a>b){sa+=(a+b);}
		else
		{
			sa+=a;
			sb+=b;
		}
	}
	cout<<sa<<" "<<sb<<"\n";
	sa=0;sb=0;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(void){
  int n;
  while(cin>>n&&n!=0){
    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++: //============================================================================
// Name        : svdzva.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
#include<algorithm>
using namespace std;

int main() {
	int n, play1 = 0, play2 = 0, card1[10000], card2[10000];
	while (true) {
		cin >> n;
		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;
}