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 <stdio.h>

int n, A[11234], B[11234];
int ans[2];

int main(void) {
	while (true) {
		ans[0] = ans[1] = 0;
		scanf("%d", &n);
		if (n == 0) { break; }
		for (int i = 0; i < n; ++i) { scanf("%d%d", &A[i], &B[i]); }

		for (int i = 0; i < n; ++i) {
			if (A[i] > B[i]) { ans[0] += A[i] + B[i]; }
			else if (A[i] < B[i]) { ans[1] += A[i] + B[i]; }
			else { ans[0] += A[i], ans[1] += B[i]; }
		}

		printf("%d %d\n", ans[0], ans[1]);
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdio>
#include<string>
#include<cmath>
typedef long long int ll;
#define VI vector<int>

#define rep(i,a) for(int i=0;i<(a);i++)
#define all(i) i.begin(),i.end()
#define INF 1000000000


using namespace std;


/**/
VI y;
pair<int,int> x[31];


int main(){
	int n;
	int a,b;
	int suma=0,sumb=0;
	cin>>n;
	rep(i,n){
		cin>>a>>b;
		if(a>b){
			suma+=a+b;
		}else if(a<b){
			sumb+=a+b;
		}else if(a==b){
			suma+=a;
			sumb+=b;
		}

	}
	cout<<suma<<" "<<sumb<<endl;

	return 0;
}

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

	int n, a, b, ap = 0, bp = 0;

	cin >> n;

	while (n != 0){

		for (int i = 0; i < n; i++){
			cin >> a >> b;

			//?????°?????´??°
			if (a > b)
				ap += a + b;
			else if (a < b)
				bp += a + b;
			else{
				ap += a;
				bp += b;
			}
		}

		cout << ap << " " << bp << endl;

		ap = 0;
		bp = 0;

		cin >> n;

	}
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
using namespace std;
int main(){
	
	int n;
	int A=0,B=0;
	cin>>n;
	
	vector<int>a(n);
	vector<int>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(b[i]>a[i])
			B+=a[i]+b[i];
		else{
			A+=a[i];
			B+=b[i];
		}
	}
	cout<<A<<" "<<B<<endl;
}

C++: #include <stdio.h>

int main(void)
{
    while(1){
        int n;
        scanf("%d",&n);
        if( n<=0 ) break ;
        int n1=0,n2=0;
        for( int i=0;i<n;i++ ){
            int c1,c2;
            scanf("%d %d",&c1,&c2);
            if( c1>c2 ) n1+=c1+c2;
            else
            if( c1<c2 ) n2+=c1+c2;
            else
                n1+=c1,n2+=c2;
        }
        printf("%d %d\n",n1,n2);
    }
    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\n",a1,b1);
		scanf("%d",&n);
	}
	return 0;
}

C++: #include<cstdio>

using namespace std;

int main() {
  int n, tmp1, tmp2, a=0, b=0;
  scanf("%d", &n);
  for (int i=n; i>0; i--) {
    scanf("%d %d", &tmp1, &tmp2);
    if (tmp1>tmp2)
      a+=tmp1+tmp2;
    else if (tmp1==tmp2)
      a+=tmp1, b+=tmp2;
    else
      b+=tmp1+tmp2;
  }
  printf("%d %d\n", a, b);
  return 0;
}

