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

C++: #include <cstdio>
int main(){
 int asum,bsum,a,b,n,i;
 scanf("%d",&n);
 while(n>0){
 asum=bsum=0;
 scanf("%ld",&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);
 scanf("%d",&n);
 }
 return 0;
};

C++: #include<bits/stdc++.h>
using namespace std;

int main(){
  int n, a[10000], b[10000], asum = 0, bsum = 0;
  while(scanf("%d\n", &n)){
    if(n == 0) return 0;

    for(int i = 0;i < n;i++) scanf("%d %d\n", &a[i], &b[i]);
    for(int i = 0;i < n;i++){
      if(a[i] > b[i]) asum += a[i]+b[i];
      else if(a[i] < b[i]) bsum += a[i]+b[i];
      else {
         asum += a[i];
         bsum += b[i];
      }
   }
   printf("%d %d\n", asum, bsum);
  }
}

C++: #include <stdio.h>
#include <math.h>
#include <ctype.h>

int main(void)
{
  int i,j,k,l;
  int n,m;
  int a,b;
  int cnt_a,cnt_b;
  while(1) {
	scanf("%d",&n);
	if(n == 0) break;
	cnt_a = cnt_b = 0;
	for(i=0;i<n;i++) {
	  scanf("%d %d",&a,&b);
	  if(a > b) cnt_a += a+b;
	  else if(b > a) cnt_b = a+b;
	  else cnt_a += a ,cnt_b += b;
	}
	printf("%d %d\n",cnt_a,cnt_b);
  }
	
  return 0;
}

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

int main(void) {
	int i, n, a, b, as = 0, bs = 0;
	for(cin >> n ; n != 0 ; as = bs = 0, cin >> n) {
		for(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;
	}
	return 0;
}

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

struct player{
    int point;
    int card[10000];
    inline player(){point = 0;}
};

int main()
{
    int loop = 1;
    player a, b;
    while(loop) {
        cin >> loop;
        for(int c = 0; c < loop; c++)
        {
            cin >> a.card[c];
            cin >> b.card[c];
        }

        for(int c = 0; c < loop; c++)
        {
            if(a.card[c] < b.card[c])
            {
                b.point += a.card[c] + b.card[c];
                continue;
            }
            if(a.card[c] == b.card[c])
            {
                 a.point += a.card[c];
                 b.point +=b.card[c];
                 continue;
            }
            a.point += a.card[c] + b.card[c];
        }
        
    }
    cout << a.point << " " << b.point << endl;
    return EXIT_SUCCESS;
}

C++: #include <bits/stdc++.h>
using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = (n)-1; i >= 0; i--)
#define FOR(i, l, r) for(int i = l; i < r; i++)
#define RFOR(i, l,r) for(int i= (l)-1; i>= (r) ; i--)

#define int64 int64_t
#define uint64 uint64_t
#define uint unsigned

short a[10000], b[10000];
int n;

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

        REP(i, n)
            cin >> a[i] >> b[i];
        uint ap = 0;
        uint bp = 0;

        REP(i, n){
            if(a[i] > b[i])
                ap += a[i] + b[i];
            else if(a[i] < b[i])
                bp += a[i] + b[i];
            else{
                ap += a[i];
                bp += b[i];
            }
        }
        cout << ap << ' ' << bp << endl;
    }
}

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

using namespace std;

int main() {
	int p1[10000], p2[10000], n, point1 = 0, point2 = 0, i;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> p1[i] >> p2[i];
	}
	for (i = 0; i < n; i++) {
		if (p1[i] == p2[i]) {
			point1 += p1[i];
			point2 += p2[i];
		}
		else if (p1[i] > p2[i]) {
			point1 += p1[i] + p2[i];
		}
		else {
			point2 += p1[i] + p2[i];
		}
	}
	cout << point1 << ' ' << point2 << endl;
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
int n;
int a[10000],b[10000];
while(cin>>n){
a[10000]={};
b[10000]={};
int ap=0,bp=0;
	for(int i=0;i<n;i++){
		cin>>a[n]>>b[n];
		sum=a[n]+b[n];
		if(a[n]>b[n]){
			ap+=sum;
		}else if(a[n]<b[n]){
			bp+=sum;
		}else{
			ap+=a[n];
			bp+=b[n];
		}
	}
	cout<<ap<<" "<<bp<<endl;
}

return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int n;
	while(cin >> n,n){
		int a,b,ar = 0,br = 0;
		while(n--){
			cin >> a >> b;
			ar += a>b?a+b:0;
			br += b>a?a+b:0;
		}
		cout << ar << " " << br << endl;
	}
}

C++: #include <stdio.h>

int main(void)
{

	int n;
	int a=0,b=0;
	int ac,bc;

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

	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
	int n;
	int a,b;
	int sa=0,sb=0;//score
	
	
	while(cin>>n&&n!=0){
	for(int i=0;i<n;i++)
	{
		cin>>a>>b;
		if(a<b){sb+=(a+b);}
		else if(a>b){sa+=(a+b);}
		else
		{
			sa+=a;
			sb+=b;
		}
	}
	cout<<sa<<" "<<sb<<"\n";
	}
	return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  long long n,a,b,x=0,y=0;
  cin>>n;
  rep(i,n){
    cin>>a>>b;
    if(a==b){
      x+=a;
      y+=b;
    }
    else if(a==max(a,b))x+=a+b;
    else if(b==max(a,b))y+=a+b;
  }
  cout<<x<<" "<<y<<endl;
}

C++: #include<stdio.h>
int a, b;
int main()
{
	int c,d=0,e=0;
	scanf("%d", &c);
	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);
}

C++: #include <iostream>

void Game(int round, std::istream& in, std::ostream& out)
{
    int scoreA = 0;
    int scoreB = 0;
    for(int i = 0; i < round; ++i){
        int a, b;
        in >> a >> b;
        if(a > b){
            scoreA += a + b;
        }else
        if(a < b){
            scoreB += a + b;
        }else{
            scoreA += a;
            scoreB += b;
        }
    }
    out << scoreA << " " << scoreB;
}

int main()
{
    int n;
    std::cin >> n;
    while(n){
        Game(n, std::cin, std::cout);
        std::cin >> n;
    }
    return 0;
}

C++: #include <iostream>
int main()
{

	while (1) {
		int card;
		std::cin >> card;
		if (card == 0) {
			break;
		}
		int a[10000], b[10000];
		int ascore = 0, bscore = 0;
		for (int i = 0; i < card; i++) {
			std::cin >> a[i] >> b[i];
			if (a[i] > b[i]) {
				ascore = ascore + (a[i] + b[i]);
			}
			else if (b[i] > a[i]) {
				bscore = bscore + (a[i] + b[i]);
			}
			else {
				ascore = ascore + a[i];
				bscore = bscore + b[i];
			}
		}
		std::cout << ascore << " " << bscore << std::endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
  int n;
  while(1){
    cin>>n;
    if(!n)break;
    int a,b;
    int apoint=0,bpoint=0;
    rep(i,n){
      cin>>a>>b;
      if(a==b){
	apoint+=a;
	bpoint+=b;
      }else if(a>b){
	apoint+=(a+b);
      }else{
	bpoint+=(a+b);
      }
    }
    cout<<apoint<<" "<<bpoint<<endl;
  }
  return 0;
}