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<vector>
int main() {
	int i = 0;
	std::cin >> i;
	std::vector <int> ha, hb;
	while (i != 0) {
		int A = 0, B = 0;
		std::vector<int> a(10000), b(10000);
		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];
			}
		}
		ha.push_back(A);
		hb.push_back(B);
		std::cin >> i;
	}
	for (int j = 0; j < i; ++j) {
		std::cout << ha[j] << " " << hb[j] << std::endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  while(cin >> N,N){
    int a,b;
    int ap = 0,bp = 0;
    for(int i = 0;i < N;i++){
      cin >> a >> b;
      if(a < b)bp += a + b;
      else if(a == b){ap += a;bp += b;}
      else ap += a + b;
    }
    cout << ap << " " << bp << endl;
  }
  return 0;
}

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

int main(){

    int a,b,acard,bcard,match;

    a = b = 0;

    cin >> match;

    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;
#define MAX_N 10000

int N;//カードの枚数
int A[MAX_N],B[MAX_N];
  
int PA = 0,PB = 0;//A,Bのそれぞれの得点
int main(){
  scanf("%d",&N);//配られるカードの枚数
  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;
 
}

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

int main(){

	int n, a, b;

	while(cin >> n){
		if( n == 0)break;
		int a_ten = 0, b_ten = 0;
		for(int i = 0; i<n; i++){
			cin >> a >> b;
			if(a == b) {
				a_ten = a_ten + a;
				b_ten = b_ten + b;
			}
			else if (a < b) b_ten = b_ten + a + b;
			else a_ten = a_ten + a + b;
				
		}

		cout << a_ten << " " << b_ten <<endl;
			
	}


	return 0;
}

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

int main(){
	int n,a,b;
	int x,y;
	while(cin>>n&&n){
		x=y=0;
		for(int i=0;i<n;i++){
			cin>>a>>b;
			if(a>b)x+=a+b;
			else if(a<b)y+=a+b;
			else{
				x+=a;
				y+=a;
			}
		}
		cout<<x<<' '<<y<<endl; 
	}
	return 0;
}

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

int main(void){
  int a,b;
  a=b=0;
  int n;
  while(cin>>n,n){
  while(n--){
    int c,d;
    cin>>c>>d;
    if(c>d)
      a += c + d;
    else
      b += c + d; 
  }
  cout<< a << " " << b << endl;
  }
}

C++: #include<stdio.h>
#include<stdlib.h>
#include<iostream>
using namespace std;

int main(){
	int a[10002],b[10002],i,j=0,ans1[10000],ans2[10000];
	int A=0,B=0,n;
	cin>>n;
	while(n!=0){
		for(i=0;i<n;i++){
			cin>>a[i]>>b[i];
		}
		for(i=0;i<n;i++){
			if(a[i]>b[i]){
				A+=(a[i]+b[i]);
			}else if(a[i]<b[i]){
				B+=(a[i]+b[i]);
			}else{
				A+=a[i];B+=b[i];
			}
		}
		ans1[j]=A;ans2[j]=B;
		j++;A=0;B=0;
		cin>>n;
	}
	for(i=0;i<j;i++){
		cout<<ans1[i]<<' '<<ans2[i]<<endl;
	}
	return 0;
}

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

int main(){
	int n, a, b;
	while (true)
	{
		int point_a = 0, point_b = 0;
		cin >> n;
		if (cin.eof()||n==0) { break; }
		for(int i =0;i<n;i++){
			cin >> a >> b;
			if(a==b){
				point_a += a;
				point_b += b;
			}
			else if (a>b){
				point_a += a + b;
			}
			else {
				point_b += a + b;
			}
		}
		cout << point_a << " " << point_b << endl;
	}
}

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

int main(){
 int n;
 int Acard,Bcard,Apoint,Bpoint;
 while(true){
  cin>>n;
  if(n==0){
   break;
  }else{
    for(int i=0;i<n;i++){
     cin>>Acard>>Bcard;
     if(Acard>Bcard){
      Apoint+=Acard+Bcard;
     }else if(Acard<Bcard){
      Bpoint+=Acard+Bcard;
     }else{
      Apoint+=Acard;
      Bpoint+=Bcard;
     }
    }
   cout<<Apoint<<' '<<Bpoint<<'\n';
  }
 }
 return 0;
}

C++: hoge

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

int A = 0, B = 0;

int main(){
    int j;
    cin >> j;
    for(int i = 0; i < j; i++){
        int as, bs;
        cin >> as >> bs;
        if(as > bs){
            A += as + bs;
        }else if(as < bs){
            B += as + bs;
        }else{
            A += as;
            B += bs;
        }
    }
    cout << A << " " << B << endl;
    return 0;
}

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

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

int main()
{	
	int n,a[10000]={},b[10000]={},ascore=0,bscore=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		cin>>b[i];
		if(a[i]>b[i]){
			ascore+=a[i]+b[i];
		}else if(a[i]<b[i]){
			bscore+=a[i]+b[i];
		}else if(a[i]==b[i]){
			ascore+=a[i];
			bscore+=b[i];
		}
	}

	cout<<ascore<<" "<<bscore<<endl;
	return 0;
}

C++: //
//  main.cpp
//  program
//
//  Created by h3032906 on 2016/11/24.
//  Copyright ?? 2016??´ h3032906. All rights reserved.
//

#include <iostream>

int main(int argc, const char * argv[]) {

    int n, a, b;
    int at = 0;
    int bt = 0;
    for( ; ; ){
        std::cin >> n;
        if(n == 0){
            break;
        }
        for(int i = 0; i < n; i++){
            std::cin >> a >> b;
            if(a > b){
                at = at + a + b;
            }
            else if(b > a){
                bt = bt + a + b;
            }
            else {
                at = at + a;
                bt = bt + b;
            }
        }
        std::cout << at << " " << bt << std::endl;
        at = 0;
        bt = 0;
    }
    return 0;
}

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

int main(){
	int n;//何枚ずつのカードを使うか
	cin>>n;
	int a;//aに配られたカード
	int b;//bに配られたカード
	int a_score=0;//Aの得点
	int b_score=0;//Bの得点
	for(int i=0; i<n; i++){
		cin>> a >> b;//a,bに入力させる
		if(a>b) a_score+=a+b;
		else if(b>a) b_score+=a+b;
		else{
			a_score+=a;
			b_score+=b;
		}
	}
	cout<<a_score<<" "<<b_score<<"\n";
	return 0;
}

C++: #include <iostream>
using namespace std;
int main()
{
	int a, e = 0, f = 0, c, d;
	cin >> a;
	for (int b = 0; b < a; b++)
	{
		cin >> c;
		cin >> d;
		if (c > d)
		{
			e += c;
			e += d;
		}
		else if (d > c)
		{
			f += c;
			f += d;
		}
		else
		{
			e += c;
			f += d;
		}
	}
	cout << e << " " << f << endl;
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int time;
	int A,B;
	int carda,cardb;
	A=0;
	B=0;
	while(cin>>time&&time!=0){
		A=0;
		B=0;
		for(int i=0;i<time;++i){
			cin>>carda>>cardb;
			if(carda>cardb){
				A+=carda+cardb;
			}else if(carda<cardb){
				B+=carda+cardb;
			}else{
				A+=carda;
				B+=cardb;
			}
		}
		cout<<A<<' '<<B<<endl;
	}
	return 0;
}