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 <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iostream>

using namespace std;

class Player
{	friend class Batler;
	vector<int> card;
	int point;
public:
	Player():point(0){}
};
class Batler
{
	Player *p1, *p2;
public:
	Batler(Player *P1, Player *P2):p1(P1),p2(P2){}

	void init();
	void input();
	void start();
};
void Batler::init()
{
	if(!p1->card.empty()){
		p1->card.clear();
		p2->card.clear();
	}
	p1->point = 0;
	p2->point = 0;
}
void Batler::input()
{
	int buf;
	cin>>buf;
	p1->card.push_back(buf);
	cin>>buf;
	p2->card.push_back(buf);
}
void Batler::start()
{
	for(unsigned int i = 0; i < p1->card.size(); i++){
		if( p1->card[i] > p2->card[i]){
			p1->point += p1->card[i] + p2->card[i];
		}else if( p1->card[i] < p2->card[i] ){
			p2->point += p1->card[i] + p2->card[i];
		}else{
			p1->point += p1->point;
			p2->point += p2->point;
		}
	}
	cout<<p1->point<<" "<<p2->point<<endl;
}
int main()
{
	int n;
	Player p1, p2;
	Batler batle(&p1,&p2);

	while(1){
		batle.init();
		cin>>n;
		if(!n) break;

		//üÍ
		for(int i = 0; i < n; i++){
			batle.input();
		}
		//ð
		batle.start();
	}
}

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

int main()
{
  int n;
  int j, k;
  int suma, sumb;
  
  suma = sumb = 0;
  cin >> n;
  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>

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

int main() {
    int n;
    while (std::cin >> n && n) {
        int sc1 = 0, sc2 = 0;
        rep(i, n) {
            int p1, p2;
            std::cin >> p1 >> p2;
            if (p1 == p2)
                sc1 += p1, sc2 += p2;
            else if (p1 > p2)
                sc1 += p1 + p2;
            else
                sc2 += p1 + p2;
        }
        std::cout << sc1 << ' ' << sc2 << std::endl;
    }
}

C++: #include <iostream>

using namespace std;

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

C++: #include <stdio.h>
int n,i,j,k;
int A[1]={0},B[1]={0};
int main(){
  for(;;){
    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<iostream>
using namespace std;
int main(){
	int n = 0;
	int p[10][2];
	int a = 0;
	int b = 0;
	cin >> n;
	for (int i = 0; i < n; i++){
		if (n == 0){
			break;
		}
		for (int j = 0; j < 2; j++){
			cin >> p[i][j];
		}
		if (p[i][0] == p[i][1]){
			a = a + p[i][0];
			b = b + p[i][1];
		}
		else if (p[i][0] < p[i][1]){
			b = b + p[i][0] + p[i][1];
		}
		else if (p[i][0] > p[i][1]){
			a = a + p[i][0] + p[i][1];
		}
	}
	cout << a << " " << b << endl;
	return 0;
}

C++: #include <cstdio>

int n,an,bn,i,j;
int a[10000],b[10000];
int main (){
	scanf("%d\n",&n);
	an=0;
	bn=0;
	for (i=0;i<n;i++){
		scanf("%d %d",&a[i],&b[i]);
	}
	for(j=0;j<n;j++){
		if(a[j]>b[j]) an=an+(a[j]+b[j]);
		else if(a[j]<b[j]) bn=bn+(a[j]+b[j]);
		else if (a[j]==b[j]) { 
			an=an+a[j];
			bn=bn+b[j];
		}
	}
	printf("%d %d\n",an,bn);
	return 0;
}

C++: #include <stdio.h>

int N ;
int a ;
int b ;
int point[2] ;

void init ( ) ;

int main ( )
{
	while ( scanf ( "%d" , &N ) == 1 && N ) {
		init ( ) ;
		for ( int i = 0 ; i < N ; i++ ) {
			scanf ( "%d %d" , &a , &b ) ;
			if ( a > b ) {
				point[0] += ( a + b ) ;
			}
			else if ( a == b ) {
				point[0] += a ;
				point[1] += b ;
			}
			else {
				point[1] += ( a + b ) ;
			}
		}
		printf ( "%d %d\n" , point[0] , point[1] ) ;
	}
	return 0 ;
}

void init ( )
{
	point[0] = point[1] = 0 ;
}

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

struct player{
    int point;
    int card[10000];
    inline 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];
            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 <cstdio>
using namespace std;
int main()
{
	int a=0,b=0,n,x,y;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d %d",&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 <cstdio>
using namespace std;
int n,a[10000],b[10000],x,y;
int main()
{
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%d %d",&a[i],&b[i]);
}
for(int i=0;i<n;i++){
if(a[i]==b[i]){x+=a[i]; y+=b[i];}
if(a[i]>b[i]) x+=a[i]+b[i];
if(a[i]<b[i]) y+=a[i]+b[i];
}
printf("%d %d",x,y);
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main()
{
int x=1;
while(x!=0){
int n;
cin >> n;
if(n==0)return 0;
int x,y,ans1=0,ans2=0;
for(int i=0;i<n;i++){
cin >> x >> y;
if(x>y)ans1+=(x+y);
else if(x<y)ans2+=(x+y);
else{
ans1+=x;
ans2+=y;
}
}
printf("%d %d\n",ans1,ans2);
}
return 0;
}

C++: #include <bits/stdc++.h>
#define fo(i,a) for(i = 0;i < a;i++)
using namespace std;
int main(void)
{
	int n,a=0,b=0,x,y,i;
	
	cin >> n ;
	fo(i,n){
		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 ;
	
	return 0;
}

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

C++: #include<stdio.h>

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

C++: #include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	int i,j,n,s,m,a=0,b=0;
	cin>>s;
	for(i=1;i<=s;i++)
	{
		cin>>n>>m;
		if(n>m)a=a+n+m;
		else if(n<m)b=b+n+m;
		else
		{
			a=a+n;
			b=b+m;
		}
	}
	cout<<a<<" "<<b;
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
   int sam1=0,sam2=0,a,b,n;

   cin >> n;
   for(int i=0;i<n;i++){
	cin >> a >> b;

	if(a>b){
		sam1 += a+b;
	}else if(b>a){
		sam2 += a+b;
	}else if(a == b){
		sam1 += a;
		sam2 += b;
	}
   }

   cout << sam1 << " " << sam2 << endl;

   return 0;
}