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.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n, a, b;
    int as = 0, bs = 0;
    cin >> n;
    rep(i,n){
        cin >> a >> b;
        if(a > b){
            as += (a + b);
        }else if(a < b)
            bs += (a + b);
        else{
            as += a;
            bs += b;
        }
    }
    cout << as << ' ' << bs << endl;
}

C++: #include<cstdio>

int main(void){
	int n,i,j,k,m=0;
	int a[10000],b[10000];
	int x[5]={0},y[5]={0};
	while(true){
		scanf("%d",&n);
		if(n==0)break;
		
		for(i=0;i<n;i++){
			scanf("%d%d",&a[i],&b[i]);
			if(a[i]>b[i]){
				x[m]=x[m]+a[i]+b[i];
			}else if(a[i]<b[i]){
				y[m]+=a[i]+b[i];
			}else{
				x[m]+=a[i];
				y[m]+=b[i];
			}
		}
		
		
		m++;
	}
	
	for(i=0;i<m;i++){
		printf("%d %d\n",x[i],y[i]);
	}
		
	return 0;
}

C++: #include<iostream>

using namespace std;
#define MAX_N 10000

int N;//カードの枚数
int A[MAX_N],B[MAX_N];
int PA[MAX_N],PB[MAX_N];
int Cou = 0;//何回目の勝負か記憶しておく

int main(){
  while(true){
  scanf("%d",&N);//配られるカードの枚数
  if(N==0)
    break;
  for(int i = 0;i < N;i++){
    scanf("%d %d",&A[i],&B[i]);
    if(A[i] > B[i])
      PA[Cou] += A[i]+B[i];
    else if(A[i] < B[i])
      PB[Cou] += A[i]+B[i];
    else{
      PA[Cou] += A[i];
      PB[Cou] += B[i];
    }
  }
  Cou++;
  }
  for(int j = 0;j < Cou;j++){
      printf("%d %d\n",PA[j],PB[j]);
  }
  return 0;
 
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for (int i =0; i < (n); ++i)
using namespace std;

int main() {
        int N;
        cin >> N;
        while (N != 0) {
                int A, AT = 0;
                int B, BT = 0;

                rep(n, N) {
                        cin >> A >> B;
                        if (A == B) {
                                AT += A;
                                BT += B;
                        } else {
                                if (A > B) {
                                        AT += A + B;
                                } else {
                                        BT += A + B;
                                }
                        }
                }
                cout << AT << " " << BT << endl;
                cin >> N;
        }

        return 0;
}

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

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>
int main(){int n,a=0,b=0,c,d;while(std::cin>>n){if(!n)return 0;while (n--){std::cin >> c >> d;if(c>d)a+=c+d;if(c==d){a+=c;b+=c;}if(c<d)b+=c+d;}printf("%d %d\n",a,b);}}

C++: 
#include <stdio.h>

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

C++: #include <stdio.h>


int main()
{

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

	scanf("%d", &n);

	for(int i = 0; i < n; i++){
		
		scanf("%d %d", &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 <bits/stdc++.h>
using namespace std;
int main(){
    while(true){
        int n,asscore=0,bsscore=0;
        cin >> n;
        if(n == 0){break;}
        vector<int> ascard(n);
        vector<int> bscard(n);
        for(int i = 0; i < n ; ++i){
            cin >> ascard.at(i) >>bscard.at(i);
            if(ascard.at(i) > bscard.at(i)){
                asscore = asscore + ascard.at(i) + bscard.at(i);
            }
            if(ascard.at(i) == bscard.at(i)){
                asscore = asscore + ascard.at(i);
                bsscore = bsscore + bscard.at(i);
            }
            if(ascard.at(i) < bscard.at(i)){
                bsscore = bsscore + ascard.at(i) + bscard.at(i);
            }
        }
        cout << asscore << " " << bsscore << endl;
    }
}

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

int main() {
	int num;
	int score_a = 0;
	int score_b = 0;
	int cnt = 0;
	
	cin >> num;
	while ((num != 0) && (cnt < 5)) {
		for (int i = 0; i < num; i++) {
			int a;
			int b;

			cin >> a >> b;
			if (a > b) {
				score_a += a + b;
			}else if (b > a) {
				score_b += a + b;
			}else {
				score_a += a;
				score_b += b;
			}
		}
		cout << score_a << " " << score_b << endl;
		score_a = 0;
		score_b = 0;
		cnt++;
	}

	cnt = 0;
	return 0;
}

C++: #include <cstdio>
using namespace std;
int main()
{
	long long int a=0,b=0,n,x,y;
	scanf("%lld",&n);
	for(long long int i=0;i<n;i++){
		scanf("%lld %lld",&x,&y);
		if(x>y) {a+=x+y;}
		else if(x<y) {b+=x+y;}
		else{
			a+=x;
			b+=y;
		}
	}
	printf("%lld %lld\n",a,b);
	return 0;
}

C++: #include<stdio.h>

int main(){
    int n, i;
    int card[2];
    int result[2];
    result[0] = result[1] = 0;
    scanf("%d",&n);
    for(i=0;i < n;i++){
        card[0] = card[1] = 0;
        scanf("%d %d", &card[0], &card[1]);
        if(card[0] < card[1]) result[1] += card[0] + card[1];
        else if(card[0] > card[1]) result[0] += card[0] + card[1];
        else{
            result[0] += card[0];
            result[1] += card[1];
        }
    }
    printf("%d %d\n", result[0], result[1]);
    return 0;
}

C++: #include <stdio.h>

int main()
{
	int n,total[2],in[2];

	while( scanf("%d",&n) && n ){
		total[0] = 0; total[1] = 0;
		for(int i = 0; i < n; i++){
			scanf("%d %d",&in[0],&in[1]);
			if(in[0] > in[1]){
				total[0] += in[0]+in[1];
			}
			else if(in[1] > in[0]){
				total[1] += in[0]+in[1];
			}
			else{
				total[0] += in[0];
				total[1] += in[1];
			}
		}
		printf("%d %d\n",total[0],total[1]);
	}

	return 0;
}

C++: #include <iostream>

int main(){
  int n;

  while(std::cin >> n, n){
    int A_point=0,B_point=0;
    int A_card,B_card;
    while(n--){
      std::cin >> A_card >> B_card;
      if(A_card > B_card){
        A_point += A_card + B_card;
      }else if(A_card < B_card){
        B_point += A_card + B_card;
      }else{
        A_point += A_card;
        B_point += B_card;
      }
    }
    std::cout << A_point << " " << B_point << std::endl;
  }

  return 0;
}