Go: package main

import (
	"fmt"
)

// Game is one game.
type Game struct {
	pointA, pointB int
}

func main() {
	var n int
	game := &Game{0, 0}
	fmt.Scanf("%d", &n)
	for n != 0 {
		game.initGame()
		game.execGame(n)
		game.printResult()
		fmt.Scanf("%d", &n)
	}
}

func (game *Game) execGame(n int) {
	var a, b int
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a)
		fmt.Scanf("%d", &b)
		switch {
		case a == b:
			game.pointA += a
			game.pointB += b
		case a > b:
			game.pointA += a + b
		case b > a:
			game.pointB += a + b
		}
	}
}

func (game *Game) initGame() {
	game.pointA = 0
	game.pointB = 0
}

func (game *Game) printResult() {
	fmt.Println(game.pointA, game.pointB)
}

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 A = 0, B = 0, j, as, bs;

int main(){
    cin >> j;
    for(int i = 0; i < j; i++){
        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;
    return 0;
}

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

int main(void) {
	int a = 0, b = 0;
	int sumA = 0, sumB = 0;
	int count = 0;
	while (cin >> count) {
		for (int i = 0; i < count; 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++: #include <iostream>
using namespace std;

int main() {
	int q[10001], w[10001];
	
	int x = 1;
	while (1) {
		int n;
		int a = 0;
		int b = 0;
		cin >> n;
		if (n == 0) {
			break;
		}

		for (int i = 1; i <= n; ++i) {
			int c, d;
			cin >> c >> d;
			if (c == d) {
				a = a + c;
				b = b + d;
			}
			else if (c > d) {
				a = a + c + d;
			}
			else {
				b = b + c + d;
			}
		}
		q[x] = a;
		w[x] = b;
		x = x + 1;
	}
	for (int j = 1; j <= x-1; ++j) {
		cout << q[j]<<" "<< w[j] << endl;
	}
}

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

int main(){
	int n, a, b, p1=0,p2=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a>>b;
		if(a>b)p1+=a+b;
		else if(a<b)p2+=a+b;
		else{
			p1+=a;
			p1+=b;
		}
	}
	cout << p1 << " " << p2 << 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;
    for(;loop--;){
    	a=0,b=0,c=0,d=0;
        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;
}

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

int main(){
	int n=0,a=0,b=0;
	int aa=0,bb=0;
	while(cin>>n,n){
		for(int i=0;i<n;i++){
		scanf("%d %d",&a,&b);
		if(a>b)aa+=a+b;
		else if(a<b)bb+=a+b;
		else {
			aa+=a;
			bb+=b;
		}
		}
		cout<<aa<<" "<<bb<<endl;
	}
}

C++: #include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int n;
	while(cin >> n , n){
		int ans[2] = {0};
		rep(i,n){
			int a,b;
			cin >> a >> b;
			if(a==b)ans[0] += a , ans[1] += b;
			else ans[a<b] += a+b;
		}
		cout << ans[0] << " " << ans[1] << endl;
	}
}

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

int main(){
  ios_base::sync_with_stdio(false);
  int n,a,b;
  while(1){
    cin >> n;
    if(n==0) break;
    int ans1=0,ans2=0;
    for(int i=0;i<n;i++){
      cin >> a >> b;
      if(a>b) ans1+=(a+b);
      else if(b>a)ans2+=(a+b);
      else{
	ans1+=a;
	ans2+=b;
      }
    }
    cout << ans1 << ' ' << ans2 << endl;
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int n,s1=0,s2=0,a,b;
	cin>>n;
	if(n==0)break;
	for(int i=0;i<n;i++){
		cin>>a>>b;
		if(a>b)s1+=a+b;
		else if(a<b)s2+=a+b;
		else{
			s1+=a;
			s2+=b;
		}
	}
	cout<<s1<<" "<<s2<<'\n';
	return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>

using namespace std;

int main()
{
	
	while(1)
	{
		int aSum(0),bSum(0);
		int n;

		cin >> n;
		
		if(n == 0)
			break;

		for(int i = 0;i < n;i++)
		{
			int a,b;
			cin >> a >> b;
		
			if(a > b){
				aSum += a + b;
			}else if(a < b){
				bSum += a + b;
			}else{
				aSum += a;
				bSum += b;
			}
		}
		cout << aSum << " " << bSum << endl;
	}
	return 0;
}

C++: // cardgame.cpp
#include <iostream>
using namespace std;

void main(){
	int n;
	int i,j;
	int a[10000], b[10000];
	int a_point=0, b_point=0;
	cin >> n;
	for(i=0;i<n;++i){
			cin >> a[i];
			cin >> b[i];
	}
	for(j=0;j<n;++j){
		if(a[j]>b[j])
			a_point+=(a[j]+b[j]);
        else if(a[j]<b[j])
			b_point+=(a[j]+b[j]);
		else if(a[j]==b[j]){
			a_point+=a[j];
			b_point+=b[j];
		}
	}
		cout << a_point << " " << b_point << endl;
}

C++: #include<iostream>

using namespace std;

int n, A, B;

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

C++: #include<iostream>
using namespace std;
int main(){
    int N,suma=0,sumb=0,x,y;
    cin >> N;
    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<iostream>
using namespace std;
int main(){
	int n,a,b,x,y;
	while(cin>>n,n){
		a=0;b=0;
		for(int i=0;i<n;i++){
			cin>>x>>y;
			if(x>y)
			a=a+x+y;
			else if(y>x)
			b=b+x+y;
			else if(x==y){
			a+=x;b+=y;
			}
		}
		cout<<a<<' '<<b<<endl;
		
	}
	
	
	
	
	
	
	
	return 0;
}

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

C++: #include <iostream>
using namespace std;
     
int main()
{
  while(1){ 
  int i, n, x, y;
  cin >>n;
   
  if(n==0){break;}
  x=0; 
  y=0;
     
  int a[n], b[n];
       
  for(i=1;i<=n;i++)
  {
    cin >>a[i]>>b[i];
    if(a[i]>b[i])
    {
      x += a[i]+b[i];
    }
    else if(a[i]<b[i])
    {
      y += a[i]+b[i];
    }
    else
    {
      x += a[i];
      y += b[i];
    }
    cout <<x<<" "<<y<<"\n";
  }}
     
    
     
  return 0;
}

C++: #include<iostream>
#define N 10000 
using namespace std;
int main(){
  int a[N],b[N],n,scoreA,scoreB;
  while(cin >> n,n != 0){
  
    scoreA = 0; scoreB =0;
  for(int i = 0;i < n;i++){
    cin >> a[i] >> b[i];
  }
  for(int i = 0;i < n;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 = scoreA + a[i]; scoreB += b[i];
    }
  }
  
  cout << scoreA <<" " << scoreB << endl;
  }

}