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

C++: #include <stdio.h>

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

C++: #include<iostream>

int main(){
	int i=0,n,a=0,b=0;
	std::cin>>n;
	while(i<n){
		int ca,cb;
		std::cin>>ca>>cb;
		if(ca>cb)a+=ca+cb;
		else if(cb>ca)b+=ca+cb;
		else if(ca==cb)a+=ca,b+=cb;
		i++;
	}
	std::cout<<a<<" "<<b<<std::endl;
	return 0;
}

C++: #include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int a[200000];
int b[200000];
int main(){
    while(1){
    int n;
    scanf("%d",&n);
    if(n == 0)
        break;
    REP(i,n)
        scanf("%d%d",a + i,b + i);

    int ap = 0,bp = 0;

    REP(i,n){
        if(a[i] > b[i])
            ap += a[i] + b[i];
        else if(a[i] < b[i]) 
            bp += a[i] + b[i];
        else{
            ap += a[i];
            bp += b[i];
        }
    }
    printf("%d %d\n",ap,bp);
    }
    return 0;
}

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

int main(){
	int n,a,b;
	long suma=0,sumb=0;
	do{
		cin >> n;
		for(int i=0;i<n;i++){
			cin >> a >> b;
			if(a>b) suma+=a+b;
			else if(a<b) sumb+=a+b;
			else{suma+=a;sumb+=b;}
		printf("%ld %ld\n",suma,sumb);
	while(n!=0);
}

C++: #include <iostream>

using namespace std;
int main()
{
    int loop;
    cin >> loop;
    int p1=0,p2=0;
    while(loop--)
    {
        int a,b;
        cin >> a >> b ;
        if(a > b) {
            p1 = p1 + a + b;
        }else if(a==b) {
            p1 += a;
            p2 += b;
        }
        else {
            p2 = p2 + a + b;
        }
    }
    cout << p1 << " " << p2 << endl;
    return 0;
}

C++: #include <cstdio>
int main(){
 int asum,bsum,a,b,n,i;
 asum=bsum=0;
 scanf("%d",&n);
 for(i=0;i<n;i++){
  scanf("%d %d",&a,&b);
  if (a>b) asum += a+b;
  if (a<b) bsum += a+b;
  if (a==b) asum += a; bsum += b;
 };
 printf("%d %d\n",asum,bsum);
 return 0;
};

C++: #include <cstdio>
int main() {
	int n,a,b,ap,bp;
	while(scanf("%d",&n),n) {
		ap=bp=0;
		for(int i=0;i<n;i++) {
			scanf("%d %d",&a,&b);
			if(a>b)ap+=a+b;
			else if(a<b)bp+=a+b;
			else ap+=a,bp+=b;
		}
		printf("%d %d\n",ap,bp);
	}
}

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

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

int n;

void solve() {
  int a = 0, b = 0;
  rep(i,n) {
    int ta, tb; cin>>ta>>tb;
    if (ta > tb) a += ta + tb;
    else if (ta < tb) b += ta + tb;
    else a += ta, b += tb;
  }
  cout<<a<<" "<<b<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>n, n) {
    solve();
  }
  return 0;
}

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

int main() {
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        int scores[2] = {};
        for (int i = 0; i < n; i++) {
            int a, b;
            cin >> a >> b;
            if (a > b) {
                scores[0] += a + b;
            } else if (a < b) {
                scores[1] += a + b;
            } else {
                scores[0] += a;
                scores[1] += b;
            }
        }
        cout << scores[0] << " " << scores[1] << endl;
    }
}