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<cstdio>
int main()
{
    int n,A,B,a,b;
    while(1)
    {
        A=0;
        B=0;
        scanf("%d",&n);
        if(n==0)break;
        for(int i=0;i<n;i++)
        {
            scanf("%d%d",&a,&b);
            if(a>b)A=A+a+b;
            else if(a<b)B=B+a+b;
            else
            {
                A+=a;
                B+=b;
            }
        }
        printf("%d %d\n",A,B);
    }
    return 0;
}

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

int main(){
  int n;
  while(cin >> n && n){
    int A=0,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;
  }
}

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

int main()
{
	int n;
	while(cin>>n,n){
	int A=0,B=0;
	for(int i=0;i<n;i++){
		int x,y;
		cin>>x>>y;
		if(x>y)A+=x+y;
		else if(x<y)B+=x+y;
		else A+=x,B+=y;
		}
		cout<<A<<" "<<B<<"\n";
	}
	return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
  while(1){
    int n;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;
  }
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int n;
    while(cin >> n && n)
    {
        int a[n], b[n], asum = 0, bsum = 0;
        for(int i=0;i<n;i++) cin >> a[i] >> b[i];
        for(int i=0;i<n;i++)
        {
            if(a[i] > b[i]) asum += a[i] + b[i];
            else if(a[i] == b[i]) {asum += a[i];bsum += b[i];}
            else bsum += a[i] + b[i];
        }
        cout << asum << " " << bsum << "\n";
    }
    
    return 0 ;
}

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

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

    vector<int> point(2);
    vector<int> buf_point(2);
    for (int i = 0; i < n; ++i)
    {
      cin >> buf_point[0] >> buf_point[1];
      if (buf_point[0] > buf_point[1])
      {
        point[0] += buf_point[0] + buf_point[1];
      }
      else if (buf_point[1] > buf_point[0])
      {
        point[1] += buf_point[0] + buf_point[1];
      }
      else
      {
        point[0] += buf_point[0];
        point[1] += buf_point[1];
      }
    }
    cout << point[0] << " " << point[1] << endl;
  }
  return 0;
}

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

int main(){
	int n=0,a=0,b=0;
	int aa,bb;
	while(cin>>n,n){
		aa=0;
		bb=0;
		for(int i=0;i<n;i++){
		scanf("%d %d",&a,&b);
		if(a>b)aa+=a+b;
		else if(a<b)bb+=a+b;
		else {
			aa+=a;
			bb+=b;
		}
		}
		cout<<aa<<" "<<bb<<endl;
	}
}

C++: #include<cstdio>

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

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

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

int main() {
  int n;
  while (cin >> n, n) {
    vector<int> A(n), B(n);
    for (int i = 0; i < n; ++i)
      cin >> A[i] >> B[i];
    int scoreA = 0, scoreB = 0;
    for (int i = 0; i < n; ++i) {
      if (A[i] == B[i])
        scoreA += A[i], scoreB += B[i];
      else if (A[i] < B[i])
        scoreB += A[i] + B[i];
      else
        scoreA += A[i] + B[i];
    }
    cout << scoreA << " " << scoreB << endl;
  }
}

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

int main()
{
 int a,b,n,x=0,y=0;
 cin>>n;
 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<<" "<<b<<endl;
 return 0;
}

C++: #include<cstdio>

using namespace std;

int main(void){
	int n;
	while (1){
		int A = 0, B = 0;
		scanf_s("%d", &n);
		if (n == 0)return 0;
		for (int i = 0; i < n; i++){
			int a, b;
			scanf_s("%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<stdio.h>
int main(void)
{
    int i,a,b,c,d,e;
	while(1){
	scanf("%d",&a);
	if(a==0) break;
	d=0; e=0;
	for(i=0;i<a;i++){
	scanf("%d %d",&b,&c);
	if(b==c){
	d+=b;
	e+=c;
	}
	else if(b>c){
	d+=b+c;
	}
	else if(b<c){
	e+=b+c;
	}
	}
	printf("%d %d\n",d,e);
	}
	return 0;
	}

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


int main(){

    int n;
    int apt=0,bpt=0;
    int a[10000]={0};
    int b[10000]={0};
    for(;;){
        apt=0;
        bpt=0;
    cin >> n;
    if(n==0)break;
    for(int i=0; i < n; i++){
        cin >>a[i];
        cin >>b[i];
    }
    for(int i=0; i < n; i++){
        if(a[i]>b[i])apt+=a[i]+b[i];
        else if(a[i]<b[i])bpt+=a[i]+b[i];
        else apt+=a[i],bpt+=b[i];
        }
    cout<<apt<<' '<<bpt<<endl;
    }
    return 0;
}

C++: #include<cstdio>
main(){
	int n;
	while(scanf("%d",&n),n){
		int a,b,c = 0,d = 0;
		while(n--){
			scanf("%d%d",&a,&b);
			c+=a>b?a+b:a==b?a:0;
			d+=b>a?a+b:a==b?b:0;
		}
		printf("%d %d\n",c,d);
	}
}

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;
  cin>>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<cstdio>
#include<cstdlib>
#include<iostream>
#include<string>
#include<map>
#include<vector>

using namespace std;

int main(){
  
  int n,anum,bnum;
  int as, bs;
  
  as = bs = 0;
  
  while(1){
    scanf("%d",&n);
    
    if(n == 0) break;  
    
    for(int i = 0 ; i < n ; i++){
      scanf("%d%d",&anum,&bnum);
      
      if(anum == bnum){
	as += anum;
	bs += bnum;
      }
      
      else if(anum > bnum){
	as += anum;
	as += bnum; 
      }
      
      else if(anum < bnum){
	bs += anum;
	bs += bnum; 
      }  
    }
    
    printf("%d %d\n",as,bs);

    as = bs = 0;

  }
  return 0;
}