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>
#include<stdio.h>
using namespace std;
int main(){
    int num,a_score=0,b_score=0;
    
    scanf( "%d", &num );
    for(int i=0;i<num;i++){
        int a_card,b_card;
        scanf("%d %d",&a_card,&b_card);
        if(a_card>b_card){a_score+=a_card+b_card;}
        else if(a_card==b_card){a_score+=a_card;b_score+=b_card;}
        else b_score+=a_card+b_card;
    } 
    cout<<a_score<<" "<<b_score<<endl;
     
    
}

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

int main(){
	int matchCount = 0;
	int inputCount;
	int pointSumA[5] = {0}, pointSumB[5] = {0};
	
	while(cin >> inputCount){
		//cout << inputCount << endl;
		if (!inputCount) break;
		
		int cnt = 0;
		while (cnt++ < inputCount){
			int tempA, tempB;
			cin >> tempA >> tempB;
			if (tempA > tempB){
				pointSumA[matchCount] += (tempA + tempB);
			} else if (tempA == tempB) {
				pointSumA[matchCount] += tempA;
				pointSumB[matchCount] += tempA;
			} else {
				pointSumB[matchCount] += (tempA + tempB);
			}
		}
		matchCount++;
	}
	int cnt2 = 0;
	while(cnt2 < matchCount){
		cout << pointSumA[cnt2++] << " " << pointSumB[cnt2] << endl;
	}
	return 0;
}

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

int main(){
	int n,hand[2],sum[2];
	while(1){
		sum[0]=0;
		sum[1]=0;
		cin>>n;
		if(n==0)break;
		for(int i=0;i<n;i++){
			cin>>hand[0]>>hand[1];
			if(hand[0]>hand[1]){
				sum[0]+=hand[0]+hand[1];
			}else if(hand[0]<hand[1]){
				sum[1]+=hand[0]+hand[1];
			}else{
				sum[0]+=hand[0];
				sum[1]+=hand[1];
			}
		}
		cout<<sum[0]<<' '<<sum[1]<<endl;
	}
	return 0;
}

C++: // cardgame.cpp
#include <iostream>
using namespace std;

