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, 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<stdio.h>

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

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

int main(){
	int n,a,b;
	long suma=0,sumb=0;
	cin >> n;
	while(n!=0){
		for(int i=0;i<n;i++){
			cin >> a >> b;
			if(a>b) suma+=a+b;
			else if(a<b) sumb+=a+b;
			else{suma+=a;sumb+=b;}
		}
		printf("%ld %ld\n",suma,sumb);
		cin >> n;
	};
	return 0;
}

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

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, d);
    }

    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int scA=0;
  int scB=0;
  while(1){
  cin>>n;
  if(n==0)break;
  for(int i=0;i<n;i++){
    int a,b;
    cin>>a>>b;
    if(a>b)scA+=a+b;
    if(a<b)scB+=a+b;
    if(a==b){
      scA+=a;
      acB+=b;
    }
  }
    cout<<scA<<' '<<scB<<endl;
  }

  return 0;
  
}

C++: #include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define rrep(i,n) for(int (i)=1;i<=(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
	
	int n;
	while(cin >> n, n) {
		int A = 0, B = 0;
		rep(i, n) {
			int a, b;
			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>
int main() {
	while (1) {
		int n;
		std::cin >> n;
		if (n == 0)
			return 0;
		else {
			int asum = 0, bsum = 0, a, b;
			for (int i = 0; i < n; i++) {
				std::cin >> a >> b;
				if (a > b)
					asum += a+b;
				else
					bsum += a+b;
			}
			std::cout << asum << " " << bsum<<std::endl;
		}
	}
	return 0;
}

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

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

C++: #include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int main() {
	int n, a = 0, b = 0;
	cin >> n;
	
	for_(i,0,n) {
		int aa, bb;
		cin >> aa >> bb;
		
		if (aa > bb) a += (aa + bb);
		else if (aa < bb) b += (aa + bb);
		else a += aa, b += bb;
	}
	
	cout << a << " " << b << endl;
}

C++: // 2011/09/20 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

		int A = 0;
		int B = 0;
		for(int i=0; i<n; i++){
			int a, b;
			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,pointA,pointB;
  int a[10000],b[10000];
  pointA = 0; pointB = 0;
  for(n = 1;n != 0;cin >> n){  
cout << n; 
cin >> n;

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

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

C++: #include<iostream>
#include<vector>
int main() {
	int n;
	int ag = 0, bg = 0;	
	std::cin >> n;
	std::vector<int> a(n), b(n);

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

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>

int main(void)
{
    int n, data_a, data_b;
    int score_a, score_b;

    std::cin >> n;

    score_a = 0;
    score_b = 0;

    for(; n > 0 ; n--) {
        std::cin >> data_a;
        std::cin >> data_b;
        if (data_a > data_b) {
            score_a += (data_a + data_b);
        } else if(data_a < data_b) {
            score_b += (data_a + data_b);
        } else {
            score_a += data_a;
            score_b += data_b;
        }
    }

    std::cout << score_a << " " << score_b << std::endl;

    return 0;
}