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 <vector>

int main(){
	while(true){
		int n,a=0,b=0;
		std::cin>>n;
		if(n==0){
			break;
		}
		std::vector<int> v1(n,0);
		std::vector<int> v2(n,0);
		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[10000],b[10000],countA=0,countB=0;
    while(cin>>n,n!=0){
        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]){
                countB+=(a[i]+b[i]);
            }else{//a[i]==b[i]
                countA+=a[i];
                countB+=b[i];
            }
        }
        cout<<countA<<" "<<countB<<endl;
    }
    return(0);
}

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

  return 0;
}

C++: #include<iostream>
using namespace std;
int main() {
	int n = 0;
	int aa, bb = 0;
	while (cin >> n, n != 0) {
		aa = 0;
		bb = 0;
	}
	int a[10000] = {};
	int b[10000] = {};

	
	for(int i = 0;i < n;i++){
		cin >> a[i] >> b[i];
	}
	for (int j = 0; j < n; j++) {
		if (a[j] > b[j]) {
			aa += a[j] + b[j];
		}
		else if (a[j] < b[j]) {
			bb += a[j] + b[j];
		}
		else if (a[j] == b[j]) {
			aa += a[j];
			bb += b[j];
		}
	}
	cout << aa << bb << endl;

	return 0;
}

C++: #include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
int main(void){
int n,a,b,a1,b1;
while(1){
scanf("%d",&n);
a1=0;
b1=0;
if(n==0){break;}
for(int i=0;i<n;i++){
scanf("%d%d",&a,&b);
if(a>b){
a1=a+b;
}else if(b>a){
b1=a+b;
}else{
a1+=a;
b1+=b;
}
}
printf("%d %d\n",a1,b1);
}
return 0;
}

C++: #include<iostream>
using namespace std;
int i, n, pA, pB, tA = 0, tB = 0;
int main() {
    while(cin >> n) {
        if(n == 0) { break; }
        for (i=1; i<=n; i++) {
            cin >> pA >> pB;
            if (pA >pB) {
                tA += pA + pB;
            } else {
                if (pA < pB) {
                    tB += pA + pB;
                } else {
                    tA += pA;
                    tB += pB;
                }
            }
         }
         cout << tA << " " << tB << endl;
         tA = 0; tB = 0;
    }
    return 0;
}

C++: #include<stdio.h>
int main(void){
    int loop,a,b,c=0,d=0;
    scanf("%d",&loop);
    for(;loop--;){
        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 <bits/stdc++.h>
using namespace std;

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;

//-----------------------------------------------------------------------------

int n,a,b;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

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

	return 0;
}

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

C++: #include <stdio.h>
int main(){
int n,l,r,a,b;
while(1){
scanf("%d",&n);
if(n==0)return 0;
a=b=0;
while(n--){
scanf("%d%d",&l,&r);
if(l>r)a+=l+r;
if(r>l)b+=l+r;
if(l==r){
	a+=l;
	b+=r;
}
}
printf("%d %d\n",a,b);
}
}

C++: #include <stdio.h>

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

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{
			result[0] += num[0];
			result[1] += num[1];
		}
	}
	cout << result[0] << " " << result[1] <<endl;
	return 0;
}

C++: #include <iostream>

using namespace std;

int main(void){
	int n;
	while(cin >> n){
		if(n == 0) break;
		int ap=0,bp=0;
		for(int i=0;i<n;i++){
			int a,b;
			cin >> a >> b;
			if(a > b){
				ap += a + b;
			}else if(a == b){
				ap += a;
				bp += b;
			}else{
				bp += a + b;
			}
		}
		cout << ap << " " << bp << "\n";
	}
}

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

int main()
{
    int n;
    while(cin >> n && n) {
        int p[2][10], s[2] = {0};
        for(int i=0; i < n; ++i) {
            cin >> p[0][i] >> p[1][i];
            if (!(p[0][i] || p[1][i])) continue;
            int sum = p[0][i]+p[1][i];
            if (p[0][i] > p[1][i]) s[0] += sum;
            else if (p[1][i] > p[0][i]) s[1] += sum;
            else s[0] += sum/2, s[1] += sum/2;
        }

        printf("%d %d\n", s[0], s[1]);
    }

    return 0;
}

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

int main(){
	int a=0,b=0;
	int na,nb;
	int nc;
	while(1){
	cin>>nc;
	if(nc==0) break;
	for(int i=0;i<nc;i++){
		cin>>na>>nb;
		if(na>nb) a+=(na+nb);
		else if(na<nb) b+=(na+nb);
		else {a+=na;b+=nb;}
	}
	cout<<a<<" "<<b<<endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int n;
	do{
		cin >> n;
		if(n != 0)
		{
			int a[n], b[n], aRes = 0, bRes = 0;
		
			for (int i = 0; i < n; ++i)
			{
				cin >> a[i] >> b[i];
				if(a[i] > b[i])
				{
					aRes += (a[i] + b[i]);
				}
				else if(a[i] < b[i])
				{
					bRes += (a[i] + b[i]);
				}
				else{
					aRes += a[i];
					bRes += b[i];
				}
			}
		
			cout << aRes << " " << bRes;
		}
	}while(n != 0);
}