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>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <set>
#include <cmath>
#include <map>


int main(int,char**){
	int n;
	int a,b;
	while(std::cin >> n){
		if(!n) break;
		int aScore(0),bScore(0);
		while(n--){
			std::cin >> a>>b;
			if(a==b) 
				aScore+=a,bScore+=b;
			else if(a>b)
				aScore+=(a+b);
			else 
				bScore+=(a+b);
		}
		std::cout << aScore << ' ' << bScore << std::endl;
	}
	return 0;
}

C++: #include<stdio.h>

int main{
	int n;
	int A=0;
	int B=0;
	int i=0;
	scanf("%d", &n);
	int x[n];
	int y[n];
	while(i<n){
	scanf("%d", &x[i]);
	scanf("%d", &y[i]);
	++i;
}
	i=0;
	while(i<n){
	if(x[i]>y[i]){
	A=A+x[i]+y[i];
}else {
	if(x[i]<y[i]){
	B=B+x[i]+y[i];
}else{
	A=A+x[i];
	B=B+y[i];
			}
		}
	++i
	}
	printf("%d %d\n", A, B);
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <stdlib.h>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		if(n==0) break;
		int a[n],b[n],at=0,bt=0;
		for(int i=0;i<n;i++){
			cin>>a[i]>>b[i];
			if(a[i]>b[i]){
				at=at+a[i]+b[i];
			}
			else if(a[i]==b[i]){
				at=at+a[i];
				bt=bt+b[i];
			}
			else{
				bt=bt+a[i]+b[i];
			}
		}
		cout<<at<<" "<<bt<<endl;
	}
    return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	while(n!=0)
		int point[2];
		enum {
			A,
			B,
		};
		int sum[2] = {};
		for (int i = 0; i < n; i++) {
			cin>>point[A]>>point[B];
			if (point[A]>point[B]) {
				for (auto j : point) {
					sum[A]+=j;
				}
			} else if(point[A] == point[B]) {
				for (auto j : sum) {
					j+=point[A];
				}
			} else {
				for (auto j : point) {
					sum[B]+=j;
				}
			}
		}
		cout<<sum[A]<<" "<<sum[B]<<endl;
		cin>>n;
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cstring>
#define rep(i,j) FOR(i,0,j)
#define FOR(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int main(){
	int n;
	while(cin>>n,n){
		int a=0,b=0,c,d;
		rep(i,n){
			cin>>c>>d;
			if(c>d)a+=c+d;
			else if(c<d)b+=c+d;
			else{
				a+=c;
				b+=d;
			}
		}
		cout<<a<<" "<<b<<endl;
	}
}

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

using namespace std;

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

  
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	while (true){
		int n, A[10000] = {}, B[10000] = {}, tenA = 0, tenB = 0;
		cin >> n;
		if (n == 0) break;
		for (int i = 0; i < n; i++){
			cin >> A[i] >> B[i];
			if (A[i] > B[i]){
				tenA += A[i] + B[i];
			}
			if (A[i] == B[i]){
				tenA += A[i];
				tenB += B[i];
			}
			if (A[i] < B[i]){
				tenB += A[i] + B[i];
			}
		}
		cout << tenA << ' ' << tenB << endl;
	}
	return 0;
}

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

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

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

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

using namespace std;

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


    }
    return 0;

}

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

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

int main(){
	int a=0,b=0;
	int na,nb;
	int nc;
	while(1){
	cin>>nc;
	if(nc==0) break;
	a=b=0;
	for(int i=0;i<nc;i++){
		cin>>na>>nb;
		if(na>nb) a+=(na+nb);
		else if(na<nb) b+=(na+nb);
		else {a+=na;b+=nb;}
	}
	cout<<a<<" "<<b<<endl;
	}
	return 0;
}

C++: #include <iostream>

int main(void){
  int n;
  int Acard[10000], Bcard[10000];

  while(1){
    int playerA = 0, playerB = 0;
    std::cin >> n;
    if(n == 0)  return 0;

    for(int i=0; i < n ; i++){
      std::cin >> Acard[i]; std::cin >> Bcard[i];
    }

    for(int i=0; i < n; i++){
      if(Acard[i] == Bcard[i]){
        playerA += Acard[i];  playerB += Bcard[i];
      }else if(Acard[i] > Bcard[i]){
        playerA += Acard[i] + Bcard[i];
      }else{
        playerB += Acard[i] + Bcard[i];
      }
    }

    std::cout << playerA << " " << playerB << std::endl;
  }
}

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

int main() {
	int n,a,b,x=0,y=0;
	for(int q=0;q==q;q++){
	n=0,x=0,y=0;
	cin>>n;
	if(n==0)break;
	for(int t=0;t<n;t++){
		cin>>a;
		cin>>b;
		if(a>b){
			x+=a+b;
		}
		else if(a==b){
			x+=a;
			y+=b;
	}
		else {
			y+=a+b;
	}
		
	}
	cout<<x<<' '<<y<<'\n';
	}
	return 0;
}

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

int main(){
	int n, x, y, sumx=0, sumy=0;
	cin >> n;

	for(int i=0; i<n; i++){
		x=0,y=0;
		cin >> x >> y;
		if(x > y){
			sumx = sumx + x + y;
		}
		else if(x < y){
			sumy = sumy + x + y;
		}
		else if(x == y){
			sumx = sumx + x;
			sumy = sumy + y;
		}
	}
	
	cout << sumx << " " << sumy  << "\n" << endl;
	return 0;
}

C++: #include <stdio.h>

int main(void)
{
	int a, b;
	int ap, bp;
	int i;
	int n;
	
	while (scanf("%d", &n), n != 0){
		ap = 0; bp = 0;
		for (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);
	}
	return (0);
}

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

struct player{
    int point ;
    int card[10000];
private:
  void player(){point =0;}
};

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