C++: #include<iostream>
#include<stdio.h>
using namespace std;
int main(){
    int num,a_score=0,b_score=0;
    while(1){
        scanf( "%d", &num );
        if(num==0)break;
        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>
#include <vector>
#include <string>

using namespace std;

int main(){


	while(1){
		int n;
		cin >> n;
		if(n == 0)
			break;
		vector<int> A,B;
		for(int i = 0; i < n; i++){
			int a,b;
			cin >> a >> b;
			A.push_back(a);
			B.push_back(b);
		}

		int a_score = 0;
		int b_score = 0;
		for(int i = 0; i < A.size(); i++){
			if(A[i] > B[i]){
				a_score += A[i] + B[i];
			}
			else if(A[i] < B[i]){
				b_score += A[i] + B[i];
			}
			else{
				a_score += A[i];
				b_score += B[i];
			}
		}
		cout << a_score << " " << b_score << endl;
	}


	return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
	int all,Atotal=0,Btotal=0;
	int A[all];
	int B[all];
	
	
	cin>>all;
	for(int i=0; i<all; i++){
	cin>> A[i]>>B[i];
	}

	for(int j=0; j<all; j++){
	
	if(A[j]>B[j]){
	Atotal+=A[j]+B[j];
	}

	else if(A[j]<B[j]){
	Btotal+= A[j]+B[j];
	}

	else{
	Atotal+=A[j];
	Btotal+=B[j];
	}
    }
	
	cout<<Atotal<<' '<<Btotal<<'\n';
	return 0;
}

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

using namespace std;

int main(){
  while(true){
    int N, score[] = {0, 0};
    scanf("%d", &N);
    if(N == 0)
      return 0;

    for(int i = 0; i < N; i++){
      int a, b;
      cin >> a >> b;
      if(a > b)
        score[0] += a + b;
      else if(a < b)
        score[1] += a + b;
      else{
        score[0] += a;
        score[1] += b;
      }
    }
    printf("%d %d\n", score[0], score[1]);
  }
}

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

int main(){
	int num_battle;
	int a, b;
	int point_a = 0;
	int point_b = 0;
	string cards;

	cin >> num_battle;
	
	for(; num_battle != 0;){
		while(num_battle > 0){
			cin >> a >> b;
			if(a == b){
				point_a += a;
				point_b += b;
			}else if(a > b){
				point_a += a + b;
			}else{
				point_b += a + b;
			}
			num_battle--;
		}
		cout << point_a << " " << point_b << endl;
		// initialize
		point_a = 0;
		point_b = 0;
		cin >> num_battle;
	}

	return 0;
}

C++: #include<cstdio>

int n;

int main(){
	int A,B,Aanswer=0,Banswer=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d %d",A,B);
		if(A>B)Aanswer+=A+B;
		else if(A<B)Banswer+=A+B;
		else{
			Aanswer+=A;
			Banswer+=B;
		}
	}
	printf("%d %d\n",Aanswer,Banswer);
	return 0;
}

C++: #include <iostream>

using namespace std;

int n,a,b,sum_a,sum_b;

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

C++: #include<iostream>
using namespace std;
int main(){
	int n,a,b,c,d,s;
	while(true){
		a=0,b=0;
		cin>>n;
		if(n==0)break;
		for(int i=0;i<n;i++){
			cin>>c>>d;
			s=c+d,b+=s;
			if(c>d)a+=s;
			if(c==d)a+=c;
		}
		cout<<a<<" "<<b-a<<endl;
	}
	return 0;
}

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

int main(){
  int n;
  int p1,p2;
  while(1){
    cin >> n;
    if(n==0) break;
    int ans1=0,ans2=0;
    for(int i=0;i<n;i++){
      cin >> p1 >> p2;
      if(p1 > p2){
	ans1 += p1 + p2;
      }
      else if(p1 < p2){
	ans2 += p1 + p2;
      }
      else{
	ans1 += p1;
	ans2 += p2;
      }
    }
    cout << ans1 << " " << ans2 << endl;
  }
}

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

int main(){
int n,a,b;
int sumA=0,sumB=0;
while(cin>>n){
	if(n==0)break;
	sumA=0,sumB=0;
for(int i=0;i<n;i++){
cin>>a>>b;
if(a>b){
sumA+=a;
sumA+=b;
}
if(a==b){
sumA+=a;
sumB+=b;
}
if(a<b){
sumB+=a;
sumB+=b;
}}
printf("%d %d\n",sumA,sumB);
}}

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

int main()
{
  int n, x, y;
  cin >>n;
  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;
}