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

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

int main()
{
  int n;
  int j, k;
  int suma, sumb;
  
  
  while (cin >> n){
    if (n == 0){
      break;
    }
    suma = sumb = 0;
    for (int i = 0; i < n; i++){
      cin >> j >> k;

      if (j < k){
        sumb += j + k;
     }
      else if (j > k){
        suma += j + k;
      }
     else {
        suma += j;
       sumb += k;
      }
    }
   cout << suma << " " << sumb << endl;
  }
  return 0;
}

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

int main()
{
	int n;
	while(cin>>n,n){
	int A=0,B=0;
	for(int i=0;i<n;i++){
		int x,y;
		cin>>x>>y;
		if(x>y)A+=x+y;
		else if(x<y)B+=x+y;
		else A+=x,B+=y;
		}
		cout<<A<<" "<<B<<"\n";
	}
	return 0;
}

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

C++: #include<cstdio>
#include<algorithm>
#include<cmath>

using namespace std;

int main(){
        while(true){
                int pa = 0, pb = 0       
                int a, b
                scanf("%d", &n);
                if(!n) break;
                for(i = 0; i < n; i++){
                        scanf("%d%d", &a, &b);
                        if(a > b)
                                pa += a + b;
                        else if(b > a)
                                pb += a + b;
                        else if(a == b){
                                pa += a;
                                pb += b;
                        }
                }
                printf("%d %d\n", pa, pb);
        }
        return 0;
}

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

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

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

return 0;
}

C++: #include <iostream>
using namespace std;
 
int main()
{
  int i, 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++: 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;
	e+=c;
	}
	else if(b>c){
	d+=b+c;
	}
	else if(b<c){
	e+=b+c;
	}
	}
	printf("%d %d\n",d,e);
	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(){
    int n;
    scanf("%d",&n);
    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 <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iostream>

using namespace std;

class Player
{	friend class Batler;
	vector<int> card;
	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) break;

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

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

int main()
{
  int n;
  int j, k;
  int suma, sumb;
  
  suma = sumb = 0;
  cin >> n;
  for (int i = 0; i < n; i++){
    cin >> j >> k;

    if (j < k){
      sumb += j + k;
    }
    else if (j > k){
      suma += j + k;
    }
    else {
      suma += j;
      sumb += k;
    }
  }
  cout << suma << " " << sumb << endl;

  return 0;
}

C++: #include <iostream>

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

int main() {
    int n;
    while (std::cin >> n && n) {
        int sc1 = 0, sc2 = 0;
        rep(i, n) {
            int p1, p2;
            std::cin >> p1 >> p2;
            if (p1 == p2)
                sc1 += p1, sc2 += p2;
            else if (p1 > p2)
                sc1 += p1 + p2;
            else
                sc2 += p1 + p2;
        }
        std::cout << sc1 << ' ' << sc2 << std::endl;
    }
}