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 <stdio.h>

int main(void) {
	int n;
	int a, b;
	int ascore, bscore;

	while (scanf("%d", &n), n) {
		ascore = 0;
		bscore = 0;
		for (int i = 0; i < n; i++) {
			scanf("%d %d", &a, &b);
			if (a > b) ascore += a + b;
			else if (a < b) bscore += a + b;
			else {
				ascore += a;
				bscore += b;
			}
		}
		printf("%d %d\n", ascore, bscore);
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int p[10000],q[10000],ptop;
int main(){
	ptop=1,p[0]=2;
	for(int i=3;i<100000;i+=2){
		bool ok=1;
		rep(j,ptop)if(!(i%p[j])){ok=0;break;}
		if(ok)p[ptop]=i,ptop++;
	}
	int n;
	long long x;
	scanf("%d",&n);
	rep(z,n){
		scanf("%lld",&x);
		rep(i,ptop)q[i]=1;
		rep(i,ptop){while(!(x%p[i]))x/=p[i],q[i]++;if(!(x-1))break;}
		int ans=1;
		if(x-1)ans++;
		rep(i,ptop)ans*=q[i];
		printf("%d\n",ans);
	}
	return 0;
}

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

C++: #include <bits/stdc++.h>

#define X first
#define Y second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define rep(i, a, b) for (unsigned i = (a); i <= (b); ++i)
#define per(i, a, b) for (unsigned i = (a); i >= (b); --i)

using namespace std;

using I = int;
using L = long;
using F = float;
using S = string;
using LL = long long;
using VI = vector<int>;
using VL = vector<long>;
using VF = vector<float>;
using VS = vector<string>;
using PLL = pair<long, long>;
using PLF = pair<long, float>;
using PLS = pair<long, string>;
using PSL = pair<string, long>;
using PSF = pair<string, float>;
using PSS = pair<string, string>;
using MLL = map<long, long>;
using MLF = map<long, float>;
using MLS = map<long, string>;
using MSL = map<string, long>;
using MSF = map<string, float>;
using MSS = map<string, string>;

const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;

int main(int argc, char const *argv[]) {
  while (1) {
    L n;
    L ans1 = 0;
    L ans2 = 0;
    scanf("%ld", &n);
    if (n == 0) { break; }
    for (unsigned i = 0; i < n; i++) {
      L a, b;
      cin >> a >> b;
      if (a > b) {
        ans1 += a + b;
      } else if (a < b) {
        ans2 += a + b;
      } else {
        ans1 += a;
        ans2 += b;
      }
    }
    printf("%ld %ld\n", ans1, ans2);
  }

  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int n;
	int a,b;
	int A,B;
	cin>>n;
	for(int j=0;j<5;j++){
        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++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
	int n, a, b, a_p, b_p;
	
	while(true){
		cin >> n;
		if(n == 0){
			break;
		}
		a_p = 0;
		b_p = 0;
		for(int i = 0; i < n; i++){
			cin >> a >> b;
			if(a > b){
				a_p += a + b;
			}else if(a == b){
				a_p += a;
				b_p += b;
			}else{
				b_p += a + b;
			}
		}
		printf("%d %d\n", a_p, b_p);
	}
	
	return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<string>
#include<functional>
#include<queue>
#include<stack>
#include<math.h>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	int n;
	while (1) {
		cin >> n;
		if (n == 0)return 0;
		int a, b;
		int ascore = 0, bscore = 0;
		vector<P>card;
		for (int i = 0; i < n; i++) {
			cin >> a >> b;
			if (a > b)ascore += a + b;
			else if (b > a)bscore += a + b;
			else {
				ascore += a;
				bscore += b;
			}
		}
		cout << ascore << " "<< bscore << endl;
	}

}

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

int main() {
	int q[10000 - 1], w[10000 - 1];
	int n;
	int a = 0;
	int b = 0;
	int x = 1;
	while (x== 10000) {
		cin >> n;
		if (n == 0) {
			break;
		}

		for (int i = 1; i <= n; ++i) {
			int c, d;
			cin >> c >> d;
			if (c == d) {
				a = a + c;
				b = b + d;
			}
			else if (c > d) {
				a = a + c + d;
			}
			else {
				b = b + c + d;
			}
		}
		q[x] = a;
		w[x] = b;
		x++;
	}
	for (int j = 1; j <= x; ++j) {
		cout << q[j] << " " << w[j] << endl;
}

C++: #include <iostream>

int main(int argc, char **argv){
	int n = 0;
	int a = 0;
	int b = 0;
	int a_score = 0;
	int b_score = 0;

	std::cin >> n;

	for(int i = 0; i < n; i++){
		std::cin >> a >> b;
		if(a > b){
			a_score += a + b;
		}
		else if(a < b){
			b_score += a + b;
		}
		else{
			a_score += a;
			b_score += b;
		}
	}

	std::cout << a_score << " " << b_score << std::endl;
	return 0;
}

C++: #include <iostream>

int main(){
	std::ios::sync_with_stdio(false);
    while(true){
		int n, a_score = 0, b_score = 0;
		std::cin >> n;
		
		if(n == 0)
			break;

		for(int i = 0; i < n; ++i){
			int a, b;
			std::cin >> a >> b;
			if(a > b)
				a_score += a + b;
			else if(a < b)
				b_score += a + b;
			else
				a_score += a, b_score += b;
		}

		std::cout << a_score << " " << b_score << std::endl;
    }
    return 0;
}

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

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

	cin >> n;

	while (n != 0){

		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;

		cin >> n;

	}
}

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

int main()
{
	int a;
	int r, l;
	int rsum, lsum;
	rsum = 0;
	lsum = 0;
	while (cin >> a && (a != 0)){
		
		for (int i = a; i > 0; i--){

			cin >> r;
			cin >> l;
			if (r > l){
				rsum += r + l;
			}
			else if (l > r){
				lsum += r + l;
			}
			else{
				rsum += r;
				lsum += l;
			}
		}
		cout << rsum << ' ' << lsum << endl;
	} 
	cout << "end";
}

C++: #include<stdio.h>

int main(){

int N;int A,B,SA=0,SB=0;
while(1){
SA=0,SB=0;

scanf("%d",&N);
if(N==0)break;
for(int i=0;i<N;i++){
scanf("%d %d",&A,&B);
if(A>B)SA+=A+B;
else if(B>A)SB+=A+B;
}

printf("%d %d\n",SA,SB);
}
return 0;
}

C++: #include<iostream>
using namespace std;
int i, n, pA, pB, tA = 0, tB = 0;
int main () {
    while(cin >> n) {
       if(n == 0) { break; }
       for (i=1; i<=n; i++) {
           cin >> pA >>pB;
           if (pA >pB) {
               tA += pA + pB;
           } else {
               if (pA <pB) {
                   tB += pA + pB;
               } else {
                   tA += pA;
                   tB +- pB;
               }
           }
       }
       cout << tA << " " << tB << endl;
       tA = 0; tB = 0;
     }
     return 0;
}