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;
    int a_point = 0, b_point = 0;

    cin >> n;
    for(int i=1; i<=n; i++){
        int tmp1, tmp2;
        cin >> tmp1 >> tmp2;
        if(tmp1 > tmp2){
            a_point += tmp1 + tmp2;
        }else if (tmp1 < tmp2){
            b_point += tmp1 + tmp2;
        }else{
            a_point += tmp1;
            b_point += tmp2;
        }
    }
    cout << a_point << " " << b_point << endl;
    return 0;
}

C++: 3
9 1
5 4
0 8
3
9 1
5 4
1 0
3
9 1
5 5
1 8
0

C++: #include<iostream>
using namespace std;
int n,a,b,c,d;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a>>b;
		if(a>b)c+=(a+b);
		if(a<b)d+=(a+b);
		if(a==b){c+=a;d+=b;}
	}
	cout<<c<<' '<<d<<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;
	
	while (cin >> n, n) {
		int a = 0, b = 0;
				
		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++: #include<iostream>
#include<stdio.h>
using namespace std;
int main(){
    int num,a_score=0,b_score=0;
    
    scanf( "%d", &num );
    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>
using namespace std;

int main(){
	int matchCount = 0;
	int inputCount;
	int pointSumA[5] = {0}, pointSumB[5] = {0};
	
	while(cin >> inputCount){
		//cout << inputCount << endl;
		if (!inputCount) break;
		
		int cnt = 0;
		while (cnt++ < inputCount){
			int tempA, tempB;
			cin >> tempA >> tempB;
			if (tempA > tempB){
				pointSumA[matchCount] += (tempA + tempB);
			} else if (tempA == tempB) {
				pointSumA[matchCount] += tempA;
				pointSumB[matchCount] += tempA;
			} else {
				pointSumB[matchCount] += (tempA + tempB);
			}
		}
		matchCount++;
	}
	int cnt2 = 0;
	while(cnt2 < matchCount){
		cout << pointSumA[cnt2++] << " " << pointSumB[cnt2] << endl;
	}
	return 0;
}

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

int main(){
	int n,hand[2],sum[2];
	while(1){
		sum[0]=0;
		sum[1]=0;
		cin>>n;
		if(n==0)break;
		for(int i=0;i<n;i++){
			cin>>hand[0]>>hand[1];
			if(hand[0]>hand[1]){
				sum[0]+=hand[0]+hand[1];
			}else if(hand[0]<hand[1]){
				sum[1]+=hand[0]+hand[1];
			}else{
				sum[0]+=hand[0];
				sum[1]+=hand[1];
			}
		}
		cout<<sum[0]<<' '<<sum[1]<<endl;
	}
	return 0;
}

C++: // cardgame.cpp
#include <iostream>
using namespace std;

int main(){
	int g,h;
	cin >> g;
	for(h=0;h<g;h++){
		int n=0;
		int i,j;
		int a[10000], b[10000];
		int a_point=0, b_point=0;
		cin >> n;
		for(i=0;i<n;++i){
				cin >> a[i];
				cin >> b[i];
		}
		for(j=0;j<n;++j){
			if(a[j]>b[j])
				a_point+=(a[j]+b[j]);
	        else if(a[j]<b[j])
				b_point+=(a[j]+b[j]);
			else if(a[j]==b[j]){
				a_point+=a[j];
				b_point+=b[j];
			}
		}
		cout << a_point << " " << b_point << endl;
	}
	return 0;	
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<climits>
using namespace std;
#define rep(i, j) for(int i = 0; i < j; i++)
#define P pair<int, int>
const int INF = INT_MAX / 2;

int main(){
    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>
using namespace std;

int main()
{
	int a;
	int r, l;
	int rsum, lsum;
	rsum = 0;
	lsum = 0;
	while (cin >> a){
		for (int i = a; i > 0; i--){

			cin >> r;
			cin >> l;
			if (r > l){
				rsum += r + l;
			}
			else if (l > r){
				lsum += r + l;
			}
			else{
				rsum += r;
				lsum += l;
			}
		}
		cout << r << ' ' << l << endl;
	}
}

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

C++: #include <cstdio>

int n,an,bn,i,j;
int a[10000],b[10000];
int main (){
	scanf("%d",&n);
	an=0;
	bn=0;
	for (i=0;i<n;i++){
		scanf("%d %d",&(a[i]),&(b[i]));
	}
	for(j=0;j<n;j++){
		if(a[j]>b[j]) an=an+(a[j]+b[j]);
		else if(a[j]<b[j]) bn=bn+(a[j]+b[j]);
		else if (a[j]==b[j]) { 
			an=an+a[j];
			bn=bn+b[j];
		}
	}
	printf("%d %d\n",an,bn);
	return 0;
}

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

int main(){
	int a,b,c,m=0;
    while(m==0){
		int ap=0,bp=0;
		std::cin>>c;
		if(c==0)break;
		for(int i=0;i<c;i++){
			std::cin>>a>>b;
			if(a>b)ap+=a,ap+=b;
			else if(b>a){
				bp+=a;bp+=b;
			}else{
				ap+=a,bp+=b;
			}
		}
		std::cout<<ap<<" "<<bp<<std::endl;
	}
	return 0;
}

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

int main(){
  int ans1=0,ans2=0,num1,num2,n;

  while(1){
    ans1=ans2=0;
    cin>>n;
    if(n==0)break;
    for(int i=0;i<n;i++){
      cin>>num1>>num2;
      if(num1>num2)ans1=ans1+num1+num2;
      else if(num1<num2)ans2=ans2+num1+num2;
      else {
	ans1=ans1+num1;
	ans2=ans2+num1;
      }
    }
    cout<<ans1<<" "<<ans2<<endl;
  }
 
 return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int a[10000],b[10000],n,i,c[2];
	for(;;){
		scanf("%d",&n);
		if(n==0)
			break;
		for(i=0;i<n+1;i++){
			scanf("%d%d",&a[i],&b[i]);
			if(a[i]>b[i])
				c[0]=a[i]+b[i];
			else
				c[1]=a[i]+b[i];
		}
		printf("%d %d\n"c[0],c[1]);
	}
	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",a1,b1);
		scanf("%d",&n);
	}
	return 0;
}

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

int main(){
  int i, n, s=0, t=0;
  int a[10000], b[10000];

  while(1){
    cin >> n;
    if (n==0) break;

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

  return 0;
}

C++: #include<stdio.h>


int main(){
	int n;
	int a=0;
	int	b=0;
	int apoint=0;
	int bpoint=0;
	int i;

	scanf("%d",&n);

	while(n!=0){
		for(i=0;i<n;i++){
			scanf("%d %d",&a,&b);
			if(a<b){
				bpoint = bpoint + a + b;
			}if(a>b){
				apoint = apoint + a + b;
			}if(a==b){
				apoint= apoint + a;
				bpoint= bpoint + b;
			}
		}		
		printf("%d %d",apoint,bpoint);
		apoint=0;
		bpoint=0;
		scanf("%d",&n);
	}
}