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() {
    int n, i, num[2], result[2] = { 0,0 };

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

        result[0] = 0;
        result[1] = 0;
        for (i = 0; i < n; i++) {
            scanf("%d %d", &num[0], &num[1]);
            if (num[0] > num[1]) result[0] += num[0] + num[1];
            else if (num[0] < num[1]) result[1] += num[0] + num[1];
            else result[0] += num[0], result[1] += num[1];
        }
        printf("%d %d\n", result[0], result[1]);
    }

    return 0;
}

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

int main() {
	int n;
	int a = 0, b = 0;

	while (cin >> n, n) {
		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 << endl;
		a = 0;
		b = 0;
	}
	return 0;
}

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

}

C++: #include<iostream>

using namespace std;

int main() {

	int n;
	while (cin >> n) {
		if (n == 0) {
			break;
		}

		int point_a = 0;
		int point_b = 0;

		for (int i = 0; i < n; ++i) {
			int a, b;
			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;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  while(1){
    cin>>n;
    if(n==0){
      break;
    }
    int a,b;
    int aa=0,bb=0;
    for(int i=0;i<n;i++){
      cin>>a>>b;
      if(a>b){
	aa+=a+b;
      }else if(b>a){
	bb+=a+b;
      }else{
	aa+=a;
	bb+=b;
      }
    }
    cout<<aa<<' '<<bb<<endl;
  }
  return(0);
}

C++: #include<stdio.h>
int A=0,B=0;
int a,b;

void Total(){
	if(a>b)	A+=a+b;
	else if(a<b) B+=a+b;
	else {A+=b;B+=a;}
}

int main(){
	int n,i;
	for(;;){
		scanf("%d",&n);
		if(n!=0){
			for(i=0;i<n;i++){
				scanf("%d%d", &a, &b);
				Total();
			}
			printf("%d %d\n",A,B);
			A=B=0;
		}else break;
	}
	return 0;
}

C++: #include<stdio.h>

int main(){
	int n;
	int A=0;
	int B=0;
	int i=0;
	scanf("%d", &n);
	int x[10000];
	int y[10000];
	while(i<n){
	scanf("%d", &x[i]);
	scanf("%d", &y[i]);
	++i;
}
	i=0;
	while(i<n){
	if(0>x[i] || 9<x[i]){
	return 0;
	}
	if(0>y[i] || 9<y[i]){
	return 0;
	}
	++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);
		return 0;
}

C++: #include<stdio.h>

int main(void){
	int a_point,b_point,i,a_card,b_card,n;
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		a_point=0,b_point=0;
		for(i=0;i<n;n++){
			scanf("%d %d",&a_card,&b_card);
			if(a_card>b_card) a_point+=a_card+b_card;
			else if(a_card<b_card) b_point+=a_card+b_card;
			else {
				a_point+=a_card;
				b_point+=b_card;
			}
			printf("%d %d\n",a_point,b_point);
		}
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int n,pointA,pointB;
  int a[10000],b[10000];
  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 <stdio.h>
int n,i,j,k;
int A[1],B[1];
int main(){
  for(;;){
    A[0]=0,B[0]=0;
    scanf("%d",&n);
    if(n==0){
      return 0;
    }
      for(i=0;i<n;i++){
      scanf(" %d %d",&j,&k);
      if(j>k){
        A[0]+=(j+k);
      } else if(j<k){
        B[0]+=(j+k);
      } else if(j==k){
        A[0]+=j;
        B[0]+=k;
      }
      printf("%d %d\n",A[0],B[0]);
    }
  }
}

C++: #include <stdio.h>
int main(void)
{
	int a[100], i, j, m, n, b[100], A = 0, B = 0;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d %d", &a[i], &b[i]);
	}
	for (i = 0; i < n; i++) {
		if (a[i] > b[i]) {
			A = A+a[i] + b[i];
		}
		else if (a[i] == b[i]) {
			A =A+ a[i];
			B =B+ b[i];
		}
		else {
			B = B+a[i] + b[i];
		}
	}
	printf("%d %d\n", A, B);
}

C++: #include<iostream>

int main(){

	int n;

	int a=0, b=0;

	int x, y;

	f:

	std::cin >> n;

	if (n == 0)
		goto flag;

	for (int i = 0; i < n; i++) {
		std::cin >> x >> y;
		if (x > y)
			a += (x + y);
		if (x < y)
			b += (x + y);
		if (x == y){
			a += x;
		b += y;
	}
	}

	std::cout << a << ' ' << b << std::endl;

	goto f;

flag:

	return 0;

}

C++: #include<iostream>
using namespace std;
#include<stdio.h>
int main()
{
        int v=0,s=0,a[10000+1],b[10000+1],i,n;
        while(1)
        {
                v=0;
                s=0;
                cin>>n;//??\???
                if(n==0)//0?????´???
                {
                        break;
                }
                for(i=0;i<n;i++)//??\???
                {
                        cin>>a[i]>>b[i];
                }
                for(i=0;i<n;i++)
                {
                        if(a[i]>b[i])
                                v=a[i]+b[i]+v;
                        else if(a[i]<b[i])
                                s=a[i]+b[i]+s;
                        else
                        {
                                v=a[i]+v;
                                s=b[i]+s;
                        }
                }
                cout<<v<<" "<<s<<endl;
        }
        return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  while (cin >> n && n) {
    int a = 0, b = 0;
    for (int i = 0; i < n; ++i) {
      int c, d;
      cin >> c >> d;

      if (c > d) a += c + d;
      else if (c < d) b += c + d;
      else a += c, b += d;
    }
 
    cout << a << " " << b << '\n';
  }

  return (0);
}

C++: #include<iostream>
using namespace std;
int i, n, pA, pB, tA = 0, tB = 0;
int main () {
    while(cin >> n) {
       if(n == 0) { break; }
       for (i=1; i<=n; i++) {
           cin >> pA >> pB;
           if (pA > pB) {
               tA += pA + pB;
           } else {
               if (pA < pB) {
                   tB += pA + pB;
               } else {
                   tA += pA;
                   tB +- pB;
               }
           }
       }
       cout << tA << " " << tB << endl;
       tA = 0; tB = 0;
     }
     return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<string.h>
using namespace std;
int main(){
	int n;
	int sa, sb;
	int a, b;
	while (1){
		cin >> n;
		if (n == 0){
			break;
		}
		for (int i = 0; i < n; i++){
			cin >> a >> b;
			if (a>b){
				sa = sa + a + b;
			}
			else if (a < b){
				sb = sb + a + b;
			}
			else{
				sa = sa + a;
				sb = sb + b;
			}
		}
		cout << sa << " "<< sb<<endl;

	}
}