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 <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

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

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen ("testcase.card0500", "r", stdin );
	string str = "";
	int n;

	while (getline (cin, str ) ){
		stringstream ssn(str);
		ssn >> n;
		if (n == 0 ){
			break;
		} // end if
		int sumA = 0, sumB = 0;
		int i;

		for (i = 0; i < n; ++i){
			int cardA = 0, cardB = 0;
			getline (cin, str );
			stringstream ss(str);
			
			ss >> cardA >> cardB;
			if (cardA > cardB ){
				sumA += (cardA + cardB);
			}else if (cardA < cardB){
				sumB += (cardA + cardB);
			}else{
				sumA += cardA;
				sumB += cardB;
			} // end if
		} // end for
		cout << sumA << ' ' << sumB << endl;

	} // end loop
	
	return 0;
}

C++: #include <iostream>

int main(void){
	int *cardsA,*cardsB;
	int cardNum,tempA,tempB,pointA=0,pointB=0,i=0;
while(true){
	std::cin >> cardNum;
	if(cardNum==0) return 0;
	cardsA=new int[cardNum];
	cardsB=new int[cardNum];
	for(;i<cardNum;++i){
		std::cin >> tempA >> tempB;
		cardsA[i]=tempA;
		cardsB[i]=tempB;
	}
	i=0;
	for(;i<cardNum;++i){
		if(cardsA[i]>cardsB[i]) pointA+=cardsA[i]+cardsB[i];
		if(cardsB[i]>cardsA[i]) pointB+=cardsA[i]+cardsB[i];
		if(cardsA[i]==cardsB[i]){
			pointA+=cardsA[i];
			pointB+=cardsA[i];
		}
	}
	std::cout << pointA << " " << pointB << std::endl;
	i=0;
	pointA=0;
	pointB=0;
	delete cardsA;
	delete cardsB;
}
	return 0;
}

C++: #include <stdio.h>

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

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

int main() {
	int aten = 0,bten = 0,a,b;
	int n;
	cin >> n;
	while(true){
		if(n == 0){
			break;
		}
		cin >> a >> b;
		if(a > b){
			aten = aten + a + b;
		}
		else if(a == b){
			aten = aten + a;
			bten = bten + a;
		}
		else{
			bten = bten + b + a;
		}


	}
	cout << aten << " " << bten << endl;
	return 0;
}

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

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

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

int main()
{
	int n;
	int i;
	
	while(1)
	{
		cin >> n;
		if(n == 0) break;
		int as=0,bs=0;
		for(i=0;i<n;i++)
		{
			int a =0,b = 0;
			cin >> a >> b;
			if(a==b)
			{
				as += a;
				bs += b;
			}
			else if(a>b)
			{
				as += (a+b);
			}
			else
			{
				bs += (a+b);
			}
		}
		cout << as << " " << bs << endl;

	}
	
	return 0;
}

C++: 
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <algorithm>

using namespace std;


bool solve(){
	int n;
	cin>> n;
	if(!n) return false;

	int a=0,b=0;
	for(int i=0;i<n;i++){
		int x,y;
		cin>> x>> y;
		if(x==y){
			a+=x;
			b+=y;
		}
		x>y ? a+=(x+y) : b+=(x+y);
	}
	cout<< a<< " "<< b<< endl;
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	while(solve()){};

	return 0;
}

C++: #include <stdio.h>

int main(int ac, char** av) {
  int n, score_a = 0, score_b = 0;
  scanf("%d", &n);
  int *a = (int*) malloc(sizeof(int) * n);
  int *b = (int*) malloc(sizeof(int) * n);
  int i;
  for(i = 0; i < n; i++) {
    scanf("%d %d", a+i, b+i);
  }
  for(i = 0; i < n; i++) {
    if(a[i] > b[i]) {
      score_a += a[i] + b[i];
    } else if(a[i] < b[i]) {
      score_b += a[i] + b[i];
    } else if(a[i] == b[i]) {
      score_a += a[i];
      score_b += b[i];
    }
  }
  printf("%d %d\n", score_a, score_b);
  free(a);
  free(b);
  return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
  int t;
  while(cin>>t && t > 0){
    int p1 = 0, p2 = 0;
    while(t > 0){
      int a = 0, b = 0;
      cin >> a >> b;
      if(a < 0 || a > 9 || a < 0 || a > 9){
        continue;
      }
      if(a > b){
        p1 += a + b;
      }
      else if(a < b){
        p2 += a + b;
      }
      else{
        p1 += a;
        p2 += b;
      }
      t--;
    }
    cout << p1 << " " << p2 << endl;
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{ int n,x=0,y=0,a,b;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a>>b;
if(a>b){
x=x+a+b;}
else if(a==b){
x=x+a;
y=y+b;}
else{
y=y+a+b;}
}
cout<<x<<" "<<y<<"\n";
 return 0;
}

C++: #include<stdio.h>


int main(){
	int n;
	int a=0;
	int	b=0;
	int apoint=0;
	int bpoint=0;
	int i;

	scanf("%d",&n);

	while(n!=0){
		for(i=0;i<n;i++){
			scanf("%d %d",&a,&b);
			if(a<b){
				bpoint = bpoint + a + b;
			}if(a>b){
				apoint = apoint + a + b;
			}if(a==b){
				apoint= apoint + a;
				bpoint= bpoint + b;
			}
		}		
		printf("%d %d\n",apoint,bpoint);
		apoint=0;
		bpoint=0;
		scanf("%d",&n);
	}
}

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<stdio.h>
int main(void)
{
    int i,a,b,c,d,e;
	scanf("%d",&a);
	d=0; e=0;
	for(i=0;i<a;i++){
	scanf("%d %d",&b,&c);
	if(b>c){
	d+=b+c;
	}
	else if(b<c){
	e+=b+c;
	}
	}
	printf("%d %d\n",d,e);
	return 0;
	}

C++: #include <iostream>

using namespace std;

int main ( void )
{
	int n;

	while ( cin >> n, n )
	{
		int A, B;
		A = B = 0;

		for (int i = 0, a, b; i < n; ++i)
		{
			cin >> a >> b;

			if ( a > b )
				A += a + b;
			else if ( a < b )
				B += a + b;
			else
			{
				A += a;
				B += b;
			}
		}

		cout << A << ' ' << B << endl;
	}

	return 0;
}

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