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 <string>
#include <cstdio>

using namespace std;

int cnt = 0;

void calc_point(int n, int card[10000][2], int point[10000][2]) {
	//get input
	for (int i = 0; i < n; i++){
		if (card[i][0] > card[i][1])
			point[cnt][0] += card[i][0]+card[i][1];
		else if(card[i][0] < card[i][1])
			point[cnt][1] += card[i][0]+card[i][1];
		else{
			point[cnt][0] += card[i][0];
			point[cnt][1] += card[i][1];
		}
	}
	cnt++;
}

int main(){
	int n = 1;
	int card[10000][2];
	int point[10000][2];
	while (1){
		scanf("%d", &n);
		if (n==0) break;
		for (int i = 0; i < n; i++){
			for (int j = 0; j < 2; j++)
				scanf("%d", &card[i][j]);
		}
		calc_point(n, card, point);
	}
	for (int i = 0; i < cnt; i++)
		cout << point[i][0] <<" "<< point[i][1] << endl;
}

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

int main() {
	int num;
	int score_a = 0;
	int score_b = 0;
	int cnt = 0;
	
	cin >> num;
	while ((num != 0) && (cnt <= 5)) {
		for (int i = 0; i < num; i++) {
			int a;
			int b;

			cin >> a >> b;
			if (a > b) {
				score_a += a + b;
			}else if (b > a) {
				score_b += a + b;
			}else {
				score_a += a;
				score_b += b;
			}
		}
		cout << score_a << " " << score_b << endl;
		score_a = 0;
		score_b = 0;
		cnt++;
	}

	cnt = 0;
	return 0;
}

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

C++: #include<iostream>
#include <stdio.h>
using namespace std;
  
int main(){
	while(1){
	int n;
	cin>>n;
	int counta=0;
	int countb=0;
	int a[10000],b[10000];
	if(n==0)break;
	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]){counta+=a[i];
		countb+=a[i];}else{countb+=a[i]+b[i];}}
	cout<<counta<<" "<<countb<<endl;}
	return 0;}

C++: #include<iostream>

using namespace std;

