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

using namespace std;

int main(void){
	int n;
	while (1){
		int A = 0, B = 0;
		scanf("%d", &n);
		if (n == 0)return 0;
		for (int i = 0; i < n; i++){
			int a, b;
			scanf("%d %d", &a, &b);
			if (a > b){
				a += b;
				b = 0;
			}
			if (a < b){
				b += a;
				a = 0;
			}
			A += a;
			B += b;
		}
		printf("%d %d\n", A, B);
	}
}

C++: #include <cstdio>

using namespace std;

int main(void){
	int n, i, a, b, x, y;
	while(1){
		scanf("%d",&n);
		if(!n){
			break;
		}
		a = b = 0;
		for(i = 0;i < n;i++){
			scanf("%d%d",&x,&y);
			if(x > y){
				a += x + y;
			}else if(x < y){
				b += x + y;
			}else{
				a += x;
				b += y;
			}
		}
		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<stdio.h>

int main(){
	int n;
	int i;
	int left,right;
	while(1){
		left = 0;
		right = 0;
		
		scanf("%d",&n);
		if(n == 0 ){
			break;
		}
		for(i = 0; i < n ;i++){
			int a, b;
			scanf("%d %d\n",&a,&b);
			if(a>b){
				left += a+b;
			}else if(a==b){
				left += a;
				right += b;
			}else { // a<b
				right += a+b;
			}
		}
		printf("%d %d\n",left,right);
	}
	return 0;
}

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

C++: #include <iostream>
using namespace std;
int main(){
	int n;
	int num=0,sum=0;

	cin >> n;

	int a[10];
	int b[10];
	for(int i=1; i<=n; i++){

		cin >> a[i] >> b[i];

		if(a[i] > b[i]){
			
			num+=a[i]+=b[i];
		}
		else if(a[i] < b[i]){
			
			sum+=b[i]+=a[i];
		}
		else if(a[i] == b[i]){

			num+=a[i];
			sum+=b[i];
		}
	}

	cout << num << " " << sum << endl;

	return 0;
}

C++: #include<cstdio>
using namespace std;
int main(){
  int A,B,n;
  int a,b;
  while(true){
    scanf("%d",&n);
    if(n == 0)
      break;
    A = B = 0;
    for(int i = 0 ; i < n ; i++){
      scanf("%d %d",&a,&b);
      if(a > b)
        A += (a + b);
      else if(a < b)
        B += (a + b);
      else{
        A += a;
        B += a;
      }
    }
    printf("%d %d\n",A,B);
  }
}

C++: #include<iostream>

void main(){

	int n;

	int a=0, b=0;

	int x, y;

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

flag:

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

}

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] << endl;
		cout << w[j] << endl;
	}
}

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

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

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

C++: #include <stdio.h>
#include <iostream>

using namespace std;

int main() {
	int n;
	int a,b;
	int ta,tb;

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

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

int main(){
	int n,a=0,b=0;
	std::cin>>n;
	std::vector<int> v1(n);
	std::vector<int> v2(n);
	for(int i=0;i<n;i++){
		std::cin>>v1[i]>>v2[i];
		if(v1[i]>v2[i]){
			a+=v1[i]+v2[i];
		}else if(v1[i]<v2[i]){
			b+=v1[i]+v2[i];
		}else{
			a+=v1[i];
			b+=v2[i];
		}
	}
	std::cout<<a<<" "<<b<<std::endl;
}

C++: #include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n,a,b,countA=0,countB=0;
    cin>>n;
    if(n!=0){
    do{
        for(int i=0;i<n;i++){
            cin>>a>>b;
            if(a>b){
                countA+=(a+b);
            }else if(a<b){
                countB+=(a+b);
            }//a==b
        }
        cout<<countA<<" "<<countB;
        countA=0,countB=0;
        cin>>n;
        if(n==0)break;
        cout<<"\n";
    }while(1);
    }
    cout<<endl;
}

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

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

C++: #include <stdio.h>

int N ;
int a ;
int b ;
int point[2] ;

void init ( ) ;

int main ( )
{
	while ( scanf ( "%d" , &N ) == 1 ) {
		init ( ) ;
		for ( int i = 0 ; i < N ; i++ ) {
			scanf ( "%d %d" , &a , &b ) ;
			if ( a > b ) {
				point[0] += ( a + b ) ;
			}
			else if ( a == b ) {
				point[0] += a ;
				point[1] += b ;
			}
			else {
				point[1] += ( a + b ) ;
			}
		}
		printf ( "%d %d\n" , point[0] , point[1] ) ;
	}
	return 0 ;
}

void init ( )
{
	point[0] = point[1] = 0 ;
}

C++: #include <cstdio>
int n,a,b,c,d,i;
int main(void){
  scanf("%d",&n);
  while(n){
    c=0;d=0;
    for(i=0;i<n;i++){
      scanf("%d%d",&a,&b);
      if(a>b)c+=a+b;
      else if(a<b)d+=a+b;
      else{
        c+=a;d+=b;
      }
    }
    printf("%d %d\n",&c,&d);
    scanf("%d",&n);
  }
  return 0;
}