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<iostream>
using namespace std;

int main()
{
    int n;

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

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

int main () {
    int n, i,A,B, resa =0, resb =0;
    while(cin >> n,n){
        for(i=0;i<n;i++){
           　cin >> A >> B;
             (A > B)? resa +=A:resb+=B;
             if(A==B) {resa += A; resb +=B};
        }
　　　　cout << resa << " " << resb << endl;
    }
}

C++: #include <iostream>

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

C++: #include <stdio.h>

int main(){
	long long Right_Point = 0;
	long long Left_Point = 0;

	int Right_Card, Left_Card;

	int kaisuu;

	Right_Point = 0;
	Left_Point = 0;
	scanf("%d", &kaisuu);
	for (int a = 0; a < kaisuu; a++){
		scanf("%d%d", &Right_Card, &Left_Card);
		if (Right_Card == Left_Card){
			Right_Point += Right_Card;
			Left_Point += Left_Point;
		}
		else if (Right_Card < Left_Card){
			Left_Point = Left_Point + (Right_Card + Left_Card);
		}
		else
			Right_Point = Right_Point + (Right_Card + Left_Card);
	}
	printf("%d %d\n", Right_Point, Left_Point);
	return 0;
}

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

int main(){
  int pnt_a = 0;
  int pnt_b = 0;
  int car_a;
  int car_b;
  int num;

  while(cin >> num){
    if(!num) break;
    for(; num; num--){
      cin >> car_a;
      cin >> car_b;
      if(car_a < car_b) pnt_b += (car_a + car_b);
      else if (car_a > car_b) pnt_a += (car_a + car_b);
      else {pnt_a += car_a; pnt_b += car_b;}
    }

    cout << pnt_a << " " << pnt_b << "\n";
  }

return 0;
}

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

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

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

int main() {
    int n, a, b;
    while (cin >> n) {
        int apt = 0, bpt = 0;
        rep(i, n) {
            cin >> a >> b;
            if (a > b) {
                apt += a + b;
            }
            else if (a < b) {
                bpt += a + b;
            }
            else {
                apt += a;
                bpt += b;
            }
        }
        cout << apt << " " << bpt << 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];
	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;
}

C++: #include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
	long long int a,b,n,x,y;
while(1){	a=0;
	b=0;
	scanf("%lld",&n);
	if(n==0) break;
	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);}
	return 0;
}

C++: #include<iostream>
using namespace std;
 
int main () {
    int n, i,A,B, resa =0, resb =0;
    while(cin >> n,n){
        resa=0;resb=0;
        for(i=0;i<n;i++){
             cin >> A >> B;
             (A > B)? resa +=(A+B):resb+=(A+B);
             if(A==B) {resa += A; resb +=B;};
        }
    cout << resa << " " << resb << endl;
    }
}

C++: #include<iostream>

int main(){
	while(1){
		int n;
		std::cin >> n;
		if(n == 0)break;
		int a = 0, b = 0;
		for(int i = 0; i < n; ++i){
			int a1,b1;
			std::cin >> a1 >> b1;
			if(a1 > b1) a += a1 + b1;
			else if(a1 < b1) b += a1 + b1;
		}
		std::cout << a << " " << b << std::endl;
	}
	return 0;
}

C++: #include <cstdio>
int main(){
 int asum,bsum,a,b,n,i;
 asum=bsum=0;
 scanf("%d",&n);
 for(i=0;i<n;i++){
  scanf("%d %d",&a,&b);
  if (a>b) asum += a+b;
  if (a<b) bsum += a+b;
  if (a==b) { asum += a; bsum += b; }
 };
 printf("%d %d\n",asum,bsum);
 return 0;
};

C++: #include <stdio.h>
int main(){
  for(;;){
    int n,i,j,k;
    int A=0,B=0;
    scanf("%d",&n);
    if(n==0){
      return 0;
    }
      for(i=0;i<n;i++){
      scanf(" %d %d",&j,&k);
      if(j>k){
        A+=(j+k);
      } else if(j<k){
        B+=(j+k);
      } else if(j==k){
        A+=j;
        B+=k;
      }
      printf("%d %d\n",A,B);
    }
  }
}

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

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

int main()
{
	//std::ios::
	int n;
	int a,b;
	int sa,sb;//score
	
	cin>>n;
	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<<a<<" "<<b<<"\n";
	return 0;
}

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

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