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>

int A[10000], B[10000];

int main()
{
	int n, a, b;
	std::cin >> n;
	while (n != 0)
	{
		a = 0; 
		b = 0;
		for (int i = 0; i < n; i++)
		{
			std::cin >> A[i] >> B[i];
			if (A[i] > B[i])
			{
				a += A[i] + B[i];
			}
			if (A[i] == B[i])
			{
				a += A[i];
				b += B[i];
			}
			if (A[i] < B[i])
			{
				b += A[i] + B[i];
			}
		}
		std::cout << a << " " << b << std::endl;
		std::cin >> n;
	}
    return 0;
}

C++: #include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
int main(void){
int n,a,b,a1,b1;
while(1){
scanf("%d",&n);
a1=0;
b1=0;
if(n==0){break;}
for(int i=0;i<n;i++){
scanf("%d%d",&a,&b);
if(a>b){
a1=a+b;
}else if(b>a){
b1=a+b;
}else{
a1+=a;
b1+=b;
}
}
printf("%d %d\n",a1,b1);
}
return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <string>
#include <algorithm>
#include <string>
#include <climits>
#include <utility>

#define REP(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define REG(i, a, b) for (int (i) = ((int)(a)); (i) < ((int)(b)); i++)
#define ALL(V) (V).begin(), (V).end()
#define PRINT(STR) cout << (STR) << endl
#define ROUNDED(N) fixed << setprecision(N)
#define SPACE " "

typedef long long ll;
using namespace std;

int nextInt() { int n; cin >> n; return n; }
double nextDouble() { double d; cin >> d; return d; }
string nextString() { string str; cin >> str; return str; }

int main() {
	cin.tie(0); //対話型には使えない
	ios::sync_with_stdio(false); //printfと共には使えない
	while (true) {
		int n = nextInt();
		if (!n) break;
		int a_sum = 0, b_sum = 0;
		for (int i = 0; i < n; i++) {
			int a = nextInt(), b = nextInt();
			if (a > b) a_sum += a + b;
			else b_sum += a + b;
		}
		cout << a_sum << SPACE << b_sum << endl;
	}
	return 0;
}

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

using namespace std;

void func(int n)
{
    int Acard, Bcard;
    int Ascore = 0, Bscore = 0;
    for (int i = 0; i < n; ++i) {
        cin >> Acard >> Bcard;
        if (Acard > Bcard) {
            Ascore += Acard + Bcard;
        } else if (Acard < Bcard) {
            Bscore += Acard + Bcard;
        } else if (Acard == Bcard) {
            Ascore += Acard;
            Bscore += Bcard;
        }
    }
    cout << Ascore << " " << Bscore << '\n';
    return;
}

int main()
{
    for (;;) {
        int n;
        cin >> n;
        if (n == 0) break;
        func(n);
    }
    return 0;
}

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

using namespace std;

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

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

C++: #include <iostream>

int main() {
  while (true) {
    int n, score_a = 0, score_b = 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) {score_a += a+b;}
      else if (a < b) {score_b += a+b;}
      else            {score_a += a; score_b += b;}
    }
    
    std::cout << score_a << " " << score_b << std::endl;
  }
  
  return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
	int n;
	int A, B;
	int sum_A, sum_B;
	while (cin >> n, n != 0){
		sum_A = 0;
		sum_B = 0;
		for (int i = 0; i < n; i++){
			cin >> A >> B;
			if (A > B) sum_A += A + B;
			else if (A < B) sum_B += A + B;
			else{
				sum_A += A;
				sum_B += B;
			}
		}
		cout << sum_A << " " << sum_B << endl;
	}
}

C++: #include <cstdio>

int main(){
	int a, b, c;
	scanf("%d", a);
	int n_a[a];
	int n_b[a];
	for(int i=0; i<a; i++){
		scanf("%d %d", n_a[i], n_b[i]);
	}
	for(int i=0; i<a; i++){
		if(n_a[i] > n_b[i]){
			b += n_a[i]+n_b[i];
		}else if(n_a[i] < n_b[i]){
			c += n_a[i]+n_b[i];
		}else if(n_a[i] == n_b[i]){
			b += n_a[i];
			c += n_b[i];
		}
	}
	printf("%d %d", b, c);
	return 0;
}

C++: #include<iostream>
using namespace std;
int i, n, pA, pB, tA = 0, tB = 0;
int main () {
    whole(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 <stdio.h>
int main(void) {
  int n, a, b, pointa, pointb, i;
  while(scanf("%d",&n),n) {
    pointa = 0; pointb = 0;
  for(i = 0; i < n; i++ ) {
    scanf("%d%d",&a,&b);
    if(a < b) {
      pointb += a+b;
    } else if(a > b) {
      pointa += a+b;
    } else {
      pointa += a; pointb += b;
    }
  }
  printf("%d %d\n",pointa,pointb);
  }
  return(0);
}

C++: #include<stdio.h>
int main()
{
	int a=0, b=0, x, y, n, i;
	scanf("%d", &n);
	for (i = 0; i < n; i++){
		scanf("%d %d", &x, &y);
		if (x > y){
			a += x + y;
		}
		else if (x == y){
			a += x;
			b += y;
		}
		else
			b += x + y;
	}
	printf("%d %d\n", a, b);
	return 0;
}

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 sam1,sam2,a,b,n;

   while(cin >> n,n !=0){

   sam1 = 0;
   sam2 = 0;

   for(int i=0;i<n;i++){
	cin >> a >> b;

	if(a>b){
		sam1 += a+b;
	}else if(b>a){
		sam2 += a+b;
	}else if(a == b){
		sam1 += a;
		sam2 += b;
	}
   }

   cout << sam1 << " " << sam2 << endl;

   }

   return 0;
}

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

class Data{
private:
	int a_point, b_point;
public:
	Data(){ a_point=0; b_point=0;}
	void Add(int a, int b);
	void Show();
};

struct DataList{
	Data dataset;
	struct DataList* next;
};

void Data::Add(int a, int b){
	a_point += a;
	b_point += b;
}

void Data::Show(){
	cout << a_point << " " << b_point << endl;
}

int main(){
	int n, a, b;
	struct DataList *datalist, *p;

	datalist = new DataList;
	p = datalist;

	datalist->next = NULL;

	while(1){
		cin >> n;
		if(n == 0) break;

		p->next = new DataList;
		p->next->next = NULL;
		p = p->next;

		while(n > 0){
			cin >> a >> b;
			if(a > b) p->dataset.Add(a+b,0);
			else if(a < b) p->dataset.Add(0,a+b);
			else p->dataset.Add(a,b);
			n -= 1;
		}
	}

	p = datalist;

	while(p->next != NULL){
		p = p->next;
		p->dataset.Show();
	}

	return 0;
}