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 "../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>
#include<stdio.h>

using namespace std;

int main(void){
  int n;
  int a, b;
  int suma = 0, sumb = 0;
  while(1){
    scanf("%d", &n);
    if(n == 0) break;
    for(int i = 0; i<n; i++){
      cin >>a >> b;
      if(a > b){
	suma += a + b;
      } else if(a < b){
	sumb += a + b;
      } else {
	suma += a;
	sumb += b;
      }
    }
    printf("%d %d\n",suma,sumb);
  }
    return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
  int n;
  int a,b,sum1,sum2;
  while(cin>>n){
  for(int i=1;i<=n;i++){
    cin>>a>>b;
    if(a>b) {sum1=sum1+a+b;}
    else if(a<b) {sum2=sum2+a+b;}
    else if(a==b) {sum1=sum1+a;sum2=sum2+b;}
    }
    if(sum1!=0||sum2!=0){cout<<sum1<<" "<<sum2<<endl;}
    sum1=0,sum2=0;
  }
  return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<string.h>
using namespace std;
int main(){
	int n;
	int sa=0, sb=0;
	int a, b;
	while (1){
		cin >> n;
		if (n == 0){
			break;
		}
		for (int i = 0; i < n; i++){
			cin >> a >> b;
			if (a>b){
				sa = sa + a + b;
			}
			else if (a < b){
				sb = sb + a + b;
			}
			else{
				sa = sa + a;
				sb = sb + b;
			}
		}
		cout << sa << " "<< sb<<endl;
		sa=0;
		sb=0;

	}
	return 0;
}

C++: #include <iostream>

int main(){
    int n,p1=0,p2=0;
    std::cin >> n;
    while( n != 0){
        for(int i=0;i<n;i++){
            int a ,b;
            std::cin >> a >> b;
            if(a > b){
                p1 += a+b;
            }
            if(b > a){
                p2 += a+b;
            }
            if(a==b){
                p1 += a;
                p2 += b;
            }
        }
        std::cout << p1 << ' ' << p2 << std::endl;
        std::cin >> n;
        p1 = 0;p2=0;
    }
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	int n,a,b,c,d;
	while(true){
	cin>>n;
	c=0,d=0;
	if(n==0)
		break;
	for(int i=0;i<n;i++){
		cin>>a>>b;
		if(a>b)
			c+=a+b;
		if(a<b)
			d+=a+b;
		if(a==b){
			c+=a;
			d+=b;
		}
	}
	cout<<c<<" "<<d<<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; resb +=B;};
        }
    cout << resa << " " << resb << endl;
    }
}

C++: #include <stdio.h>
int n,i,j,k;
int A[1],B[1];
int main(){
  for(;;){
    scanf("%d",&n);
    if(n==0){
      return 0;
    }
      for(i=0;i<n;i++){
      scanf(" %d %d",&j,&k);
      A[0]=0,B[0]=0;
      if(j>k){
        A[0]+=(j+k);
      } else if(j<k){
        B[0]+=(j+k);
      } else if(j==k){
        A[0]+=j;
        B[0]+=k;
      }
      printf("%d %d\n",A[0],B[0]);
    }
  }
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <sstream>
#include <vector>
#include <string>
#include <iomanip>
#include <bitset>
using namespace std;
#define INF	100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i,n) for(int i = 0; i < n; i++)
#define sz(x) ((int)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).begin(), (x).end(), greater<int>() )
#define clr(a,b) memset((a),(b),sizeof(a))
typedef pair<int, int> P;
typedef long long int ll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<P, vector<P>, greater<P> > PQ;

int n,a,b,A,B;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	while(cin >> n){
		if(n == 0) break;
		a = 0; b = 0;
		rep(i,n){
			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;
	}
}

C++: #include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
using namespace std;

int n,a,b;

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

C++: #include<cstdio>
#include<algorithm>
#include<cmath>

using namespace std;

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

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