int main(){
	int g,h;
	cin >> g;
	for(h=0;h<g;h++){
		int n=0;
		int i,j;
		int a[10000], b[10000];
		int a_point=0, b_point=0;
		cin >> n;
		for(i=0;i<n;++i){
				cin >> a[i];
				cin >> b[i];
		}
		for(j=0;j<n;++j){
			if(a[j]>b[j])
				a_point+=(a[j]+b[j]);
	        else if(a[j]<b[j])
				b_point+=(a[j]+b[j]);
			else if(a[j]==b[j]){
				a_point+=a[j];
				b_point+=b[j];
			}
		}
		cout << a_point << " " << b_point << endl;
	}
	return 0;	
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<climits>
using namespace std;
#define rep(i, j) for(int i = 0; i < j; i++)
#define P pair<int, int>
const int INF = INT_MAX / 2;

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

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

int main()
{
	int a;
	int r, l;
	int rsum, lsum;
	rsum = 0;
	lsum = 0;
	while (cin >> a){
		for (int i = a; i > 0; i--){

			cin >> r;
			cin >> l;
			if (r > l){
				rsum += r + l;
			}
			else if (l > r){
				lsum += r + l;
			}
			else{
				rsum += r;
				lsum += l;
			}
		}
		cout << r << ' ' << l << endl;
	}
}

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 <cstdio>

int n,an,bn,i,j;
int a[10000],b[10000];
int main (){
	scanf("%d",&n);
	an=0;
	bn=0;
	for (i=0;i<n;i++){
		scanf("%d %d",&(a[i]),&(b[i]));
	}
	for(j=0;j<n;j++){
		if(a[j]>b[j]) an=an+(a[j]+b[j]);
		else if(a[j]<b[j]) bn=bn+(a[j]+b[j]);
		else if (a[j]==b[j]) { 
			an=an+a[j];
			bn=bn+b[j];
		}
	}
	printf("%d %d\n",an,bn);
	return 0;
}

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

int main(){
	int a,b,c,m=0;
    while(m==0){
		int ap=0,bp=0;
		std::cin>>c;
		if(c==0)break;
		for(int i=0;i<c;i++){
			std::cin>>a>>b;
			if(a>b)ap+=a,ap+=b;
			else if(b>a){
				bp+=a;bp+=b;
			}else{
				ap+=a,bp+=b;
			}
		}
		std::cout<<ap<<" "<<bp<<std::endl;
	}
	return 0;
}

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

int main(){
  int ans1=0,ans2=0,num1,num2,n;

  while(1){
    ans1=ans2=0;
    cin>>n;
    if(n==0)break;
    for(int i=0;i<n;i++){
      cin>>num1>>num2;
      if(num1>num2)ans1=ans1+num1+num2;
      else if(num1<num2)ans2=ans2+num1+num2;
      else {
	ans1=ans1+num1;
	ans2=ans2+num1;
      }
    }
    cout<<ans1<<" "<<ans2<<endl;
  }
 
 return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int a[10000],b[10000],n,i,c[2];
	for(;;){
		scanf("%d",&n);
		if(n==0)
			break;
		for(i=0;i<n+1;i++){
			scanf("%d%d",&a[i],&b[i]);
			if(a[i]>b[i])
				c[0]=a[i]+b[i];
			else
				c[1]=a[i]+b[i];
		}
		printf("%d %d\n"c[0],c[1]);
	}
	return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int n;
	int a,b;
	int a1,b1;
	int i;
	scanf("%d",&n);
	while(n!=0){
		a1=0;
		b1=0;
		for(i=0;i<n;i++){
			scanf("%d %d",&a,&b);
			if(a>b){
				a1+=a;
				a1+=b;
			}
			else if(a<b){
				b1+=a;
				b1+=b;
			}
			else{
				a1+=1;
				b1+=1;
			}
		}
		printf("%d %d",a1,b1);
		scanf("%d",&n);
	}
	return 0;
}

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

int main(){
  int i, n, s=0, t=0;
  int a[10000], b[10000];

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

    for (i=0; i<n; i++){
      cin >> a[i] >> b[i];
      if (a[i]>b[i]){
	s=s+a[i]+b[i];
      } else if (a[i]<b[i]){
	t=t+a[i]+b[i];
      } else {
	s+=a[i]; t+=b[i];
      }
    }
    cout << s << " " << t << endl;
    s=0; t=0;
  }

  return 0;
}

C++: #include<stdio.h>


int main(){
	int n;
	int a=0;
	int	b=0;
	int apoint=0;
	int bpoint=0;
	int i;

	scanf("%d",&n);

	while(n!=0){
		for(i=0;i<n;i++){
			scanf("%d %d",&a,&b);
			if(a<b){
				bpoint = bpoint + a + b;
			}if(a>b){
				apoint = apoint + a + b;
			}if(a==b){
				apoint= apoint + a;
				bpoint= bpoint + b;
			}
		}		
		printf("%d %d",apoint,bpoint);
		apoint=0;
		bpoint=0;
		scanf("%d",&n);
	}
}

C++: #include<iostream>

int main(){
	int n,A_point,B_point,A,B;
	std::cin>>n;
	for(int i=0;i<n;++i){
		std::cin>>A>>B;
		if(A>B)
			A_point+=A+B;
		else if(A==B){
			A_point+=A;
			B_point+=B;
		}
		else B_point+=A+B;
	}
	std::cout<<A_point<<' '<<B_point<<std::endl;
	return 0;
}

C++: #include <iostream>

using namespace std;

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

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

int main() {
	int q[10001], w[10001];
	
	int x = 1;
	while (1) {
		int n;
		int a = 0;
		int b = 0;
		cin >> n;
		if (n == 0) {
			break;
		}

		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;
			}
		}
		q[x] = a;
		w[x] = b;
		x = x + 1;
	}
	for (int j = 1; j <= x-1; ++j) {
		cout << q[j]<< w[j] << endl;
	}
}