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

using namespace std;

int main(void){
    // Your code here!
    while(true){
        int N;
        cin >> N;
        if(N == 0){
            break;
        }
        int sumA = 0;
        int sumB = 0;
        for(int i=0;i<N;i++){
            int A,B;
            cin >> A >> B;
            if(A > B){
                sumA += A + B;
            }else if(A < B){
                sumB += A + B;
            }else{
                sumA += A;
                sumB += B;
            }
        }
        cout << sumA << " " << sumB << endl;
    }
    return 0;
}

C++: #include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
    int a,b;
    int input;
    while(1)
    {
        scanf("%d",&input);
        if(input == 0) break;
        int suma = 0;
        int sumb = 0;
        for(int i = 0;i < input;i++)
        {
            scanf("%d%d",&a,&b);
            if(a>b)
            {
                suma = suma +a +b;
            }
            else if(b>a)
            {
                sumb = sumb +a +b;
            }
            else if(a == b)
            {
                suma = suma+a;
                sumb += sumb+b;
            }
        }
        suma = suma+'0';
        sumb = sumb+'0';
        printf("%c %c\n",suma,sumb);
    }
    return 0;
}

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

using namespace std;

int main()
{
	int n, a, b, as, bs;

	while (cin >> n, n){
		as = 0;
		bs = 0;
		for (int i = 0; i < n; i++){
			cin >> a >> b;
			if (a == b){
				as += a;
				bs += b;
			}
			else if (a == max(a, b)) as += a + b;
			else if (b == max(a, b)) bs += a + 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(1) {
        loop = 0;
        cin >> loop;
        if(loop == 0) break;
        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<iostream>
using namespace std;
int main(){
	int n;
	int a,b;
	int A,B;
	while(true){
		cin>>n;
			if(n==0){break;}
	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++: #define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)c.size())

typedef unsigned long long ull;
const int INF = (int)1e8;

int main(){
	int n;
	while(cin>>n,n){
		int a=0,b=0;
		FOR(i,n){
			int x,y; cin>>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<iostream>
#include<vector>
int main(){
int n;
int s=0;
int g=0;
std::cin>>n;
std::vector<int> a(n),b(n);
for(int i=0;i<n;++i){
std::cin>>a[i]>>b[i];
if(a[i]>b[i]) g+=a[i];
else s+=b[i];
}
std::cout<<" "<<std::endl;
std::cout<<g<<" "<<s<<std::endl;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

int n, a, b;

int main(){
	while (cin >> n){
		int	suma = 0, sumb = 0;
		REP(i, n){
			cin >> a >> b;
			if (a > b){
				suma += a + b;
			}
			else if (a < b){
				sumb += a + b;
			}
			else {
				sumb += b;
				suma += a;
			}
		}
		cout << suma << " " << sumb << endl;
	}
}

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

C++: #include<iostream>

using namespace std;
main(){
  int n,s1,s2;
  int a,b;
  cin>>n;
  while(n!=0){
    s1=s2=0;
    for(int i=0;i<n;i++){
      cin>>a>>b;
      if(a>b)
	s1+=(a+b);
      else if(a<b)
	s2+=(a+b);
      else{
	s1+=a;
	s2+=a;
      }

    }
    cout<<s1<<" "<<s2<<endl;
    
    cin>>n;
  }
  return 0;
}

C++: #include <stdio.h>

int main(void)
{
	int ans_a, ans_b;
	int n;
	int a, b;
	
	while (1){
		scanf("%d", &n);
		if (n == 0){
			break;
		}
	ans_a = ans_b = 0;
	while (n){
		scanf("%d %d", &a, &b);
		
		if (a > b){
			ans_a += (a + b);
		}
		else if (a < b){
			ans_b += (a + b);
		}
		else {
			ans_a += a;
			ans_b += b;
		}
		
		n--;
	}
	
	printf("%d %d\n", ans_a, ans_b);
	
	return (0);
}

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

int main(void)
{
	int n;
	int a,b;
	int asum,bsum;
	while(1)
	{
		cin >> n;
		if(n == 0)
			return 0;
		asum=0;bsum=0;
		for(int i=0;i<n;i++)
		{
			cin >> a >> b;
			if(a>b)
			{
				asum=asum+a+b;
			}
			if(b>a)
				bsum=bsum+a+b;
			if(a==b)
			{
				asum+=a;
				bsum+=b;
			}
		}
		cout << asum << ' ' << bsum << endl;
	}
	return 0;
}

C++: #include <stdio.h>

int main(){
	long long Right_Point = 0;
	long long Left_Point = 0;

	int Right_Card, Left_Card;

	int kaisuu;

	while (1){
		Right_Point = 0;
		Left_Point = 0;
		scanf("%d", &kaisuu);
		if (kaisuu == 0){
			break;
		}
		for (int a = 0; a < kaisuu; a++){
			scanf("%d%d", &Right_Card, &Left_Card);
			if (Right_Card == Left_Card){
				Right_Point += Right_Card;
				Left_Point += Left_Point;
			}
			else if (Right_Card < Left_Card){
				Left_Point = Left_Point + (Right_Card + Left_Card);
			}
			else
				Right_Point = Right_Point + (Right_Card + Left_Card);
		}
		printf("%d %d\n", Right_Point, Left_Point);
	}
	return 0;
}

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