int main(){
  int n, i, Apoint, Bpoint;
  int A[10000], B[10000];
  while(cin >> n ,n){
    Apoint, Bpoint = 0, 0;
    for(i=0; i<n; i++){
      cin >> A[i] >> B[i];
    }
    for(i=0; i<n; i++){
      if(A[i]>B[i])Apoint += A[i]+B[i];
      else if (A[i]<B[i])Bpoint += B[i]+A[i];
      else{
	Apoint += A[i];
	Bpoint += B[i];
      }
    }

    cout << Apoint << " " << Bpoint << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>

using namespace std;

int main() {
	int n;
	cin >> n;
	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 (x < y) {
			b += x + y;
		} else {
			a += x;
			b += y;
		}
	}
	cout << a << b << endl;
	return 0;
}

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

int main(){
	int n, a, b;
	while (true)
	{
		int point_a = 0, point_b = 0;
		cin >> n;
		if (cin.eof()||n==0) { break; }
		for(int i =0;i<n;i++){
			cin >> a >> b;
			if(a==b){
				point_a += a;
				point_b += b;
			}
			else if (a>b){
				point_a += a + b;
			}
			else {
				point_b += a + b;
			}
		}
		cout << a << " " << b << endl;
	}
}

C++: #include<iostream>

int main(){

	int n;

	int a=0, b=0;

	int x, y;

	f:

	std::cin >> n;

	if (n == 0)
		goto flag;

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

	std::cout << a << ' ' << b << std::endl;

	goto f;

flag:

	std::cout << "" << std::endl;

	return 0;

}

C++: #include<stdio.h>

int main(){
	int i=0,w=0,x,a[10000],b[10000],aP[10000],bP[10000];
	while(i<10000){
		aP[i]=bP[i]=0;
	++i;
	}
	i=0;
	while(1){
	scanf("%d",&x);
	if(x==0){
	return 0;
	}
	while(i<x){
scanf("%d%d",&a[i],&b[i]);
	++i;
	}
	i=0;
	while(i<x){
		if(a[i]==b[i]){
			aP[w]=aP[w]+a[i];
			bP[w]=bP[w]+b[i];
		}else if(a[i]>b[i]){
		aP[w]=aP[w]+a[i]+b[i];
		}else{
		bP[w]=bP[w]+a[i]+b[i];
		}
		++i;
	}
	++w;
	}
	i=0;
	while(i<w){
	printf("%d %d\n",aP[w],bP[w]);
	}
}

C++: #include <iostream>

using namespace std;

int main() {
  for (;;) {
    int n, pa = 0, pb = 0;
    cin >> n;
    if (!n) return 0;
    for (int i = 0; i < n; i++) {
      int a, b;
      cin >> a >> b;
      if (a == b) {
        pa += a;
        pb += b;
      } else
        (a > b ? pa : pb) += a + b;
    }
    cout << pa << ' ' << pb << endl;
  }
}

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

int main(){
	
	int n,j=0;
	int A[10000], B[10000];
	
	
	while(j<5){
	
	int scoreA=0,scoreB=0;
		cin>>n;
		if(n==0){break;}
	for(int i=0;i<n;i++)
	{
		
		cin >>A[i];
		cin>>B[i];
		if(A[i]>B[i])
		{scoreA+=(A[i]+B[i]);}
			
		else if(A[i]<B[i])
			{scoreB+=(A[i]+B[i]);}
		else if(A[i]==B[i])
				{scoreA+=A[i];
				scoreB+=B[i];}
	}
		cout<<scoreA<<" "<<scoreB<<endl;
		j++;
	}
	return 0;
}

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

int main(void) {
	int i, n, a, b, as = 0, bs = 0;
	cin >> n;

	for(i=0 ; i<n ; i++) {
		cin >> a >> b;
		if(a > b)		{ as += a + b; }
		else if(a < b)	{ bs += a + b; }
		else 			{ as += a; bs += b; }
	}
	cout.form("%d %d\n", as, bs);
	return 0;
}

C++: #include <iostream>

using namespace std;

int main() {

  while(true) {
    int n;
    cin >> n;
    int pa = 0, pb = 0;
    int stack = 0;
    for(int i = 0; i < n; i++) {
      int a, b;
      cin >> a >> b;
      if(a > b) {
        pa += stack + a + b;
        stack = 0;
      }
      else if(a < b) {
        pb += stack + a + b;
        stack = 0;
      }
      else {
        stack += a + b;
      }
    }
    cout << pa << " " << pb << endl;
  }

  return 0;
}

C++: #include <iostream>
using namespace std;
int main(){

	int n, a, b, ap = 0, bp = 0, i;

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

		//?????°?????´??°
		if (a > b)
			ap += a + b;
		else if (a < b)
			bp += a + b;
		else{
			ap += a;
			bp += b;
		}
	}

	cout << ap << ' ' << bp << endl;
}

C++: #include<stdio.h>

int main(){

int N;int A,B,SA=0,SB=0;
while(1){
SA=0,SB=0;

scanf("%d",&N);
if(N==0)break;
for(int i=0;i<N;i++){
scanf("%d %d",&A,&B);
if(A>B)SA=SA+A+B;
else if(B>A)SB=SB+A+B;
}

printf("%d %d\n",SA,SB);
}
return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
  int n,l,r,a,b;
  while(cin>>n,n){
    a=b=0;
    while(n--){
      cin>>l>>r;
      if(l>r) a+=l+r;
      else if(r>l) b+=l+r;
      else{
	a+=l;b+=r;
      }
    }
    cout<<a<<' '<<b<<endl;
  }
  return 0;
}

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

int main(){
	int a=0,b=0,ca,cb,n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>ca>>cb;
		if(ca>cb)a+=(ca+cb);
		else if(ca<cb)b+=(ca+cb);
		else{
			a+=ca;
			b+=cb;
		}
	}
	cout<<a<<' '<<b<<endl;
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define REP(i,N) for(int i = 0; i < (int)N; i++)

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

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

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