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,pointA,pointB;
  int a[10000],b[10000];
  pointA = 0; pointB = 0;
  for(n = 1;n != 0;cin >> n){  
 cin >> n;

  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()
{
  int n;
  while (cin >> n) {
    if (n == 0)
      break;

    int a_sum = 0;
    int b_sum = 0;
    for (int i = 0; i < n; ++i) {
      int a, b;
      cin >> a >> b;
      if (a == b) {
        a_sum += a;
        b_sum += b;
      } else if (a < b) {
        b_sum += a + b;
      }
      else if (b < a) {
        a_sum += a + b;
      }
    }

    cout << a_sum << " " << b_sum << endl;
  }
}

C++: #include<iostream>
using namespace std;
int main() {

    int i,j;
    int n,m;
    int round;
    int point_a, point_b;
    int a,b;
    
    while(1) {
        point_a = 0;
        point_b = 0;
        cin >> round;
        if(round == 0) break;
        for(i=0; i<round; i++) {
            cin >> a >> b;
            if( a > b ) {
                point_a += a + b;
            } else if(a < b) {
                point_b += a + b;
            } else {
                point_a += a;
                point_b += b;                
            }
        }
        cout << point_a << " " << point_b << endl;
    }
    

}

C++: #include <stdio.h>
 
int main(){
int n,a=0,b=0;
scanf("%d",&n);
while(n){
int 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;
}
}
scand("%d",&n);
}
}

C++: #include <iostream>

int main(){
    while(true){
    int n, a_score = 0, b_score = 0;
    std::cin >> n;
    
    if(n == 0)
        break;

    for(int i = 0; i < n; ++i){
        int a, b;
        std::cin >> a >> b;
        if(a > b)
            a_score += a + b;
        else if(a < b)
            b_score += a + b;
        else
            a_score += a, b_score += b;
    }

    std::cout << a_score << " " << b_score << std::endl;
    }
    return 0;
}

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

C++: #include <cstdio>
int main(void)
{
  while(1){
    int n;
    scanf("%d",&n);
    if(!n) break;
    int ap=0,bp=0;
    for(int i=0;i<n;i++){
      int a,b;
      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>
#include <cstdio>
using namespace std;

int main() {
	int n, a, b, na, nb;
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d %d", &na, &nb);
		if(na > nb){
			a = na + nb + a;
		} else if(na < nb){
			b = na + nb + b;
		} else {
			a = a + na;
			b = b + nb;
		}
	}
	cout << a << " " << b << endl;
	return 0;
}

C++: #include<iostream>
using namespace std;
static const int N = 10000;

int main() {
	int n;
	int i;
	int A[N];
	int B[N];
	int score_A = 0;
	int score_B = 0;

	cin >> n;
    
	for (i = 0; i < n; i++) {
		cin >> A[i];
		cin >> B[i];
	}

	for (i = 0; i < n; i++) {
		if (A[i] > B[i]) {
			score_A += A[i] + B[i];
		}
		else if (A[i] < B[i]) {
			score_B += A[i] + B[i];
		}
		else if (A[i] = B[i]) {
			score_A += A[i];
			score_B += B[i];
			}
	}

	cout << "A????????????" << score_A << " B????????????" << score_B << endl;

	return 0;
}

C++: #include<iostream>
using namespacee 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(void){
	int *cardsA,*cardsB;
	int cardNum,tempA,tempB,pointA=0,pointB=0,i=0;
while(true){
	std::cin >> cardNum;
	if(cardNum==0) return 0;
	cardsA=new int[cardNum];
	cardsB=new int[cardNum];
	for(;i<cardNum;++i){
		std::cin >> tempA >> tempB;
		cardsA[i]=tempA;
		cardsB[i]=tempB;
	}
	i=0;
	for(;i<cardNum;++i){
		if(cardsA[i]>cardsB[i]) pointA+=cardsA[i]+cardsB[i];
		if(cardsB[i]>cardsA[i]) pointB+=cardsA[i]+cardsB[i];
		if(cardsA[i]==cardsB[i]){
			pointA+=cardsA[i];
			pointB+=cardsA[i];
		}
	}
	std::cout << pointA << " " << pointB << std::endl;
	delete cardsA;
	delete cardsB;
}
	return 0;
}

C++: #include <stdio.h>

int main(){
	while(1){
	int n;
	scanf("%d", &n);
	if(n==0) break;	

	int i;
	int x,y;
	x = y = 0;
	for(i=0;i<n;i++){
		int a,b;
		scanf("%d%d", &a, &b);

		if(a>b) x+=a+b;
		else if(a==b) x+=a,y+=b;
		else y+= a+b;
	}
	printf("%d %d\n", x, y);
	}
}

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

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

C++: #include <iostream>

using namespace std;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		int aSum = 0, bSum = 0;
		for(int i = 0; i < n; ++i)
		{
			int a, b;
			cin >> a >> b;
			if(a > b)
			{
				aSum += a + b;
			}
			else if(a < b)
			{
				bSum += a + b;
			}
			else
			{
				aSum += a;
				bSum += a;
			}
		}
		cout << aSum << " " << bSum << endl;
	}
}

int main()
{
	solve();
	return(0);
}

C++: #include<iostream>

using namespace std;
main(){
  int n,s1,s2;
  int a,b;
  cin>>n;
  while(n!=0){
    s1=s2=0;
    for(int i=0;i<n;i++){
      cin>>a>>b;
      if(a>b)
	s1+=(a+b);
      else if(a<b)
	s2+=(a+b);
      else{
	s1+=a;
	s2+=a;
      }

    }
    cin>>n;
  }
  cout<<s1<<" "<<s2<<endl;
  return 0;
}

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

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

C++: #include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n,a,b,countA,countB;
    do{
        countA=0,countB=0;
        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+=(a+b);
            }//a==b
        }
        cout<<countA<<" "<<countB<<"\n";
    }while(1);
    cout<<countA<<" "<<countB<<endl;
}