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++: //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;
}

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