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

C++: #include <iostream>

int main(void){
  int n;
  int Acard[10000], Bcard[10000];

  while(1){
    int playerA = 0, playerB = 0;
    std::cin >> n;
    if(n == 0)  return 0;

    for(int i=0; i < n ; i++){
      std::cin >> Acard[i]; std::cin >> Bcard[i];
    }

    for(int i=0; i < n; i++){
      if(Acard[i] == Bcard[i]){
        playerA += Acard[i];  playerB += Bcard[i];
      }else if(Acard[i] > Bcard[i]){
        playerA += Acard[i] + Bcard[i];
      }else{
        playerB += Acard[i] + Bcard[i];
      }
    }

    std::cout << playerA << " " << playerB << std::endl;
  }
}

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

int main() {
	int n,a,b,x=0,y=0;
	for(int q=0;q==q;q++){
	n=0,x=0,y=0;
	cin>>n;
	if(n==0)break;
	for(int t=0;t<n;t++){
		cin>>a;
		cin>>b;
		if(a>b){
			x+=a+b;
		}
		else if(a==b){
			x+=a;
			y+=b;
	}
		else {
			y+=a+b;
	}
		
	}
	cout<<x<<' '<<y<<'\n';
	}
	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  << "\n" << endl;
	return 0;
}

C++: #include <stdio.h>

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

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

struct player{
    int point ;
    int card[10000];
private:
  void player(){point =0;}
};

int main()
{
    int loop;
    player a, b;
    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];
        if(a.card[c] == b.card[c]) a.point += a.card[c], b.point +=b.card[c];
        if(a.card[c] > b.card[c]) a.point += a.card[c] + b.card[c];
    }
    cout << a.point << " " << b.point << endl;
    return EXIT_SUCCESS;
}

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

C++: #include<iostream>

using namespace std;
int main() {
	
	int n;
	while( cin >> n && n != 0 ) {
		
		int A[2] = {};
		
		for(int i=0;i<n;i++) {
		
		int a, b;
		cin >> a >> b;
		
		if( a > b)
		A[0] += ( a + b );
		
		if( a == b) {
		A[0] += a; 
		A[1] += b;
		
	}
		if( a < b)
		A[1] += ( a + b);
		
}
		cout << A[0] << " " << A[1] << "\n";
	}
	
	return 0;
}

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

int main()
{
  int n;
  int j, k;
  int suma, sumb;
  
  
  while (cin >> n){
    if (n == 0){
      break;
    }
    suma = sumb = 0;
    for (int i = 0; i < n; i++){
      cin >> j >> k;

      if (j < k){
        sumb += j + k;
     }
      else if (j > k){
        suma += j + k;
      }
     else {
        suma += j;
       sumb += k;
      }
    }
   cout << suma << " " << sumb << endl;
  }
  return 0;
}

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

int main()
{
	int n;
	while(cin>>n,n){
	int A=0,B=0;
	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<<"\n";
	}
	return 0;
}

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

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

using namespace std;

int main(){
        while(true){
                int pa = 0, pb = 0       
                int a, b
                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<stdio.h>
int main(){
for(;;){
	int ap=0,bp=0,a,b,t,d;
	scanf("%d",&d);
	if(d==0)
	break;
	for(t=0;t<d;t++){
		scanf("%d %d",&a,&b);
		if(a==b){
			ap+=a;
			bp+=b;
		}
		else if(a<b)
		bp+=a+b;
		else
		ap+=a+b;
	}
	printf("%d %d\n",ap,bp);
}
return 0;
}

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

C++: #include<iostream>
using namespace std;
int main(){
int n;
int a,b,ap,bp;
while(cin>>n){
ap=0;
bp=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;
}

return 0;
}

C++: #include <iostream>
using namespace std;
 
int main()
{
  int i, 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;
}

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

C++: #include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int a[200000];
int b[200000];
int main(){
    int n;
    scanf("%d",&n);
    REP(i,n)
        scanf("%d%d",a + i,b + i);

    int ap = 0,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];
        }
    }
    printf("%d %d\n",ap,bp);
    return 0;
}