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

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

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

int main(){
	int a;
	int uma;
	int ushi;
	int b;
	int c;
	int i;
	while (true){
		cin >> a;
		if (a == 0){ break; }
		else{
			while (true){
				if (i<a){
					cin >> b;
					cin >> c;
					if (b>c){
						uma = uma + b + c;
					}
					if (b == c){
						uma = uma + b;
						ushi = ushi + c;
					}
					else{
						ushi = ushi + b + c;
					}
					i++;
				}if (i == a){ break; }
			}
			cout << uma << " " << ushi << endl;
			uma = 0;
			ushi = 0;
			i = 0;
		}
	}
}

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

C++: #include <cstdio>
using namespace std;
int n,a[10000],b[10000],x,y;
int main()
{
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%d %d",&a[i],&b[i]);
}
for(int i=0;i<n;i++){
if(a[i]==b[i]){x+=a[i]; y+=b[i];}
if(a[i]>b[i]) x+=a[i]+b[i];
if(a[i]<b[i]) y+=a[i]+b[i];
}
if(n>0) printf("%d %d",x,y);
}

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

C++: #include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>

using namespace std;
typedef long long Int;
#define REP(i , x) for(int i = 0 ; i < x ; ++i)
Int Ap, Bp;

int main()
{
	int n;
	int a, b;
	
	while (cin >> n, n){
		REP(i, n){
			cin >> a >> b;
			if (a > b){
				Ap += a;
				Ap += b;
			}
			else if (a < b){
				Bp += a;
				Bp += b;
			}
			else{
				Ap += a;
				Bp += b;
			}
		}

		cout << Ap << " " << Bp << endl;
	}
	return 0;

}

C++: #include<vector>
#include<algorithm>
#include<string>

int main(){

  std::vector<std::pair<int,int> > data;

  char buf[100];
  int n;

  std::cin >> buf;
  n = atoi(buf);

  char a[100];
  char b[100];

  for (int i=0; i<n ; i++){
    std::cin >> a;
    std::cin >> b;
    data.push_back(std::pair<int,int>(atoi(a),atoi(b)));
  }

  int you = 0;
  int opp = 0;

  for (std::vector<std::pair<int,int> >::iterator it = data.begin(); it != data.end(); it++){
    int yv = (*it).first;
    int ov = (*it).second;
    if (yv > ov ){
      you += yv+ov;
    }else if (yv < ov){
      opp += yv+ov;
    }else{
      you += yv;
      opp += ov;
    }
  }

  std::cout << you << " " << opp << std::endl;

  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
int n=1;
int a,b,pa,pb;
for(;n!=0;){
cin>>n;
if(n==0){break;}
pa=0;pb=0;
for(int i=0;i<n;i++){
a=0;b=0;
cin>>a;
cin>>b;
if(a>b){pa+=a+b;}
if(a==b){pa+=a;pb+=b}
if(a<b){pb+=a+b;}
}
cout<<pa<<" "<<pb<<endl;
}
return 0;
}

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

int main(){
  int n,a=0,b=0;
  for(;;){
  cin>>n;
  if(n==0)break;
  
  int A[n],B[n];
  for(int i=0;i<n;i++){
    cin>>A[i]>>B[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];
    }
  }

cout<<a<<" "<<b<<endl;
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

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

C++: #include <iostream>

using namespace std;
int main()
{
    while(true) {
        int loop;
        cin >> loop;
        int p1=0,p2=0;
        if(loop==0)break;
        while(loop--)
        {
            int a,b;
            cin >> a >> b ;
            if(a > b) {
                p1 = p1 + a + b;
            }else if(a==b) {
                p1 += a;
                p2 += b;
            }
            else {
                p2 = p2 + a + b;
            }
        }
        cout << p1 << " " << p2 << endl;
    }
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  int c1,c2,p1 = 0,p2 = 0;
  scanf("%d",&n);
  
  while(n--){
    scanf("%d %d",&c1,&c2);
    if(c1 > c2)p1 += c1+c2;
    else if(c1 < c2)p2 += c1+c2;
    else{
      p1 += c1;
      p2 += c2;
    }
  }
  printf("%d %d\n",p1,p2);
}

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

C++: #include <cstdio>

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

C++: #include <iostream>
#include <cassert>
#define REP(i,l,n) for(int i=l;i<n;++i)
#define rep(i,n) REP(i,0,n)
int ansA,ansB;
int n;
int a,b;
using namespace std;
int main() {
  while(1){
    cin >> n;
    if(n==0) return 0;
    ansA = 0;
    ansB = 0;
    rep(i,n){
      cin >> a;
      cin >> b;
      if(a>b){
        ansA += a+b;
      }else if(b>a){
        ansB += a+b;
      }else{
        ansA += a;
        ansB += b;
      }
    }

    cout << ansA << " " << ansB << endl;
  }
  return 0;
}