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

int N;
int C[10000][2];

void solve() {
  int a = 0;
  int b = 0;
  for (int i = 0; i < N; i++) {
    int ac = C[i][0];
    int bc = C[i][1];
    if (ac > bc) {
      a += ac + bc;
    } else if (ac < bc) {
      b += ac + bc;
    } else {
      a += ac;
      b += bc;
    }
  }
  printf("%d %d\n", a, b);
}

int main() {
  for (;;) {
    scanf("%d", &N);
    if (N == 0) { break; }

    for (int i = 0; i < N; i++) {
      scanf("%d%d", &C[i][0], &C[i][1]);
    }
    solve();
  }
}

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

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

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

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

int main(){
    const int MAX_N = 10000;
    int n;
    int a[MAX_N];
    int b[MAX_N];
    int aPoint=0;
    int bPoint=0;
    
    
    while(true){
        cin >> n;
        if(n==0){
            break;
        }
        for(int i=0;i<n;i++){
            cin >> a[i];
            cin >> b[i];
            if (a[i] > b[i]){
                aPoint += a[i]+b[i];
            }else if (a[i]<b[i]){
                bPoint += a[i]+b[i];
            }else{
                aPoint += a[i];
                bPoint += b[i];
            }
        }
        cout << aPoint << " ";
        cout << bPoint << "\n";
        aPoint = 0;
        bPoint = 0;
    }
}

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

int main()
{
 int t,aa,ab,ba,bb,ca,cb,pa,pb;
 cin>>t;
 cin>>aa>>ab;
 cin>>ba>>bb;
 cin>>ca>>cb;
 
 t=3;pa=0;pb=0;
 
 if(aa>ab){pa=pa+aa+ab;}
 if(aa<ab){pb=pb+aa+ab;}
 if(aa==ab){pa=pa+aa;pb=pb+ab;}

 if(ba>bb){pa=pa+ba+bb;}
 if(ba<bb){pb=pb+ba+bb;}
 if(ba==bb){pa=pa+ba;pb=pb+bb;}
 
 if(ca>cb){pa=pa+ca+cb;}
 if(ca<cb){pb=pb+ca+cb;}
 if(ca==cb){pa=pa+ca;pb=pb+cb;}

 cout<<pa<<" "<<pb<<'\n';

 return 0;
}

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


int main(){

    int n;
    int apt=0,bpt=0;
    int a[10000]={0};
    int b[10000]={0};
    cin >> n;
    for(int i=0; i < n; i++){
        cin >>a[i];
        cin >>b[i];
    }
    for(int i=0; i < n; i++){
        if(a[i]>b[i])apt+=a[i]+b[i];
        else if(a[i]<b[i])bpt+=a[i]+b[i];
        else apt+=a[i],bpt+=b[i];
        }
    cout<<apt<<' '<<bpt<<endl;
}

C++: #include <iostream>
using namespace std;
int main()
{
	int a = 1, e = 0, f = 0, c, d;
	while (1)
	{
		cin >> a;
		if (a != 0)
		{
			break;
		}
		e = 0;
		f = 0;
		for (int b = 0; b < a; b++)
		{
			cin >> c;
			cin >> d;
			if (c > d)
			{
				e += c;
				e += d;
			}
			else if (d > c)
			{
				f += c;
				f += d;
			}
			else
			{
				e += c;
				f += d;
			}
		}
		cout << e << " " << f << endl;
	}
	return 0;
}

C++: #include <stdio.h>

const int MAX_N=10000;
int a[MAX_N];
int b[MAX_N];
int n;
int A,B;
void solve(){
	for(int i=0;i<n;i++){
		if(a[i]>b[i]){
			A+=a[i]+b[i];
		}
		else if(a[i]<b[i]){
			B+=a[i]+b[i];
		}
	}
}
int main(){
 while(1){
         A=0;
         B=0;
	scanf("%d",&n);
	if(n==0){
		break;
	}
	for(int i=0;i<n;i++){
	scanf("%d%d",&a[i],&b[i]);
	}
	solve();
	printf("%d %d\n",A,B);
 }
   return 0;
}

C++: #include<string>
#include<vector>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<sstream>
#include<functional>
#include<map>
#include<stack>
#include<set>
#include<cmath>

#define REP(i,s,e) for(int i=int(s);i<int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)

#define EPS 1e-6

using namespace std;

int main(){

	int n,a,b;

	while(true){

	cin >> n;

	if(n==0) break;

	int p=0; int q=0;
	rep(i,n){

	cin >> a >> b;

	if(a>b) p+=a+b;
	else if(a<b) q+=a+b;
	else{ p+=a; q+=b; }

	}

	cout << p << " " << q << endl;

	}

    return 0;

}

C++: #include<cstdio>
main(){
	int n;
	while(scanf("%d",&n),n){
		int a,b,c = 0,d = 0;
		while(n--)
			scanf("%d%d",&a,&b);c+=a>b?a+b:a==b?a:0;d+=b>a?a+b:a==b?b:0;
		printf("%d %d\n",c,d);
	}
}

C++: #include<iostream>

using namespace std;

int main(){
  
  int n;
  while(cin >> n && n>0){
  int a,b;
  int res_a=0,res_b=0;
  for(int i=0;i<n;i++){
    cin >> a >> b;
    if(a>b) res_a+=(a+b);
    else if(a<b) res_b+=(a+b);
    else{res_a+=a;res_b+=b;}
  }
  cout << res_a << res_b << endl;
}
}

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

int main()
{

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

	cin >> n;

	while(n > 0){
		n--;
		cin >> 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<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;
            }
        }
        printf("%d %d\n",suma,sumb);
    }
    return 0;
}

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

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

C++: #include<iostream>
int main() {
	int vec=0;
	int n;
	int a=0;
	int b=0;
	int game_a, game_b;
	while (1) {
		std::cin >> n;
		if (n == 0)break;
		else {
			for (int i = 0; i < n; ++i) {
				std::cin >> game_a>>game_b;
				if (game_a == game_b) { a += game_a; b += game_b; }
				else if (game_a > game_b)a += game_a + game_b;
				else b += game_a + game_b;
			}
			std::cout << a<<" "<<b<< std::endl;
		}
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	while (true){
		int n, A[10000] = {}, B[10000] = {}, tenA = 0, tenB = 0;
		cin >> n;
		if (n == 0) break;
		for (int i = 0; i < n; i++){
			cin >> A[i] >> B[i];
			if (A[i] > B[i]){
				tenA += A[i] + B[i];
			}
			if (A[i] == B[i]){
				tenA += A[i];
				tenB += B[i];
			}
			if (A[i] < B[i]){
				tenB += A[i] + B[i];
			}
		}
		cout << tenA << ' ' << tenB << endl;
		return 0;
	}
}

C++: #include <iostream>

using namespace std;

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