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>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;


int main(){
	int n;
	int ary1[10100];
	int ary2[10100];

	while (cin >> n, n != 0) {
		int sum1 = 0, sum2 = 0;
		for (int i = 0; i < n; i++) {
			cin >> ary1[i] >> ary2[i];
		}

		for (int i = 0; i < n; i++) {
			if (ary1[i] > ary2[i]) {
				sum1 += (ary1[i] + ary2[i]);
			}
			else if (ary1[i] < ary2[i]) {
				sum2 += (ary1[i] + ary2[i]);
			}
			else {
				sum1 += ary1[i];
				sum2 += ary2[i];
			}
		}

		cout << sum1 << " " << sum2 << endl;
	}

	return 0;
}

C++: #include "stdafx.h"
#include <iostream>

int A[10000], B[10000];

int main()
{
	int n, a, b;
	std::cin >> n;
	while (n != 0)
	{
		a = 0; 
		b = 0;
		for (int i = 0; i < n; i++)
		{
			std::cin >> A[i] >> B[i];
			if (A[i] > B[i])
			{
				a += A[i] + B[i];
			}
			if (A[i] == B[i])
			{
				a += A[i];
				b += B[i];
			}
			if (A[i] < B[i])
			{
				b += B[i];
			}
		}
		std::cout << a << " " << b << std::endl;
		std::cin >> n;
	}
    return 0;
}

C++: #include <algorithm>
#include <cstdio>
#include <functional>

using namespace std;

int main(){
    
   return 0;

}

C++: #include<stdio.h>
int main(){
  int n,a,b,ap=0,bp=0;
  int i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d",&a,&b);
    if(a>b){
      ap+=a+b;
    }
    if(a<b){
      bp+=a+b;
    }
    if(a==b){
      ap+=a;
      bp+=b;
    }
  }
  printf("%d %d\n",ap,bp);
  return(0);
}

