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

C++: //Volume5 -> 0501

#include <iostream>
#include <vector>
//#include <math.h>
//#include <string>
#include <cmath>
#include <iomanip>

int main();

int main(){
	std::vector<int> totalAPoint;		//Aの得点
	std::vector<int> totalBPoint;		//Bの得点
	int dataSetCount = 0;				//ゲーム数

	while (1){
		int n = 0;		//1ゲームの入力数

		std::cin >> n;
		//n=0で終了
		if (n == 0){
			break;
		}

		dataSetCount++;

		int aPoint = 0;		//1ゲームにおけるAの得点
		int bPoint = 0;		//1ゲームにおけるBの得点

		for (int i = 0; i < n; i++){
			int tempA;
			int tempB;

			std::cin >> tempA >> tempB;
			if (tempA > tempB){
				aPoint += (tempA + tempB);
			}
			else if (tempA < tempB){
				bPoint += (tempA + tempB);
			}
			//引き分け
			else{
				aPoint += tempA;
				bPoint += tempB;
			}
		}

		totalAPoint.push_back(aPoint);
		totalBPoint.push_back(bPoint);
	}

	//結果出力
	for (int i = 0; i < dataSetCount; i++){
		std::cout << totalAPoint[i] << " " << totalBPoint[i] << std::endl;
	}

	//while (1);
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){

	int n, a, b, ap = 0, bp = 0;

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

		//?????°?????´??°
		if (a > b)
			ap += a + b;
		else if (a < b)
			bp += a + b;
		else{
			ap += a;
			bp += b;
		}
	}

	cout << ap << ' ' << bp << endl;
}