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++: #define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int n;
	while (cin >> n, n) {
		int a(0), b(0);
		rep(i, 0, n) {
			int x, y; cin >> x >> y;
			if (x == y) {
				a += x;
				b += y;
			}
			else if (x < y)b += x + y;
			else a += x + y;
		}
		cout << a << " " << b << endl;
	}
	return 0;
}

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

int main(){
	int z;
	int a=0;
	int b=0;
	std::cin>>z;
	std::vector<int> vec1(z);
	std::vector<int> vec2(z);
	for(int i=0;i<z;i++){
		std::cin>>vec1[i];
		std::cin>>vec2[i];
	}
	for(int i=0;i<z;i++){
		if(vec1[i]>vec2[i])a=a+vec1[i]+vec2[i];
		if(vec2[i]>vec1[i])b=b+vec1[i]+vec2[i];
		if(vec1[i]==vec2[i]){
			a=a+vec1[i];
			b=b+vec2[i];
		}
	}
	std::cout<<a<<" "<<b<<std::endl;
	
	return 0;
}

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

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;
  int a[10000], b[10000];
  while (1)
  {
    cin >> n;
    if (n == 0) return 0;
    for (int i = 0; i < n; i++)
    {
      cin >> a[i] >> b[i];
    }
    int Ascore = 0, Bscore = 0;
    for (int i = 0; i < n; i++)
    {
      if (a[i] > b[i]) Ascore += a[i]+b[i];
      if (a[i] < b[i]) Bscore += a[i]+b[i];
      if (a[i] == b[i])
      {
        Ascore += a[i];
        Bscore += b[i];
      }
    }
    cout << Ascore << ' ' << Bscore << endl;
  }
}

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

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

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stdlib.h>
#include <time.h>
#include <queue>
#include <sstream>
using namespace std;
int main(void){
	int n;
	while(cin >> n, !0){
		int a = 0; 
		int b = 0;
		for(int i = 0; i < n; i++){
			int r, l;
			cin >> l >> r;
			if(r < l){
				a += r+l;
			}else if(r > l){
				b += r+l;
			}else if(r == l){
				a += l;
				b += r;
			}
		}
		cout << a << " " << b << endl;
	}
}

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

int main()
{
 int a,b,n;
 while(cin>>n, n)
 {
  int x=0, y=0;
 while(n--)
 {
   cin>>a>>b;
   if(a<b) {y+=a+b;}
   else if(a>b) {x+=a+b;}
   else {x+=a; y+=b;}
  }

 cout<<x<<" "<<y<<endl;
}
}

C++: #include <iostream>

using namespace std;

int main(){
	int n,a,b;
	while(cin>>n){
		if(n==0)break;
		int sa=0,sb=0;
		for(;n>0;n--){
			cin>>a>>b;
			if(a>b)sa+=a+b;
			else if(b>a)sb+=a+b;
			else{sa+=a;sb+=b;}
		}
		cout<<sa<<" "<<sb<<endl;
	}
}

C++: #include <bits/stdc++.h>

using namespace std;

int N;

int main() {
	int a, b, totalA, totalB;

	while (cin >> N, N) {
		totalA = totalB = 0;
		for (int i = 0; i < N; ++i) {
			cin >> a >> b;
			if (a > b) {
				totalA += a + b;
			}
			else if (a < b) {
				totalB += a + b;
			}
			else {
				totalA += a;
				totalB += b;
			}
		}
		cout << totalA << " " << totalB << endl;
	}

	return 0;
}

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define vi vector<int>
#define VS vector<string>
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back

using namespace std;



int main(){
	int n;
	while(cin >> n, n){
		int a = 0, b = 0;
		for(int i=0; i < n; i++){
			int in, in2;
			cin >> in >> in2;
			if(in < in2) b += in+in2;
			else if(in > in2) a += in+in2;
			else {
				a += in;
				b += in2;
			}
		}
		cout << a << " " << b << endl;
	}
}

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

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

return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
	int n, a, b, bt, at;

	while (cin >> n){
		at = bt = 0;

		for (int i = 0; i < n; i++){
			cin >> a >> b;
			if (a < b) bt += a + b;
			else if (b < a) at += a + b;
			else {
				at += a;
				bt += b;
			}
		}
		if (n != 0) cout << at << " " << bt << endl;
	}
	return (0);
}

C++: #include <stdio.h>

int main(){
int n,i;
int a,b,f,t;

while(1){
scanf("%d",&n);
if(n==0)break;
a=0;
b=0;
f=0;
t=0;
for(i=0;i<n;i++){
scanf("%d %d",&a,&b);
if(a==b){
f+=a;
t+=b;
}
else if(a>b){
f+=a+b;
}
else if(a<b){
t+=a+b;
}
}
ptintf("%d %d\n",f,t);
}

return 0;
}

C++: #include <cstdio>

using namespace std;

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