Go: package main

import "fmt"

func main() {
	for {
		var a, b, n int
		fmt.Scanf("%d", &n)

		if n == 0 {
			return
		}

		for i := 0; i < n; i++ {
			var cardA, cardB int
			fmt.Scanf("%d %d", &cardA, &cardB)

			if cardA > cardB {
				a += cardA + cardB
			} else if cardB > cardA {
				b += cardA + cardB
			} else {
				a += cardA
				b += cardB
			}
		}

		fmt.Println(a, b)
	}
}

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

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

int main() {
int n;
cin>>n;
while(n!=0){
	int ap=0,bp=0;
	int a,b;
	for(int k=0;k<n;k++){
		cin>>a>>b;
		if(a>b){
			ap=ap+a+b;
		}
		else if(a<b){
			bp=bp+a+b;
		}
		else{
			ap=ap+a;
			bp=bp+a;
		}
	}
	cout<<ap<<" "<<bp<<endl;
	cin>>n;
}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;

int main(){
  while(scanf("%d",&n),n){
    int a=0,b=0;
    REP(i,n){
      int x,y;
      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<iostream>
using namespace std;

int main() {
  int n;
  while (cin >> n and n != 0) {
    int acard, bcard, ascore = 0, bscore = 0;

    for (int i = 0; i < n; i++) {
      cin >> acard >> bcard;
      
      if (acard > bcard) {
        ascore += acard + bcard;
      } else if (acard < bcard) {
        bscore += acard + bcard;
      } else {
        ascore += acard;
        bscore += bcard;
      }
    }

    cout << ascore << " " << bscore << endl;
  }
}

C++: #include <iostream>

using namespace std;

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