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 a, b[100] = { 0 }, c[100] = { 0 },d=0,e=0;
	cin >> a;
	for (int i = 0; i < a;i++){
		cin >> b[i] >> c[i];
	}
	for (int i = 0; i < a; i++){
		if (b[i]>c[i]){
			d = d + b[i] + c[i];
		}
		else if (b[i] < c[i]){
			e = e + b[i] + c[i];
		}
		else if (b[i] == c[i]){
			d = d + b[i];
			e = e + c[i];
		}
	}
	cout << d << endl;
	cout << e << endl;
	return 0;
}

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

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

int main(){
	int n;
	while (cin >> n, n){
		int inA, inB, ansA = 0, ansB = 0;
		for (int i = 0; i < n; i++){
			cin >> inA >> inB;
			if (inA > inB) ansA += inA + inB;
			else if (inB > inA) ansB += inA + inB;
			else{
				ansA += inA;
				ansB += inB;
			}
		}
		printf("%d %d\n", ansA, ansB);
	}
}

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

int main() {
	int n,i,result[2] = {0,0};
	cin >> n;
	int num[2];
	for(i = 0;i < n;i++){
		cin >> num[0] >> num[1];
		if(num[0] > num[1])result[0]+= num[0] + num[1];
		else if(num[0] < num[1])result[1]+= num[0] + num[1];
		else if(num[0] == num[1]){
			result[0] += num[0];
			result[1] += num[1];
		}
	}
	cout << result[0] << ' ' << result[1] <<endl;
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
    int n,ap,bp,a,b;
    cin>>n;
    while(n!=0){
        ap=0;
        bp=0;
        for(int i=0;i<n;i++){
            cin>>a>>b;
            ap+=a==b?a:(a>b?a+b:0);
            bp+=a==b?b:(a<b?a+b:0);
        }
        cout<<ap<<' '<<bp<<endl;
        cin>>n;
    }
}

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;
else {SA+=A;SB+=B;}
}

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

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

int main(){
	while (1){
		int sum = 0;
		int n;
		int a_sum = 0;
		cin >> n;
		if (!n) return 0;
		for (int i = 0; i < n; i++){
			int a_num, b_num;
			cin >> a_num;
			cin >> b_num;

			if (a_num > b_num){
				a_sum += (a_num + b_num);
			}
			else if (a_num == b_num){
				a_sum += a_num;
			}
			sum += a_num + b_num;
		}

		cout << a_sum << " " << sum - a_sum << "\n";
	}
}

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

int main()
{
    int n;
    while(cin >> n && n) {
        int a, b, c, d;
        for(int i=0; i < n; ++i) {
            cin >> a >> b;
            if (a > b) c += a+b;
            else if (b > a) d += a+b;
            else c += a, d += b;
        }

        printf("%d %d\n", c, a);
    }

    return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    int pointA=0,pointB=0;
    for(int i=0;i<n;i++){
        int a,b;
        cin >> a >> b;
        if(a<b){
            pointB += a+b;
        }
        if(a>b){
            pointA += a+b;
        }
        else{
            pointA += a;
            pointB += b;
        }
    }
    cout << a << b << endl;
}

C++: #include <stdio.h>

int main(void)
{
	int ans_a, ans_b;
	int n;
	int a, b;
	
	while (1){
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		
		ans_a = ans_b = 0;
		while (n){
			scanf("%d %d", &a, &b);
			
			if (a > b){
				ans_a += (a + b);
			}
			else if (a < b){
				ans_b += (a + b);
			}
			else {
				ans_a += a;
				ans_b += b;
			}
			
			n--;
		}
		printf("%d %d\n", ans_a, ans_b);
	}
	
	return (0);
}

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

int main()
{
	int n, a, b, count = 0, pointX = 0, pointY = 0;
	cin >> n;
	do {
		cin >> a >> b;
		if (a > b) {
			pointX += (a + b);
		}
		else if (a < b) {
			pointY += (a + b);
		}
		else {
			pointX += a;
			pointY += b;
		}
		count++;
		if (count == n) {
			cout << pointX << " " << pointY << endl;
			pointX = pointY = count = 0;
			cin >> n;
		}
	} while (n != 0);
	return 0;
}

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

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

C++: #include <stdio.h>

void main()
{
	int n;
	int A, B;
	int playerA = 0, playerB = 0;
	int i = 0;
	
	while (1){
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		
		while (i < n){
			scanf("%d %d", &A, &B);
			if (A == B){
				playerA += A;
				playerB += B;
			}
			else if (A > B){
				playerA += A + B;
			}
			else {
				playerB += A + B;
			}
			i++;
		}
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed 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+b;
      if(a<b) y+=a+b;
      if(a==b) x+=a,y+=b;
    }
    cout<<x<<" "<<y<<endl;
  }
  return 0;
}

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

int 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;
	return 0;	
}

C++: #include <stdio.h>
#define loop(num)	for(int a = 0; a < num; a++)

int main(){
	int num;
	long long A = 0, B = 0;
	int a_card, b_card;
	scanf("%d", &num);
	loop(num){
		scanf("%d%d", &a_card, &b_card);
		if (a_card < b_card) B += (a_card + b_card);
		if (b_card < a_card) A += (a_card + b_card);
		if (a_card == b_card){
			A += a_card;
			B += b_card;
		}
	}
	printf("%lld %lld\n", A, B);
	return 0;
}

C++: #include <stdio.h>


int main()
{

	int n;
	int a=0,b=0;
	int ac,bc;

	scanf("%d\n", &n);

	for(int i = 0; i < n; i++){
		
		scanf("%d %d", &ac,&bc);
		if(ac > bc)
			a += ac + bc;
		else if(ac < bc)
			b += ac + bc;
		else
			a += ac, b += bc;
	}
	printf("%d %d\n", a,b);


	return 0;
}

C++: #include<iostream>

using namespace std;

int main(){

  int n;
  while(cin >> n){
    if(n == 0) break;
    
    int suma = 0, sumb = 0;
  
    for(int i = 0; i < n; i++){
      int a, b;
      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;
}