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 <vector>
using namespace std;

int n;
int solve(){
    vector<int> a(n),b(n);
    for(int i=0;i<n;i++){
        cin >> a[i] >> b[i];
    }

    int pa = 0, pb = 0;
    for(int i=0;i<n;i++){
        if(a[i] > b[i]) pa += a[i]+b[i];
        else if(a[i] < b[i]) pb += a[i]+b[i];
        else{
            pa += a[i];
            pb += b[i];
        }
    }
    cout << pa << " " << pb << endl;
}

int main(){
    while(1){
        cin >> n;
        if(n==0) break;
        solve();
    }
}

C++: #include<iostream>

using namespace std;
int A=0,B=0,a,b,n;
int main(){
cin >> n;

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

return 0;
}

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

int main(){
	int n, x, y, sumx=0, sumy=0;
	cin >> n;

	for(int i=0; i<n; i++){
		x=0,y=0;
		cin >> x >> y;
		if(x > y){
			sumx = sumx + x + y;
		}
		else if(x < y){
			sumy = sumy + x + y;
		}
		else if(x == y){
			sumx = sumx + x;
			sumy = sumy + y;
		}
	}
	
	cout << sumx << " " << sumy << endl;
	return 0;
}

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

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

C++: #include <bits/stdc++.h>

using namespace std;

int main(){
    while(true){
    int n;
    scanf("%d", &n);
    if(n==0) return 0;
    vector<int> a(n), b(n);
    for(int i=0;i<n;++i) scanf("%d %d", &a[i],&b[i]);
    int as=0, bs=0;
    for(int i=0;i<n;++i){
        if(a[i]>b[i])as+=a[i]+b[i];
        else if(a[i]<b[i])bs+=a[i]+b[i];
        else {as+=a[i];bs+=b[i];}
    }
    printf("%d %d\n", as,bs);
    }
}

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

C++: #include <stdio.h>

int main() {
    int n, i, num[2], result[2] = { 0,0 };

    while (scanf("%d", &n)) {
        if (n == 0) break;

        result[0] = 0;
        result[1] = 0;
        for (i = 0; i < n; i++) {
            scanf("%d %d", &num[0], &num[1]);
            if (num[0] > num[1]) result[0] += num[0] + num[1];
            else if (num[0] < num[1]) result[1] += num[0] + num[1];
            else result[0] += num[0], result[1] += num[1];
        }
        printf("%d %d\n", result[0], result[1]);
    }

    return 0;
}

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

int main() {
	int n;
	int a = 0, b = 0;

	while (cin >> n, n) {
		for (int i = 0; i < n; i++) {
			int x, y;
			cin >> x >> y;
			if (x > y) { a += (x + y); }
			else if (x < y) { b += (x + y); }
			else { 
			a += x;
			b += y;
			}
		}
		cout << a << b << endl;
		a = 0;
		b = 0;
	}
	return 0;
}

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

}

C++: #include<iostream>

using namespace std;

int main() {

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

		int point_a = 0;
		int point_b = 0;

		for (int i = 0; i < n; ++i) {
			int a, b;
			cin >> a >> b;
			if (a > b) {
				point_a += a + b;
			}
			else if (a < b) {
				point_b += a + b;
			}
			else {
				point_a += a;
				point_b += b;
			}
		}
		cout << point_a << " " << point_b << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  while(1){
    cin>>n;
    if(n==0){
      break;
    }
    int a,b;
    int aa=0,bb=0;
    for(int i=0;i<n;i++){
      cin>>a>>b;
      if(a>b){
	aa+=a+b;
      }else if(b>a){
	bb+=a+b;
      }else{
	aa+=a;
	bb+=b;
      }
    }
    cout<<aa<<' '<<bb<<endl;
  }
  return(0);
}

C++: #include<stdio.h>
int A=0,B=0;
int a,b;

void Total(){
	if(a>b)	A+=a+b;
	else if(a<b) B+=a+b;
	else {A+=b;B+=a;}
}

int main(){
	int n,i;
	for(;;){
		scanf("%d",&n);
		if(n!=0){
			for(i=0;i<n;i++){
				scanf("%d%d", &a, &b);
				Total();
			}
			printf("%d %d\n",A,B);
			A=B=0;
		}else break;
	}
	return 0;
}

C++: #include<stdio.h>

int main(){
	int n;
	int A=0;
	int B=0;
	int i=0;
	scanf("%d", &n);
	int x[10000];
	int y[10000];
	while(i<n){
	scanf("%d", &x[i]);
	scanf("%d", &y[i]);
	++i;
}
	i=0;
	while(i<n){
	if(0>x[i] || 9<x[i]){
	return 0;
	}
	if(0>y[i] || 9<y[i]){
	return 0;
	}
	++i;
}
	i=0;
	while(i<n){
	if(x[i]>y[i]){
	A=A+x[i]+y[i];
}else {
	if(x[i]<y[i]){
	B=B+x[i]+y[i];
}else{
	A=A+x[i];
	B=B+y[i];
			}
		}
	++i;
	}
	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<iostream>
using namespace std;
int main(){
  int n,pointA,pointB;
  int a[10000],b[10000];
  for(n = 1;n != 0;){  
 cin >> n;
 if(n != 0){
    pointA = 0; pointB = 0;
  for(int i = 0;i < n;i++){
    cin >> a[i] >> b[i];
  }
  for(int i = 0;i< n;i++){
    
    if(a[i] < b[i]){
      pointB = pointB + a[i] +b[i];
    } else if(a[i] > b[i]){
      pointA = pointA + a[i] +b[i];
    } else if(a[i] == b[i]){
      pointA = pointA + a[i];
      pointB = pointB + b[i];
    }
  }
 
  cout << pointA << " "<< pointB << endl;
 }
  }
  
  
}

C++: #include <stdio.h>
int n,i,j,k;
int A[1],B[1];
int main(){
  for(;;){
    A[0]=0,B[0]=0;
    scanf("%d",&n);
    if(n==0){
      return 0;
    }
      for(i=0;i<n;i++){
      scanf(" %d %d",&j,&k);
      if(j>k){
        A[0]+=(j+k);
      } else if(j<k){
        B[0]+=(j+k);
      } else if(j==k){
        A[0]+=j;
        B[0]+=k;
      }
      printf("%d %d\n",A[0],B[0]);
    }
  }
}

C++: #include <stdio.h>
int main(void)
{
	int a[100], i, j, m, n, b[100], A = 0, B = 0;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d %d", &a[i], &b[i]);
	}
	for (i = 0; i < n; i++) {
		if (a[i] > b[i]) {
			A = A+a[i] + b[i];
		}
		else if (a[i] == b[i]) {
			A =A+ a[i];
			B =B+ b[i];
		}
		else {
			B = B+a[i] + b[i];
		}
	}
	printf("%d %d\n", A, B);
}

C++: #include<iostream>

int main(){

	int n;

	int a=0, b=0;

	int x, y;

	f:

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

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

	goto f;

flag:

	return 0;

}