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 n, a, b, sa, sb;
  
int main(){
  for(;;){
    cin >> n;
    if(n == 0){
      break;
    }else{
      for(int i = 0; i < n; i++){
        cin >> a >> b;
        if(a < b){
          sb += a + b;
        }else if(a > b){
          sa += b + a;
        }else{
          sa += a;
          sb += b;
        }
      }
      cout << sa << " " << sb << endl;
    }
  }
  return 0;
}

C++: #include <stdio.h>

int main(void)
{
	int ans_a, ans_b;
	int n;
	int a, b;
	
	while (1){
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		
		ans_a = ans_b = 0;
		while (n){
			scanf("%d %d", &a, &b);
			
			if (a > b){
				ans_a += (a + b);
			}
			else if (a < b){
				ans_b += (a + b);
			}
			else {
				ans_a += a;
				ans_b += b;
			}
			
			n--;
		}
	}
	
	printf("%d %d\n", ans_a, ans_b);
	
	return (0);
}

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

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

C++: #include<iostream>

int n;
int a, b;
int res[2];

int main()
{
	while( 1 ){
		std::cin >> n;
		
		if( !n ) break;
		
		res[0] = res[1] = 0;
		
		while( n-- ){
			std::cin >> a >> b;
		 	if( a == b ){
			 	res[0] += a;
				res[1] += b;
			}
			else if( a > b ){
			 	res[0] += a + b;
			}
			else{
			 	res[1] += a + b;
			}
		}
		
		std::cout << res[0] << " " << res[1] << std::endl;
	}

 	return 0;
}

C++: #include <iostream>
using namespace std;
      
int main()
{
  while(1){ 
  int i, n, x, y;
  cin >>n;
    
  if(n==0){break;}
  else
  {
  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++: #include<iostream>
#include<string>
#include<cmath>
using namespace std;

int main(){
  int n,a=0,b=0;
  cin>>n;
  int A[n],B[n];
  for(int i=0;i<n;i++){
    cin>>A[i]>>B[i];
    if(A[i]>B[i]){
      a+=A[i]+B[i];
    }else if(A[i]<B[i]){
      b+=A[i]+B[i];
    }else{
      a+=A[i];
      b+=B[i];
    }
  }
  cout<<a<<" "<<b<<endl;
  return 0;
}

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

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

using namespace std;
struct card{
	int a;
	int b;
};
int main(){
	deque<card> d;
	card e;
	int n;
	while(cin >> n,n){
		int ta=0,tb=0,flag=0;
		while(n--){
			cin >> e.a >> e.b;
			d.push_back(e);
			if(e.a==e.b)flag=1;
		}
		if(flag){
			while(!d.empty()){
				e=d.front();
				d.pop_front();
				ta+=e.a;tb+=e.b;
			}
		}else{
			while(!d.empty()){
				e=d.front();
				d.pop_front();
				if(e.a>e.b) ta+=(e.a+e.b);
				else tb+=(e.a+e.b);
			}
		}
		cout << ta <<" "<< tb << endl;
	}
	return 0;
}

C++: #include<iostream>
intscore_a,score_b;
intmain(void)
{
usingnamespacestd;
intn,data_a,data_b;
while(1)
{
cin>>n;
if(!n)break;
score_a=0;
score_b=0;
for(;n>0;n--){
cin>>data_a;
cin>>data_b;
if(data_a>data_b){
score_a+=(data_a+data_b);
}elseif(data_a<data_b){
score_b+=(data_a+data_b);
}else{
score_a+=data_a;
score_b+=data_b;
}
}
cout<<score_a<<""<<score_b<<endl;
}
return0;
}

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

int A = 0, B = 0, j;

int main(){
    for(;;){
        if(cin >> j){
            A = 0;
            B = 0;
            if(j == 0){
                break;
            }
            for(int i = 0; i < j; i++){
                int as, bs;
                cin >> as >> bs;
                if(as > bs){
                    A += as + bs;
                }else if(as < bs){
                    B += as + bs;
                }else{
                    A += as;
                    B += bs;
                }
            }
            cout << A << " " << B << endl;
        }else{
            break;
        }
    }
    return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <cmath>

using namespace std;

int main(int args, char *argc[]){
  int n;
  while(cin>>n){
    if(n==0)
      return 0;
    int a=0,b=0;
    for(int i=0;i<n;i++){
      int ia,ib;
      cin>>ia>>ib;
      if(ia==ib){
        a+=ia;
        b+=ib;
      }
      else if(ia<ib)
        b+=(ia+ib);
      else
        a+=(ia+ib);
    }
    printf("%d %d\n",a,b);
  }
  return 0;
}

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

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

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

int main()
{
  int n;
  int j, k;
  int suma, sumb;
  
  suma = sumb = 0;
  while (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<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
main(){
  int n,a,b,A,B;
  while(1){
    cin >> n;
    if(!n)break;
    A = B = 0;
    for(int i=0;i<n;i++){
      cin >> a >> b;
      if(a>b){
	A += (a + b);
      }else if(a==b){
	A += a;
	B += b;
      }else {
	B += (a+b);
      }
    }
    cout << A << " " << B << endl;
  }
}

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    <iomanip>
using namespace std;
int a,b;
int main(){
    int num;
    while(cin>>num&&num!=0){
        int pa=0,pb=0;
        for (int i=0; i<num; i++) {
            cin>>a>>b;
            if (a==b) {
                pa+=a;pb+=a;
            }else if(a>b){
                pa+=(a+b);
            }else{
                pb+=(a+b);
            }
        }
        cout<<pa<<" "<<pb<<endl;
    }
    return 0;
}