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>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
#include <cstdio>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  int n;
  int sa,sb;
  while(cin>>n,n){
  sa = sb = 0;
  while(n--){
    int a,b;
    cin>>a>>b;
    if(a>b){
      sa += a + b;
    }else{
      sb += a + b;
    }
  }

  cout<< sa << " " << sb << endl;
  }
}

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

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

C++: #include<cstdio>

using namespace std;

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

C++: #include <cstdio>

using namespace std;

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

C++: #include<stdio.h>

int main(void){
	int a_point,b_point,i,a_card,b_card,n;
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		a_point=0;
		b_point=0;
		for(i=0;i<n;n++){
			scanf("%d %d",&a_card,&b_card);
			if(a_card>b_card) a_point+=(a_card+b_card);
			else if(a_card<b_card) b_point+=(a_card+b_card);
			else {
				a_point+=a_card;
				b_point+=b_card;
			}
		}
		printf("%d %d\n",a_point,b_point);
	}
	return 0;
}

C++: #include<stdio.h>

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

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

C++: #include <iostream>
using namespace std;
int main(){
	int n;
	int num=0,sum=0;

	cin >> n;

	int a[10];
	int b[10];
	for(int i=1; i<=n; i++){

		cin >> a[i] >> b[i];

		if(a[i] > b[i]){
			
			num+=a[i]+=b[i];
		}
		else if(a[i] < b[i]){
			
			sum+=b[i]+=a[i];
		}
		else if(a[i] == b[i]){

			num+=a[i];
			sum+=b[i];
		}
	}

	cout << num << " " << sum << endl;

	return 0;
}

C++: #include<cstdio>
using namespace std;
int main(){
  int A,B,n;
  int a,b;
  while(true){
    scanf("%d",&n);
    if(n == 0)
      break;
    A = B = 0;
    for(int i = 0 ; i < n ; i++){
      scanf("%d %d",&a,&b);
      if(a > b)
        A += (a + b);
      else if(a < b)
        B += (a + b);
      else{
        A += a;
        B += a;
      }
    }
    printf("%d %d\n",A,B);
  }
}

C++: #include<iostream>

void main(){

	int n;

	int a=0, b=0;

	int x, y;

	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;
	}

flag:

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

}

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] << endl;
		cout << w[j] << endl;
	}
}

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

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

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

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

using namespace std;

int main() {
	int n;
	int a,b;
	int ta,tb;

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

C++: #include <iostream>
#include <string>
#include <vector>

int main(){
	int n,a=0,b=0;
	std::cin>>n;
	std::vector<int> v1(n);
	std::vector<int> v2(n);
	for(int i=0;i<n;i++){
		std::cin>>v1[i]>>v2[i];
		if(v1[i]>v2[i]){
			a+=v1[i]+v2[i];
		}else if(v1[i]<v2[i]){
			b+=v1[i]+v2[i];
		}else{
			a+=v1[i];
			b+=v2[i];
		}
	}
	std::cout<<a<<" "<<b<<std::endl;
}

C++: #include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n,a,b,countA=0,countB=0;
    cin>>n;
    if(n!=0){
    do{
        for(int i=0;i<n;i++){
            cin>>a>>b;
            if(a>b){
                countA+=(a+b);
            }else if(a<b){
                countB+=(a+b);
            }//a==b
        }
        cout<<countA<<" "<<countB;
        countA=0,countB=0;
        cin>>n;
        if(n==0)break;
        cout<<"\n";
    }while(1);
    }
    cout<<endl;
}

C++: #include<iostream>
using namespace std;
int main(){
	int a,b,num1=0,num2=0;
	int m;
	cin>>m;
	for(int i=0;i<m;i++){
	cin>>a>>b;
	if(a>b)num1+=a+b;
	else if(a<b)num2+=a+b;
	else {
	num1+=a;num2+=a;
}
	
	
	} 
	cout<<num1<<" "<<num2<<endl;
return 0;
}

C++: 
    #include<iostream>
using namespace std;
int main(){
  int n, a, b;
  int as =0, bs =0;
  cin >> n;
  if (n!= 0){
    for(int 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<<as <<" "<<bs <<endl;
  }
}