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, a,b, A,B;

  while( cin >> n && n ){
    A=B=0;
    while( n-- ){
      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;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)

int main(void){
	while(true){
		int n;
		int a = 0, b = 0;
		cin >> n;
		if(n == 0) break;
		rep(i, n){
			int x, y;
			cin >> x >> y;
			if(x > y){
				a += x + y;
			}
			if(y > x){
				b += x + y;
			}
			if(y == x){
				a += x;
				b += y;
			}
		}
		cout << a << " " << b << endl;
	}
	return 0;
}

C++: #include<stdio.h>
void judge(int n, int a[], int b[], int *result1, int *result2) {
	while (--n >= 0) {
		if (a[n] > b[n]) {
			*result1 += a[n] + b[n];
		}
		else if (a[n] < b[n]) {
			*result2 += a[n] + b[n];
		}
		else if (a[n] == b[n]) {
			*result1 += a[n];
			* result2 += b[n];
		}
	}
}
int main() {
	int a[1000];
	int b[1000];
	int n, t = 0;
int i;
	int result1 = 0, result2 = 0;
	int result[1000][2];
	do {
		scanf("%d", &n);
		for (i = 0; i < n; i++) {
			scanf("%d %d", &a[i], &b[i]);
		}
		judge(n, a, b, &result1, &result2);
		result[t][0] = result1;
		result[t][1] = result2;
		result1 = 0;
		result2 = 0;
		t++;
	} while (n != 0);

	for (i = 0; i < t-1;i++) {
		printf("%d %d\n", result[i][0], result[i][1]);
	}

	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int n,pointA,pointB;
  int a[10000],b[10000];
  pointA = 0; pointB = 0;
  for(n = 1;n != 0;){  
 cin >> n;
 if(n != 0){
    pointA = 0; pointB = 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]){
      pointB = pointB + a[i] +b[i];
    } else if(a[i] > b[i]){
      pointA = pointA + a[i] +b[i];
    } else if(a[i] == b[i]){
      pointA = pointA + a[i];
      pointB = pointB + b[i];
    }
  }
 
  cout << pointA << " "<< pointB << endl;
 }
  }
  
  
}

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

int main(void){
  int a,b;
  a=b=0;
  int n;
  cin>>n;
  while(n--){
    int c,d;
    cin>>c>>d;
    if(c>d)
      a += c + d;
    else
      b += c + d; 
  }
  cout<< a << " " << b << endl;
}

C++: #include<iostream>

int main(){
int n,a,b,pa,pb;
pa=0;pb=0
cin>>n;
for(;;){
for(int i=0;i<n;i++){
cin>>a;
cin>>b;
if(a==b){pa+=a; pb+=a}
if(a>b){pa+=a+b;}
if(a<b){pb+=a+b;}
}
if(n==0){break;}
cout<<pa<<" "<<pb<<endl;
}

return 0;
}

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

struct player{
    int point = 0;
    int card[10000];
};

int main()
{
    int loop;
    player a, b;
    cin >> loop;
    for(int c = 0; c < loop; c++)
    {
        cin >> a.card[c];
        cin >> b.card[c];
    }

    for(int c = 0; c < loop; c++)
    {
        if(a.card[c] < b.card[c]) b.point += a.card[c] + b.card[c];
        if(a.card[c] == b.card[c]) a.point += a.card[c], b.point +=b.card[c];
        if(a.card[c] > b.card[c]) a.point += a.card[c] + b.card[c];
    }
    cout << a.point << " " << b.point << endl;
    return EXIT_SUCCESS;
}

C++: #include<iostream>
using namespace std;
int main(){
  int n,a,b,x=0,y=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a>>b;
    if(a==b){
      x+=a;
      y+=b;
    }
    if(a>b)x+=(a+b);
    if(b>a)y+=(a+b);
  }
  cout<<x<<" "<<y<<endl;
}

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

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

int main(void){
  int n,a,b;

  while(1){
    cin >> n;
    if(n==0)break;
    int Pa=0,Pb=0;
    for(int i=0;i<n;i++){
      cin >> a >> b;
      if(a>b)Pa+=a+b;
      else if(a<b)Pb+=a+b;
      else {Pa+=a; Pb+=b;}
    }
    cout << Pa <<" "<< Pb << endl;
  }
  return 0;
}

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

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

using namespace std;

class Player
{	friend class Batler;
	vector<int> card;
	long long int point;
public:
	Player():point(0){}
};
class Batler
{
	Player *p1, *p2;
public:
	Batler(Player *P1, Player *P2):p1(P1),p2(P2){}

	void init();
	void input();
	void start();
};
void Batler::init()
{
	if(!p1->card.empty()){
		p1->card.clear();
		p2->card.clear();
	}
	p1->point = 0;
	p2->point = 0;
}
void Batler::input()
{
	int buf;
	cin>>buf;
	p1->card.push_back(buf);
	cin>>buf;
	p2->card.push_back(buf);
}
void Batler::start()
{
	for(unsigned int i = 0; i < p1->card.size(); i++){
		if( p1->card[i] > p2->card[i]){
			p1->point += p1->card[i] + p2->card[i];
		}else if( p1->card[i] < p2->card[i] ){
			p2->point += p1->card[i] + p2->card[i];
		}else{
			p1->point += p1->point;
			p2->point += p2->point;
		}
	}
	cout<<p1->point<<" "<<p2->point<<endl;
}
int main()
{
	int n;
	Player p1, p2;
	Batler batle(&p1,&p2);

	while(1){
		batle.init();
		cin>>n;
		if(n == 0) return 0;

		//üÍ
		for(int i = 0; i < n; i++){
			batle.input();
		}
		//ð
		batle.start();
	}
}

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

using namespace std;

int main()
{
	int ap, bp, turnnum, acard, bcard;
	ap = bp = 0;
	queue<int>adeck, bdeck;
	while (1)
	{
		scanf("%d", &turnnum);
		if (turnnum == 0)break;

		for (int i = 0; i < turnnum; i++)
		{
			scanf("%d %d", &acard, &bcard);
			adeck.push(acard);
			bdeck.push(bcard);
		}
		while (adeck.empty() == false)
		{
			if (adeck.front()>bdeck.front())
			{
				ap += adeck.front() + bdeck.front();
				adeck.pop();
				bdeck.pop();
			}
			else if(adeck.front() < bdeck.front())
			{
				bp += adeck.front() + bdeck.front();
				adeck.pop();
				bdeck.pop();
			}
			else
			{
				ap += adeck.front();
				bp += bdeck.front();
				adeck.pop();
				bdeck.pop();
			}
		}
		printf("%d %d\n", ap, bp);

	}

}

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

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;
#define pi 3.141592653589793283462
int main(){
	int n;
	int ca=0;
	int cb=0;
	int ia,ib;
	while(1){
		cin>>n;
		if(n==0)
			break;
		for(int i=0;i<n;i++){
		cin>>ia>>ib;
		if(ia>ib)
			ca+=(ia+ib);
		else if(ia<ib)
			cb+=(ia+ib);
		else{
			ca+=ia;
			cb+=ib;
		}
	}
		cout<<ca<<" "<<cb<<endl;
		ca=0;
		cb=0;
   }
	return 0;
}