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>
using namespace std;

int A = 0, B = 0, j;

int main(){
    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>
int A,B;int main(void){using namespace std;int n,C,D;while(1){cin>>n;if(!n)break;A=0;B=0;for(;n>0;n--){cin>>C;cin>>D;if(C>D){A+=(C+D);}else if(C<D){B+=(C+D);}else{A+=C;B+=D;}}cout<<A<<" "<<B<<endl;}return 0;}

C++: #include <iostream>
using namespace std;
int main(void){
	int n,asum,bsum,a,b;
	while(1){
		asum=0;bsum=0;
		cin>>n;
		if(!n) return 0;
		while(n--){
		cin>>a;
		cin>>b;
			if(a >= b) asum+=a;
			else bsum+=a;
			if(a <= b) bsum+=b;
			else asum+=b;
		}
		cout<<asum<<" "<<bsum<<endl;
		}
}

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;

    while(1){
    cin >> n;
    if(n == 0) break;
    int num[10000][2] = {};
    int score[2] = {};

    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < 2; ++j){
            cin >> num[i][j];
        }
        if (num[i][0] > num[i][1])
        {
            score[0] += num[i][0] + num[i][1];
        } else if (num[i][0] == num[i][1])
        {
            score[0] += num[i][0];
            score[1] += num[i][1];
        } else{
            score[1] += num[i][0] + num[i][1];
        }
    }

    cout << score[0] << " " << score[1] << endl;
    }

    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int n,pointA,pointB;
  int a[10000],b[10000];
  for(n = 1;n != 0;){  
 cout << "n";
 cin >> n;
 if(n != 0){
    pointA = 0; pointB = 0;
  for(int i = 0;i < n;i++){
    cin >> a[i] >> b[i];
  }
  for(int i = 0;i< n;i++){
    
    if(a[i] < b[i]){
      pointB = pointB + a[i] +b[i];
    } else if(a[i] > b[i]){
      pointA = pointA + a[i] +b[i];
    } else if(a[i] == b[i]){
      pointA = pointA + a[i];
      pointB = pointB + b[i];
    }
  }
 
  cout << pointA << " "<< pointB << endl;
 }
  }
  
  
}

C++: #include<bits\stdc++.h>
using namespace std;
int main(void){
	int n,asum,bsum,a,b,i;
	while(1){
		cin>>n;
		if(n==0)break;
		asum=0; bsum=0;
		for(i=0;i<n;i++){
			cin>>a>>b;
			if(a==b)asum+=a,bsum+=b;
			if(a>b)asum+=a+b;
			if(b>a)bsum+=a+b;
		}
		cout<<asum<<' '<<bsum<<endl;
	}
	return 0;
}

C++: #define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

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

C++: #include<iostream>
#include<vector>

int main(){
	int z;
	int a=0;
	int b=0;
	std::cin>>z;
	std::vector<int> vec1(z);
	std::vector<int> vec2(z);
	for(int i=0;i<z;i++){
		std::cin>>vec1[i];
		std::cin>>vec2[i];
	}
	for(int i=0;i<z;i++){
		if(vec1[i]>vec2[i])a=a+vec1[i]+vec2[i];
		if(vec2[i]>vec1[i])b=b+vec1[i]+vec2[i];
		if(vec1[i]==vec2[i]){
			a=a+vec1[i];
			b=b+vec2[i];
		}
	}
	std::cout<<a<<" "<<b<<std::endl;
	
	return 0;
}

C++: #include<iostream>
using namespace std;
int main() {
	int a=0, b=0;
	int x;
	int n, m;
	cin >> x;
	for (int i = 0; i < x; i++){
		cin >> n >> m;
		if (n > m){
			a += n + m;
		}
		else b += n + m;
	}
	cout << a << " " << b << endl;
	char c;
	cin >> c;
}

C++: #include<iostream>

using namespace std;

int n,A,B;

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

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

int main()
{
  int n;
  int a[10000], b[10000];
  while (1)
  {
    cin >> n;
    if (n == 0) return 0;
    for (int i = 0; i < n; i++)
    {
      cin >> a[i] >> b[i];
    }
    int Ascore = 0, Bscore = 0;
    for (int i = 0; i < n; i++)
    {
      if (a[i] > b[i]) Ascore += a[i]+b[i];
      if (a[i] < b[i]) Bscore += a[i]+b[i];
      if (a[i] == b[i])
      {
        Ascore += a[i];
        Bscore += b[i];
      }
    }
    cout << Ascore << ' ' << Bscore << endl;
  }
}

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

C++: #include<iostream>
using namespace std;
int main(){
  int n,card1,card2,P1=0,P2=0;
  while(1){
    cin >> n;
    if(n==0){
      break;
    }
    for(int i=0;i<n;i++){
      cin >> card1 >> card2;
      if(card1>card2){
	P1=P1+card1+card2;
      }
      else if(card2>card1){
	P2=P2+card1+card2;
      }
      else if(card1==card2){
	P1=P1+card1;
	P2=P2+card2;
      }
    }
    cout << P1 << " " << P2 << endl;
  }
  return (0);
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stdlib.h>
#include <time.h>
#include <queue>
#include <sstream>
using namespace std;
int main(void){
	int n;
	while(cin >> n, !0){
		int a = 0; 
		int b = 0;
		for(int i = 0; i < n; i++){
			int r, l;
			cin >> l >> r;
			if(r < l){
				a += r+l;
			}else if(r > l){
				b += r+l;
			}else if(r == l){
				a += l;
				b += r;
			}
		}
		cout << a << " " << b << endl;
	}
}

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

int main()
{
 int a,b,n;
 while(cin>>n, n)
 {
  int x=0, y=0;
 while(n--)
 {
   cin>>a>>b;
   if(a<b) {y+=a+b;}
   else if(a>b) {x+=a+b;}
   else {x+=a; y+=b;}
  }

 cout<<x<<" "<<y<<endl;
}
}

C++: #include <iostream>

using namespace std;

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