C++: #include <stdio.h>
int n,i,j,k;
long int A[1],B[1];
int main(){
  scanf("%d",&n);
  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("%ld %ld\n",A[0],B[0]);
  return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	while(n!=0){
		int point[2];
		enum {
			A,
			B,
		};
		int sum[2] = {};
		for (int i = 0; i < n; i++) {
			cin>>point[A]>>point[B];
			if (point[A]>point[B]) {
				for (auto j : point) {
					sum[A]+=j;
				}
			} else if(point[A] == point[B]) {
				for (auto j : sum) {
					j+=point[A];
				}
			} else {
				for (auto j : point) {
					sum[B]+=j;
				}
			}
		}
		cout<<sum[A]<<" "<<sum[B]<<endl;
		cin>>n;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <stack>

using namespace std;

int main(){
	stack<int> st;
	int k;
	int i,j;
	int result;
	char c;
	while(scanf("%c", &c) != EOF){
		if(c == ' ' || c == '\n'){
		} else if(c == '+'){
			i = st.top();
			st.pop();
			j = st.top();
			st.pop();
			result = i + j;
			st.push(result);

		} else if ( c == '-'){
			i = st.top();
			st.pop();
			j = st.top();
			st.pop();
			result = j - i;
			st.push(result);

		} else if ( c == '*'){
			i = st.top();
			st.pop();
			j = st.top();
			st.pop();
			result = i * j;
			st.push(result);

		} else {
			k = (int)(c - '0');
			st.push(k);
		}
	}
	cout << st.top() << endl;
}

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; j < n; j++) {
      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>
using namespace std;

int main(){
int a=0;
int uma=0;
int ushi=0;
int b=0;
int c=0;
int i=0;
while (true){
cin >> a;
if (a == 0){ break; }
else{
	while (true){
	if (i<a){
	cin >> b;
	cin >> c;
	if (b>c){
		uma = uma + b + c;
	}
	if (b == c){
		uma = uma + b;
		ushi = ushi + c;
	}
	else{
	ushi = ushi + b + c;
	}
	i = i + 1;
}if (i == a){ break; }
}
cout << uma << " " << ushi << endl;
uma = 0;
ushi = 0;
i = 0;
}
}
}

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

int main(){

    int a,b,acard,bcard,match;

    while(1){

      a = b = 0;

      cin >> match;

      if(match == 0){
        break;
      }



      for(int i=0;i < match; i++){
        cin >> acard >> bcard;
        if(acard > bcard){
          a += acard+bcard;
        }
        else if(acard < bcard){
          b += acard+bcard;
        }
        else{
          a += acard;
          b += bcard;
        }
      }

      cout << a << ' ' << b << endl;

    }


    return 0;
}

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

int main() {
		int n;
		int a;
		int b;
	while( true ){
		int sa=0;
		int sb=0;
		cin >> n;
		
		if(n == 0){
			return 0;
		}
		for(int i=0;i<n;i++){
			cin >> a >> b;
			if(a>b){
				sa+=a+b;
			}else{
				if(a<b){
				sb+=a+b;	
				}else{
					sa+=a;
					sb+=b;
				}
			}
		}
		cout << sa << " " << sb << endl;
	}
}

C++: #include<iostream>
using namespace std;
int main(){
	while(true){
  int a=0,b=0,N,Card[2];
  cin >> N;
  if(N==0)
 	break;
  for(int i=0;i<N;i++){
  	cin >> Card[0] >> Card[1];
  	int sum=Card[0]+Card[1],truth=(Card[0]>Card[1]);
 	if(Card[0]!=Card[1]){
  	a+=sum*truth;
  	b+=sum*!(truth);
 	}
 	else{
 		a+=sum/2;
 		b+=sum/2;
 	}
  }
  cout << a << " "<< b << endl;
	}
  return 0;
}

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

C++: a,b,c,d;main(n){for(s="%d %d\n";scanf(s+3,&n),n;printf(s,c,d))for(c=d=0;n--;*(a<b?&d:&c)+=a,*(b<a?&c:&d)+=b)scanf(s,&a,&b);}

C++: #include<stdio.h>
int main(void)
{
	int a[101] = { 0 }, b[101] = { 0 }, ruio = 0, hideo = 1, nagase = 0, masako = 0;
	int temp = 0, c[101] = { 0 }, k = 1;
	while (scanf("%d", &ruio) >0) {
		if (ruio == 0)return 0;
		for (int i = 1; i <= ruio; i++) {
			scanf("%d", &a[i]);
			c[a[i]]++;
		}
		hideo = nagase = ruio;
		for (int i = 1; i < ruio; i++) {
			for (int j = ruio; j > i; j--) {
				if (a[j] < a[j - 1]) {
					temp = a[j];
					a[j] = a[j - 1];
					a[j - 1] = temp;
				}
			}
		}
		for (int j = 1; j <= ruio * 2; j++) {
			if (c[j] == 0) {
				b[k] = j;
				k++;
			}
		}
		k = 0;
		while (nagase != 0 && hideo != 0) {
			k++;
			if (masako == 0) {
				masako = a[k];
				nagase--;
			}
			else if (masako < a[k]) {
				masako = a[k];
				nagase--;
			}
			else {
				masako = 0;
			}
			a[k] = 0;
			if (masako == 0) {
				masako = b[k];
				hideo--;
			}
			else if (masako < b[k]) {
				masako = b[k];
				hideo--;
			}
			else {
				masako = 0;
			}
			b[k] = 0;

		}
		printf("%d\n**%d\n**", hideo , nagase);
		for (int i = 1; i <= 100; i++) {
			a[i] = 0;
			b[i] = 0;
			c[i] = 0;
		}
		hideo = nagase = 0;
		masako = temp = 0;
		k = 1;
		
	}
	
}

C++: #include<iostream>

using namespace std;
#define MAX_N 10000

int N;//カードの枚数
int A[MAX_N],B[MAX_N];
  
int main(){
  while(true){
  int PA = 0,PB = 0;//A,Bのそれぞれの得点
  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 += A[i]+B[i];
    else if(A[i] < B[i])
      PB += A[i]+B[i];
  }
  printf("%d %d\n",PA,PB);
  }
  return 0;
 
}