Go: package main

import "fmt"

func main() {
	for {
		var a, b, n int
		fmt.Scanf("%d", &n)

		if n == 0 {
			return
		}

		for i := 0; i < n; i++ {
			var cardA, cardB int
			fmt.Scanf("%d %d", &cardA, &cardB)

			if cardA > cardB {
				a += cardA + cardB
			} else if cardB > cardA {
				b += cardA + cardB
			} else {
				a += cardA
				b += cardB
			}
		}

		fmt.Println(a, b)
	}
}

C++: #include<iostream>
using namespace std;
int main(){
	while (1){
		int n, a[1000] = {0}, b[1000] = {0}, 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>
int A,B;
int main(void)
{
using namespace std;
int n,C,D;
while(1)
{
cin>>n;
if(!n)break;
A=0;
B=0;
for(;n>0;n--){
cin>>C;
cin>>D;
if(C>D){
A+=(C+D);
}else if(C<D){
B+=(C+D);
}else{
A+=C;
B+=D;
}
}
cout<<A<<" "<<B<<endl;
}
return 0;
}

C++: #include <iostream>

using namespace std;

int main() {
    int n, A, B;
    while (cin >> n && n != 0) {
        int sumA = 0, sumB = 0;
        for (int i=0; i<n; ++i) {
            cin >> A >> B;
            if (A == B) {
                sumA += A;
                sumB += B;
            } else if (A < B) {
                sumB += A + B;
            } else {
                sumA += A + B;
            }
        }
        cout << sumA << " " << sumB << endl;
    }
    return 0;
}

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

int main(){
  int n;
  int a,b,A,B;

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

C++: #include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  int c1,c2,p1 = 0,p2 = 0;
  while(scanf("%d",&n)){
    if(n == 0)break;
    while(n--){
      scanf("%d %d",&c1,&c2);
      if(c1 > c2)p1 += c1+c2;
      else if(c1 < c2)p2 += c1+c2;
      else{
	p1 += c1;
	p2 += c2;
      }
    }
  }
  printf("%d %d\n",p1,p2);
}

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

int main(void)
{
    int i;
    int num, x, y;
    int p1 = 0;
    int p2 = 0;

    for (;;) {
        scanf("%d", &num);
        if (num == 0) {
            break;
        }

        for (i = 0; i < num; i++) {
            scanf("%d %d", &x, &y);
            if (x > y) {
                p1 += (x+y);
            }
            else if (x < y) {
                p2 += (x+y);
            }
            else {
                p1 += x;
                p2 += y;
            }
        }
        printf("%d %d\n", p1, p2);
        p1 = p2 = 0;
    }

    return 0;
}

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

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

C++: //30
#include<iostream>

using namespace std;

int main(){
  for(int n;cin>>n,n;){
    int a=0,b=0;
    for(int i=0;i<n;i++){
      int ta,tb;
      cin>>ta>>tb;
      if(ta>tb){
	a+=ta+tb;
      }else if(ta==tb){
	a+=ta;
	b+=tb;
      }else{
	b+=ta+tb;
      }
    }
    cout<<a<<' '<<b<<endl;
  }
  return 0;
}

C++: #include<stdio.h>

void main(){
    int n, i;
    int card[2];
    int result[2];
    result[0] = result[1] = 0;
    scanf("%d",&n);
    for(i=0;i < n;i++){
        card[0] = card[1] = 0;
        scanf("%d %d", &card[0], &card[1]);
        if(card[0] < card[1]) result[1] += card[0] + card[1];
        else if(card[0] > card[1]) result[0] += card[0] + card[1];
        else{
            result[0] += card[0];
            result[1] += card[1];
        }
    }
    printf("%d %d\n", result[0], result[1]);
    return 0;
}

C++: #include<cstdio>
#include<iostream>
using namespace std;
int q[6][3];
int main()
{
	int i,j,n,s,m,a,b,p=1;
	while(cin>>s)
	{
		a=0;b=0;
		if(s==0)break;
	for(i=1;i<=s;i++)
	{
		cin>>n>>m;
		if(n>m)a=a+n+m;
		else if(n<m)b=b+n+m;
		else
		{
			a=a+n;
			b=b+m;
		}
	}
	q[p][1]=a;
	q[p][2]=b;
	p++;
    }
    for(i=1;i<p;i++)cout<<q[i][1]<<" "<<q[i][2]<<endl;
	return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<string>
#include<functional>
#include<queue>
#include<stack>
#include<math.h>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	int n;
	while (cin >> n) {

		int a, b;
		int ascore = 0, bscore = 0;
		vector<P>card;
		for (int i = 0; i < n; i++) {
			cin >> a >> b;
			if (a > b)ascore += a + b;
			else if (b < a)bscore += a + b;
			else {
				ascore += a;
				bscore += b;
			}
		}
		cout << ascore << " " << bscore << endl;
	}


	return 0;
}

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