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>

using namespace std;


int main() {

  int n;
  int p_a,p_b;


  while(cin >> n,n) {

    p_a=p_b=0;

    for(int i=0;i<n;i++) {

      int a,b;

      cin >> a >> b;

      if(a>b) p_a+=a+b;

      else if(a==b) {

	p_a+=a;
	p_b+=b;

      }

      else p_b+=a+b;

    }

    cout << p_a << " " << p_b << endl;

  }

  return 0;

}

C++: #include <iostream>
#include <functional>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <map>
#include <cmath>

using namespace std;

namespace _{struct _{_(){ // initialize
  cin.tie(0); ios::sync_with_stdio(false);
}}_;}
template <typename T, size_t size>
inline size_t len(const T (&)[size]) { return size; }
#define println(s) cout << s << '\n';
#define str to_string
#define rep(i, n) for (int i=0; i<int(n); i++)
#define all(c) (c).begin(), (c).end()


int main() {
  int n; cin >> n;

  int A = 0;
  int B = 0;
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    if (a == b) {
      A += a; B += b;
    } else if (a > b)
      A += a+b;
    else
      B += a+b;
  }

  cout << A << " " << B << endl;
  return 0;
}

C++: #include<stdio.h>

int main(){
	int i=0,x,a[10000],b[10000],aP=0,bP=0;
	while(1){
	scanf("%d",&x);
	if(x==0){
	return 0;
	}
	while(i<x){
scanf("%d%d",&a[i],&b[i]);
	++i;
	}
	i=0;
	while(i<x){
		if(a[i]==b[i]){
			aP=aP+a[i];
			bP=bP+b[i];
		}else if(a[i]>b[i]){
		aP=aP+a[i]+b[i];
		}else{
		bP=bP+a[i]+b[i];
		}
		++i;
	}
	printf("%d %d\n",aP,bP);
	}
}

C++: #include<iostream>
using namespace std;
int n[10000000],s1,s2;
int main(){
int p,a,b;
cin>>p;
for(int i=0;i<p;i++){
cin>>a>>b;
if(a>b){s1+=a+b;}
else if(b>a){s2+=a+b;}
else{s1+=a;s2+=b;}
}
cout<<s1<<' '<<s2<<endl;
}

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

int main(){
	
	int n, x, y, sumx=0, sumy=0;

	while(cin >> n && n > 0){
		sumx=0, sumy=0;
		for(int i=0; i<n; i++){
			x=0,y=0;
			cin >> x >> y;
			if(x > y){
				sumx = sumx + x + y;
			}
			else if(x < y){
				sumy = sumy + x + y;
			}
			else if(x == y){
				sumx = sumx + x;
				sumy = sumy + y;
			}
		}
	
		cout << sumx << " " << sumy << endl;
	 }
	return 0;
}

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

int main() {
    while (true) {
        int n;
        cin >> n;
        int PlayerA;
        int PlayerB;
        if (n==0) {
            break;
        }
        PlayerA=0;
        PlayerB=0;
        while (n--) {
            int scoreA;
            int scoreB;
            cin >> scoreA >> scoreB;
            if (scoreA>scoreB) {
                PlayerA+=scoreA+scoreB;
            } else if (scoreA<scoreB) {
                PlayerB+=scoreA+scoreB;
            } else {
                PlayerA+=scoreA;
                PlayerB+=scoreB;
            }
        }
        printf("%d %d\n",PlayerA,PlayerB);
    }
    return 0;
    
}

C++: #include <iostream>

using namespace std;

int main()
{
  int n;
  cin >> n;
  while (n != 0) {
    int inputA, inputB;
    int outA(0), outB(0);
    for (int i=0; i<n; i++) {
      cin >> inputA >> inputB;
      if (inputA > inputB) outA += inputA + inputB;
      else if (inputA < inputB) outB += inputA + inputB;
      else { outA += inputA; outB += inputB;}
    }
    cout << outA << ' ' << outB << endl;
    cin >> n;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

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

}

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

int main(){
int n,a,b;
int A=0,B=0;
while(cin>>n){
	A=0;
	B=0;
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 res = 1;
    while(res){
        cin >> res;

        if(res == 0)
            break;

        int n[2][res];

        for(int i=0; i<res; i++){
            cin >> n[0][i];
            cin >> n[1][i];
        }
        int x = 0;
        int y = 0;

        for(int j=0; j<res; j++){
            if(n[0][j]>n[1][j])
                x += n[0][j]+n[1][j];
            else if(n[0][j]==n[1][j]){
                x += n[0][j];
                y += n[1][j];
            }
            else
                y += n[0][j]+n[1][j];
            }

            cout << x << ' ' << y << '\n';

    }

    return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{	
	int c, a, b, a1, b1;
	while (cin >> c&&c != 0) {
		a = 0; b = 0;
		for (int i = 0; i < c; i++) {
			cin >> a1 >> b1;
			if (a1 > b1) {
				a += (a1 + b1);
			}
			else if (a1 < b1) {
				b += (a1 + b1);
			}
			else {
				a += a1;
				b += b1;
			}
		}
		cout << endl;
		cout << a << ' ' << b << endl;
		cout << endl;
	}
	return 0;
}

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;
        cin >> 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>
using namespace std;
int
main ()
{
  int a, b, n, resa, resb;
  a = b = n = 0;
  while (cin >> n)
    {
      resa = resb = 0;
      if (n == 0)
	break;
      for (; n > 0; n--)
	{
	  cin >> a >> b;
	  if (a > b)
	    resa += a + b;
	  else if (a < b)
	    resb += a + b;
	  else
	    {
	      resa += a;
	      resb += b;
	    }
	}
      cout << resa << " " << resb << endl;
    }
}

C++: #include<stdio.h>

int main(){
	int i=0,x,a[10000],b[10000],aP=0,bP=0;
	scanf("%d",&x);
	while(i<x){
scanf("%d%d",&a[i],&b[i]);
	++i;
	}
	i=0;
	while(i<x){
		if(a[i]==b[i]){
			aP=aP+a[i];
			bP=bP+b[i];
		}else if(a[i]>b[i]){
		aP=aP+a[i]+b[i];
		}else{
		bP=bP+a[i]+b[i];
		}
		++i;
	}
	printf("%d %d\n",aP,bP);
}

C++: #include<stdio.h>
#include<stdlib.h>
#include<iostream>
using namespace std;
int main(){
	int a[10002],b[10002],i,j=0,ans1[10000],ans2[10000];
	int A=0,B=0,n;
	cin>>n;
	while(n!=0){
		for(i=0;i<n;i++){
			cin>>a[i]>>b[i];
		}
		for(i=0;i<n;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;
		cin>>n;
	}
    return 0;
	
}