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 <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
using namespace std;
int main(){
	
	int n;
	int A=0,B=0;
	cin>>n;
	
	vector<int>a(n);
	vector<int>b(n);
	
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
		if(a[i]>b[i])
			A+=a[i]+b[i];
		else if(b[i]>a[i])
			B+=a[i]+b[i];
		else{
			A+=a[i];
			B+=b[i];
		}
	}
	cout<<A<<" "<<B<<endl;
}

C++: #include <stdio.h>

int main(void)
{
    while(1){
        int n;
        scanf("%d",&n);
        if( n<=0 ) break ;
        int n1=0,n2=0;
        for( int i=0;i<n;i++ ){
            int c1,c2;
            scanf("%d %d",&c1,&c2);
            if( c1>c2 ) n1+=c1+c2;
            else
            if( c1<c2 ) n2+=c1+c2;
            else
                n1+=c1,n2+=c2;
        }
        printf("%d %d\n",n1,n2);
    }
    return 0 ;
}

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

C++: #include<cstdio>

using namespace std;

int main() {
  int n, tmp1, tmp2, a=0, b=0;
  scanf("%d", &n);
  for (int i=n; i>0; i--) {
    scanf("%d %d", &tmp1, &tmp2);
    if (tmp1>tmp2)
      a+=tmp1+tmp2;
    else if (tmp1==tmp2)
      a+=tmp1, b+=tmp2;
    else
      b+=tmp1+tmp2;
  }
  printf("%d %d\n", a, b);
  return 0;
}

C++: #include<iostream>
#include<stdio.h>
using namespace std;
int main(){
    int num,a_score=0,b_score=0;
    while(1){
        scanf( "%d", &num );
        if(num==0)break;
        for(int i=0;i<num;i++){
            int a_card,b_card;
            scanf("%d %d",&a_card,&b_card);
            if(a_card>b_card){a_score+=a_card+b_card;}
            else if(a_card==b_card){a_score+=a_card;b_score+=b_card;}
            else b_score+=a_card+b_card;
        } 
        cout<<a_score<<" "<<b_score<<endl;
    }
    
}

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

using namespace std;

int main(){


	while(1){
		int n;
		cin >> n;
		if(n == 0)
			break;
		vector<int> A,B;
		for(int i = 0; i < n; i++){
			int a,b;
			cin >> a >> b;
			A.push_back(a);
			B.push_back(b);
		}

		int a_score = 0;
		int b_score = 0;
		for(int i = 0; i < A.size(); i++){
			if(A[i] > B[i]){
				a_score += A[i] + B[i];
			}
			else if(A[i] < B[i]){
				b_score += A[i] + B[i];
			}
			else{
				a_score += A[i];
				b_score += B[i];
			}
		}
		cout << a_score << " " << b_score << endl;
	}


	return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
	int all,Atotal=0,Btotal=0;
	int A[all];
	int B[all];
	
	
	cin>>all;
	for(int i=0; i<all; i++){
	cin>> A[i]>>B[i];
	}

	for(int j=0; j<all; j++){
	
	if(A[j]>B[j]){
	Atotal+=A[j]+B[j];
	}

	else if(A[j]<B[j]){
	Btotal+= A[j]+B[j];
	}

	else{
	Atotal+=A[j];
	Btotal+=B[j];
	}
    }
	
	cout<<Atotal<<' '<<Btotal<<'\n';
	return 0;
}

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

using namespace std;

int main(){
  while(true){
    int N, score[] = {0, 0};
    scanf("%d", &N);
    if(N == 0)
      return 0;

    for(int i = 0; i < N; i++){
      int a, b;
      cin >> a >> b;
      if(a > b)
        score[0] += a + b;
      else if(a < b)
        score[1] += a + b;
      else{
        score[0] += a;
        score[1] += b;
      }
    }
    printf("%d %d\n", score[0], score[1]);
  }
}

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

int main(){
	int num_battle;
	int a, b;
	int point_a = 0;
	int point_b = 0;
	string cards;

	cin >> num_battle;
	
	for(; num_battle != 0;){
		while(num_battle > 0){
			cin >> a >> b;
			if(a == b){
				point_a += a;
				point_b += b;
			}else if(a > b){
				point_a += a + b;
			}else{
				point_b += a + b;
			}
			num_battle--;
		}
		cout << point_a << " " << point_b << endl;
		// initialize
		point_a = 0;
		point_b = 0;
		cin >> num_battle;
	}

	return 0;
}

C++: #include<cstdio>

int n;

int main(){
	int A,B,Aanswer=0,Banswer=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d %d",A,B);
		if(A>B)Aanswer+=A+B;
		else if(A<B)Banswer+=A+B;
		else{
			Aanswer+=A;
			Banswer+=B;
		}
	}
	printf("%d %d\n",Aanswer,Banswer);
	return 0;
}

C++: #include <iostream>

using namespace std;

int n,a,b,sum_a,sum_b;

int main(void){
  
  while( cin >> n , n ){
    
    sum_a = sum_b = 0;
    for( int i = 0 ; i < n ; i++ ){
      cin >> a >> b;
      if( a > b ) sum_a += a + b;
      if( a < b ) sum_b += a + b;
      if( a == b ){
	sum_a += a;
	sum_b += b;
      }
    }
    cout << sum_a << " " << sum_b << endl;    
  }
  return 0;
}

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

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

int main(){
  int n;
  int p1,p2;
  while(1){
    cin >> n;
    if(n==0) break;
    int ans1=0,ans2=0;
    for(int i=0;i<n;i++){
      cin >> p1 >> p2;
      if(p1 > p2){
	ans1 += p1 + p2;
      }
      else if(p1 < p2){
	ans2 += p1 + p2;
      }
      else{
	ans1 += p1;
	ans2 += p2;
      }
    }
    cout << ans1 << " " << ans2 << endl;
  }
}

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

int main(){
int n,a,b;
int sumA=0,sumB=0;
while(cin>>n){
	if(n==0)break;
	sumA=0,sumB=0;
for(int i=0;i<n;i++){
cin>>a>>b;
if(a>b){
sumA+=a;
sumA+=b;
}
if(a==b){
sumA+=a;
sumB+=b;
}
if(a<b){
sumB+=a;
sumB+=b;
}}
printf("%d %d\n",sumA,sumB);
}}

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

int main()
{
  int n, x, y;
  cin >>n;
  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 <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;

int main()
{
	int num, wk, tk, A, B;

	while( cin >> num )
	{
		A = 0; B = 0;

		for(int i = 0; i < num; i++)
		{
			cin >> wk >> tk;
			if(wk > tk) A += wk + tk;
			else if(wk < tk) B += wk + tk;
		}

		printf("%d %d", A, B);
		
	}
}