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(){
  int n,a,b,count;
     int  A[10],B[10];
     count=0;
     for(int j=0;;j++){
       A[j]=0;
       B[j]=0;
    cin >> n;
    if(n==0)break;
    
    for(int i=0;i<n;i++){
      
      cin >> a >> b;
      if(a>b){
	A[j]+=a+b;
      }
      else if(a<b){
	B[j]+=a+b;
      }
      else if(a==b){
	A[j]+=a;
	B[j]+=b;
      }
      
    }cout << A[j] << " " << B[j] << endl;
    }
      for(int i=0;i<n;i++){
    cout << A[i] << " " << B[i] << endl;
    }
  return 0;
}

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

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

C++: #include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n,a,b,countA=0,countB=0;
    cin>>n;
    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;
        cout<<"\n";
        countA=0,countB=0;
        cin>>n;
        if(n==0)break;
    }while(1);
    return(0);
}

C++: #include<stdio.h>
void judge(int n, int a[], int b[], int *result1, int *result2) {
	while (--n >= 0) {
		if (a[n] > b[n]) {
			*result1 += a[n] + b[n];
		}
		else if (a[n] < b[n]) {
			*result2 += a[n] + b[n];
		}
		else if (a[n] == b[n]) {
			*result1 += a[n];
			* result2 += b[n];
		}
	}
}
int main() {
	int a[10];
	int b[10];
	int n, t = 0;
int i;
	int result1 = 0, result2 = 0;
	int result[10][2];
	do {
		scanf_s("%d", &n);
		for (i = 0; i < n; i++) {
			scanf_s("%d %d", &a[i], &b[i]);
		}
		judge(n, a, b, &result1, &result2);
		result[t][0] = result1;
		result[t][1] = result2;
		result1 = 0;
		result2 = 0;
		t++;
	} while (n != 0);

	for (i = 0; i < t-1;i++) {
		printf("%d %d\n", result[i][0], result[i][1]);
	}

	return 0;
}

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

C++: #include <iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	while(n){
		int point[2];
		enum {
			A,
			B,
		};
		int sum[2] = {0,0};
		for (int i = 0; i < n; i++) {
			cin>>point[A]>>point[B];
			if (point[A]>point[B]) {
				for (auto j : point) {
					sum[A]+=j;
				}
			} else if(point[A] == point[B]) {
				for (int j = 0; j < 2; j++) {
					sum[j]+=point[j];
				}
			} else {
				for (auto j : point) {
					sum[B]+=j;
				}
			}
		}
		cout<<sum[A]<<" "<<sum[B]<<endl;
		cin>>n;
	}
	return 0;
}

C++: #include <iostream>

int main(){
    
    while(true){
    
    int num,a,b,resa=0,resb=0;
    
    std::cin>>num;
    
    if(num==0)
        break;
    
    for(int i=0;i<num;i++){
        std::cin>>a>>b;
        if(a>b)
            resa+=a+b;
        else
        if(a<b)
            resb+=a+b;
        else
            if(a==b)
                resa+=a,resb+=b;
    }
    
    std::cout<<resa<<' '<<resb<<std::endl;
        
    }
    
    return 0;
}

C++: #include<cstdio>
#include<algorithm>
#include<cmath>

using namespace std;

int main(){
        while(true){
                int pa = 0, pb = 0;      
                int a, b, n, i
                scanf("%d", &n);
                if(!n) break;
                for(i = 0; i < n; i++){
                        scanf("%d%d", &a, &b);
                        if(a > b)
                                pa += a + b;
                        else if(b > a)
                                pb += a + b;
                        else if(a == b){
                                pa += a;
                                pb += b;
                        }
                }
                printf("%d %d\n", pa, pb);
        }
        return 0;
}

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

return 0;
}

C++: #include <cstdio>
int n,a,b,c,d,i;
int main(void){
  scanf("%d",&n);
  if(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;
}

C++: #include <iostream>

int main(){
    int n, a, b, apt, bpt;
    while(std::cin >> n, n){
        for(apt = bpt = 0; n; n--){
            std::cin >> a >> b;
            if(a > b)
                apt += a + b;
            else if(b > a)
                bpt += a + b;
            else{
                apt += a;
                bpt += b;
            }
        }
        std::cout << apt << ' ' << bpt << std::endl;
    }
    return 0;
}