Go: package main

import (
	"fmt"
)

// Game is one game.
type Game struct {
	pointA, pointB int
}

func main() {
	var n int
	game := &Game{0, 0}
	fmt.Scanf("%d", &n)
	for n != 0 {
		game.initGame()
		game.execGame(n)
		game.printResult()
		fmt.Scanf("%d", &n)
	}
}

func (game *Game) execGame(n int) {
	var a, b int
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a)
		fmt.Scanf("%d", &b)
		switch {
		case a == b:
			game.pointA += a
			game.pointB += b
		case a > b:
			game.pointA += a + b
		case b > a:
			game.pointB += a + b
		}
	}
}

func (game *Game) initGame() {
	game.pointA = 0
	game.pointB = 0
}

func (game *Game) printResult() {
	fmt.Println(game.pointA, game.pointB)
}

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;
}

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

int main(void) {
  int n;
  vector<int> A, B;
  int i = 0. j;
  int a, b;
  for(; i < 5; i++) {
    cin >> n;
    if(!n) break;
    A.push_back(0), B.push_back(0);
    for(j = 0; i < n; i++) {
      cin >> a >> b;
      if(a > b) A[i] += a;
      else if(a < b) B[i] += b;
      else A[i] += a, B[i] += b;
  }
  for(int i = 0; i < A.size(); i++) cout << A[i] << " " << B[i] << endl;
}

C++: #include<iostream>
#include<vector>
int main() {
	int i = 0;
	std::cin >> i;
	int A = 0, B = 0;
	std::vector<int> a, b;
	for (int j = 0; j < i; ++j) {
		std::cin >> a[j] >> b[j];
	}
	for (int j = 0; j < i; ++j) {
		if (a[j] > b[j]) {
			A += (a[j] + b[j]);
		}
		else if (a[j] < b[j]) {
			B += (a[j] + b[j]);
		}
		else {
			A += a[j];
			B += b[j];
		}
	}
	std::cout << A << " " << B << std::endl;
	return 0;
}

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

int main () {
    int n, i,A,B, resa =0, resb =0;
    while(cin >> n,n){
        for(i=0;i<n;i++){
           　cin >> A >> B;
             (A > B)? resa +=A:resb+=B;
             if(A==B) {resa += A; resb +=B;};
        }
　　　　cout << resa << " " << resb << endl;
    }
}

C++: #include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)

using namespace std;

int main(){
    while(true){
    int n;
    scanf("%d", &n);
    if(n==0) return 0;
    vector<int> a(n), b(n);
    REP(i, n)  scanf("%d %d", &a[i],&b[i]);
    int as=0, bs=0;
    REP(i,n){
        if(a[i]>b[i])as+=a[i]+b[i];
        else if(a[i]<b[i])bs+=a[i]+b[i];
        else {as+=a[i];bs+=b[i];}
    }
    printf("%d %d\n", as,bs);
    }
}