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 t;
  while(cin>>t && t > 0){
    int p1 = 0, p2 = 0;
    while(t > 0){
      int a = 0, b = 0;
      cin >> a >> b;
      if(a < 0 || a > 9 || a < 0 || a > 9){
        continue;
      }
      if(a > b){
        p1 += a + b;
      }
      else if(a < b){
        p2 += a + b;
      }
      else{
        p1 += a;
        p2 += b;
      }
      t--;
    }
    cout << p1 << " " << p2 << endl;
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{ int n,x=0,y=0,a,b;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a>>b;
if(a>b){
x=x+a+b;}
else if(a==b){
x=x+a;
y=y+b;}
else{
y=y+a+b;}
}
cout<<x<<" "<<y<<"\n";
 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\n",apoint,bpoint);
		apoint=0;
		bpoint=0;
		scanf("%d",&n);
	}
}

C++: #include<iostream>
using namespace std;
int i, n, pA, pB, tA = 0, tB = 0;
int main(){
while(cin >> n) {
if(n == 0) { break; }
for (i=1; i<=n; i++) {
cin >> pA >> pB;
if (pA > pB) {
tA += pA + pB;
} else {
if (pA < pB) {
tB += pA + pB;
} else {
tA += pA;
tB += pB;
}
}
}
cout << tA << "" << tB << endl;
tA = 0; tB = 0;
}
return 0;
}

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

C++: #include <iostream>

using namespace std;

int main ( void )
{
	int n;

	while ( cin >> n, n )
	{
		int A, B;
		A = B = 0;

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

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

int main(){
	int count;
	int aSum, bSum;
	int aCard, bCard;

	while(cin >> count, count){
		aSum = bSum = 0;

		for(int i=0; i < count; i++){
			cin >> aCard >> bCard;
			if(aCard > bCard) aSum += aCard + bCard;
			else if(aCard < bCard) bSum += aCard + bCard;
			else aSum += aCard, bSum += bCard;
		}
		cout << aSum << " " << bSum << endl;
	}
}

C++: #include<iostream>
using namespace std;
int main() {
	int n = 1, Acard,Bcard,Ascore=0,Bscore=0;
	while (n) {
		cin >> n;
		if (n == 0) { break; }
		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;
		Ascore = 0; Bscore = 0;
	}
	return 0;
}

C++: #include<stdio.h>

int main(void){
	int a_point,b_point,i,a_card,b_card,n;
	while(0==0){
		scanf("%d",&n);
		if(n==0) break;
		a_point=0;
		b_point=0;
		for(i=0;i<n;i++){
			scanf("%d %d",&a_card,&b_card);
			if(a_card>b_card) a_point+=(a_card+b_card);
			else if(a_card<b_card) b_point+=(a_card+b_card);
			else {
				a_point+=a_card;
				b_point+=b_card;
			}
		}
		printf("%d %d\n",a_point,b_point);
	}
	return 0;
}

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

int main(){
    
    while(1)
    {
        int num;
        cin>>num;
        
        if(num == 0)
        {
            break;
        }
        
        vector< int > cardA(num);
        vector< int > cardB(num);
        
        for(int i=0;i<num;++i)
        {
            int pA, pB;
            cin>>pA>>pB;
            cardA[i] = pA;
            cardB[i] = pB;
        }
        
        int pointA = 0;
        int pointB = 0;
        
        for(int i=0;i<num;++i)
        {
            if(cardA[i] ==cardB[i])
            {
                pointA += cardA[i];
                pointB += cardA[i];
            }
            else if(cardA[i] > cardB[i])
            {
                pointA += cardA[i] + cardB[i];
            }
            else
            {
                pointB += cardA[i] + cardB[i];
            }
        }
        
        cout<<pointA<<" "<<pointB<<endl;
    }
    
    return 0;
}

C++: #include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
#include <list>
using namespace std;
typedef long long int lli;
typedef pair<int,int> P;
#define F first
#define S second
const int INF=1000000000;

int main(){
	int n;
	while(cin>>n&&n){
		int a,b;
		a=b=0;
		for(int i=0; i<n; ++i){
			int t1,t2;
			cin >> t1 >> t2;
			if(t1>t2) a+=t1+t2;
			else if(t1<t2) b+=t1+t2;
			else{
				a+=t1;
				b+=t2;
			}
		}
		cout << a << " " << b << endl;
	}
	return 0;
}

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

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

int main(int argc, char const* argv[])
{
  while (true) {
    int n;
    std::cin >> n;
    if (n == 0) {
      break;
    }
    int pt_a = 0, pt_b = 0;
    for (int i = 0; i < n; ++i) {
      int a, b;
      std::cin >> a >> b;
      if (a == b) {
        pt_a += a;
        pt_b += b;
      } else if (a < b) {
        pt_b += a + b;
      } else {
        pt_a += a + b;
      }
    }
    std::cout << pt_a << " " << pt_b << std::endl;
  }
  return 0;
}

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

int main(){
	int a,b,c,m=0;
    while(m==0){
		std::cin>>c;
		if(c==0)break;
		for(int i=0;i<c;i++){
			int ap=0,bp=0;
			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 <bits/stdc++.h>
using namespace std;
 
int main() {
    int n,a,b,countA=0,countB=0;
    cin>>n;
    if(n!=0){
    do{
        for(int i=0;i<n;i++){
            cin>>a>>b;
            if(a>b){
                countA+=(a+b);
            }else if(a<b){
                countB+=(a+b);
            }//a==b
        }
        cout<<countA<<" "<<countB;
        cout<<"\n";
        countA=0,countB=0;
        cin>>n;
        if(n==0)break;
    }while(1);
    }
    cout<<endl;
}