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 n;
	int ag = 0, bg = 0;	
	std::cin >> n;
	std::vector<int> a(n), b(n);

	for (int i = 0; i < n; ++i) {
		std::cin >> a[i] >> b[i];
		if (a[i] > b[i]) { ag += a[i]; ag += b[i]; }
		else { bg += a[i]; bg += b[i]; }
	}
	std::cout << ag << " " << bg << std::endl;
	return 0;
}

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

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

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

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

int score[1000][2];
int main(){
	int i;
	int N,a,b,scorsole= 0;
	while(1){
		cin >> N;
		if(N == 0)
			break;
		for(i = 0;i < N;i++){
			cin >> a >> b;
			if(a > b)
				score[scorsole][0] += a+b;
			else if(a == b){
				score[scorsole][0] += a;
				score[scorsole][1] += b;
			}
			else
				score[scorsole][1] += a+b;
		}
		scorsole++;
	}
	for(i = 0;i < scorsole;i++){
		cout << score[i][0] << " " << score[i][1] << endl;
	}
	return 0;
}

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

C++: #include <bits/stdc++.h>
typedef long long LL;
using namespace std;

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

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

int main ()
{
    int	N;
    while (cin >> N, N) {
	int n1, n2;
        int a =	0, b = 0;
        for (int i = 0; i < N; i++) {
            cin >> n1 >> n2;
            if (n1 > n2) a += n1 + n2;
            else if (n1 < n2) b	+= n1 +	n2;
            else {
                a += n1;
                b += n2;
            }
        }
        cout <<	a << " " << b << endl;
    }

    return 0;
}

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

C++: #include<iostream>
using namespace std;
int main(){
int n,sum;
int a,b.ap,bp;
while(cin>>n){
ap=0;
bp=0;
	for(int i=0;i<n;i++){
		cin>>a>>b;
		sum=a+b;
		if(a>b){
			ap+=sum;
		}else if(a<b){
			bp+=sum;
		}else{
			ap+=a;
			bp+=b;
		}
	}
	cout<<ap<<" "<<bp<<endl;
}

return 0;
}

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

C++: #include <stdio.h>
#include <iostream>

using namespace std;

int main() {

	int c;
	int a,b;
	int tokuten1 = 0;
	int tokuten2 = 0;
	
	while (cin >> c) {
		tokuten1 = 0;
		tokuten2 = 0;
		if (c == 0) {
			break;
		}
		for (int i = 0; i < c; i++) {
			cin >> a >> b;
			if (a > b) {
				tokuten1 += (a + b);
			} else if (a < b) {
				tokuten2 += (a + b);
			} else {
				tokuten1 += a;
				tokuten2 += b;
			}
		}
		cout << tokuten1 << " " << tokuten2 << endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
	int N, A, B, X, Y;

	while (true)
	{
		cin >> N; A = 0; B = 0;

		if (N == 0) { break; }

		for (int i = 0; i < N; i++)
		{
			cin >> X >> Y;

			if (X > Y) { A += X + Y; }
			if (X < Y) { B += X + Y; }
			if (X == Y) { A += X; B += Y; }
		}

		cout << A << ' ' << B << endl;
	}

	return 0;
}

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

int main(){
  int n;
  int Acard,Bcard;
  int Atotal,Btotal;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>Acard>>Bcard;
    if(Acard>Bcard){
      Atotal+=(Acard+Bcard);
    }else if(Bcard>Acard){
      Btotal+=(Acard+Bcard);
    }else{
      Atotal+=Acard;
      Btotal+=Bcard;
    }
  }

  cout<<Atotal<<' '<<Btotal<<'\n';
  return 0;
}

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

using namespace std;

int cnt = 0;

void calc_point(int n, int card[10000][2], int point[10000][2]) {
	//get input
	for (int i = 0; i < n; i++){
		if (card[i][0] > card[i][1])
			point[cnt][0] += card[i][0]+card[i][1];
		else if(card[i][0] < card[i][1])
			point[cnt][1] += card[i][0]+card[i][1];
		else{
			point[cnt][0] += card[i][0];
			point[cnt][1] += card[i][1];
		}
	}
	cnt++;
}

int main(){
	int n = 1;
	int card[10000][2];
	int point[10000][2];
	while (1){
		scanf("%d", &n);
		if (n==0) break;
		for (int i = 0; i < n; i++){
			for (int j = 0; j < 2; j++)
				scanf("%d", &card[i][j]);
		}
		calc_point(n, card, point);
	}
	for (int i = 0; i < cnt; i++)
		cout << point[i][0] <<" "<< point[i][1] << endl;
}

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

int main() {
	int num;
	int score_a = 0;
	int score_b = 0;
	int cnt = 0;
	
	cin >> num;
	while ((num != 0) && (cnt <= 5)) {
		for (int i = 0; i < num; i++) {
			int a;
			int b;

			cin >> a >> b;
			if (a > b) {
				score_a += a + b;
			}else if (b > a) {
				score_b += a + b;
			}else {
				score_a += a;
				score_b += b;
			}
		}
		cout << score_a << " " << score_b << endl;
		score_a = 0;
		score_b = 0;
		cnt++;
	}

	cnt = 0;
	return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int n,a,b,a2,b2,i;
	while(1){
	scanf("%d",&n);
	if(n==0) break;
	a=0;
	b=0;
	a2=0;
	b2=0;
	for(i=0;i<n;i++){
	scanf("%d %d",&a,&b);
		if(a<b){
			b2+=a+b;
		}
		if(a>b){
			a2+=a+b;
		}
		else if(a==b){
			a2+=a;
			b2+=b;
		}
	}
	printf("%d %d\n",a2,b2);
	}
}

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

C++: #include<iostream>

using namespace std;

int main(){
  int n, i, Apoint, Bpoint;
  int A[10000], B[10000];
  while(cin >> n ,n){
    Apoint, Bpoint = 0, 0;
    for(i=0; i<n; i++){
      cin >> A[i] >> B[i];
    }
    for(i=0; i<n; i++){
      if(A[i]>B[i])Apoint += A[i]+B[i];
      else if (A[i]<B[i])Bpoint += B[i]+A[i];
      else{
	Apoint += A[i];
	Bpoint += B[i];
      }
    }

    cout << Apoint << " " << Bpoint << endl;
  }
  return 0;
}