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>
using namespace std;
int main(){
  int n;
  while(cin>>n,n!=0){
    vector<pair<int,int> > pii;
    int pa=0,pb=0;
    for(int i=0;i<n;i++){
      int a,b;
      cin>>a>>b;
      pii.push_back(make_pair(a,b));
      if(pii[i].first>pii[i].second)
	pa+=(pii[i].first+pii[i].second);
      else if(pii[i].first<pii[i].second)
	pb+=(pii[i].first+pii[i].second);
      else{
	pa+=pii[i].first;pb+=pii[i].second;
      }
    }
    cout<<pa<<" "<<pb<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>

// this require C++11
//#include <unordered_set>
//#include <unordered_map>
//#include <random>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;

template<typename T>
ostream& operator<<(ostream& os,vector<T>& vec){
    typename vector<T>::iterator it,endit=vec.end();
    os << "[";
    for(it=vec.begin();it!=endit;it++){
        os << " " << *it << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}



int main(){
	int n,a,b;
	int Pa,Pb;
	for(;;){
		n=input<int>();
		if(n==0)
			break;
		Pa=0,Pb=0;
		repeat(i,n){
		a=input<int>();b=input<int>();
		if(a>b)
			Pa+=a+b;
		else if(a==b){
			Pa+=a;Pb+=b;
		}else if(a<b)
			Pb+=a+b;
		}
		cout << Pa << " " << Pb << endl;
	}
	return 0;
}

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 += B[i];
			}
		}
		std::cout << a << " " << b << std::endl;
		std::cin >> n;
	}
    return 0;
}

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

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

		int p0=0, p1=0;

		for (int i = 0; i < n; ++i){
			int a, b;
			cin >> a >> b;
			if (a>b) p0 += a + b;
			else if (a == b);
			else p1 += a + b;
		}
		cout << p0 << ' ' << p1 << endl;
	}
}

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

C++: #include <bits/stdc++.h>
#include <stdint.h>

typedef uint32_t u32;
typedef uint64_t u64;

int main() {

  for(;;) {
    int n;
    std::cin >> n;
    if( n == 0 ) break;
    int x = 0, y = 0;
    for(int i = 0; i < n; ++i) {
      int a, b;
      std::cin >> a >> b;
      if( a > b ) x += a + b;
      if( a < b ) y += a + b;
      if( a == b ) {
        x += a; y += b;
      }
    }
    std::cout << x << " " << y << std::endl;
  }
  
  return 0;
}

C++: #include <iostream>

using namespace std;

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

C++: # coding: utf-8
# Here your code !


def latte():
    return int(input())

while True:
    x=y=0
    n=latte()
    if n==0 :break
    for i in range(n):
        a,b=map(int,input().strip().split())
        if a>b:
            x+=a+b
        elif b>a:
            y+=a+b
        else :
            x+=a
            y+=b
    
    print(x,y)

C++: #include<stdio.h>

int main(){
	int n;
	int A=0;
	int B=0;
	int i=0;
	scanf("%d", &n);
	int x[10000];
	int y[10000];
	while(i<n){
	scanf("%d", &x[i]);
	if(0>x[i] || 9<x[i]){
	return 0;
	}
	scanf("%d", &y[i]);
	if(0>y[i] || 9<y[i]){
	return 0;
	}
	++i;
}
	i=0;
	while(i<n){
	if(x[i]>y[i]){
	A=A+x[i]+y[i];
}else {
	if(x[i]<y[i]){
	B=B+x[i]+y[i];
}else{
	A=A+x[i];
	B=B+y[i];
			}
		}
	++i;
	}
	printf("%d %d\n", A, B);
		return 0;
}

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

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

using namespace std;

int main() {

	int n, a, b, c, d;

	while(1) {
		cin >> n;
		if(n==0)
			break;
		a=0;
		b=0;
		while(n!=0) {
			cin >> c >> d;
			if(c>d)
				a+=c+d;
			else if(c<d)
				b+=c+d;
			else {
				a+=c;
				b+=d;
			}
	
			n--;
		}
		cout << a << " " << b << endl;
	}


	return 0;

}

C++: #include<iostream>
using namespace std;
int main(){
	int n;
	int a,b;
	int A,B;
	cin>>n;
	while(true){
        if(n==0){break;}
	for(int i=0;i<n;i++){
		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;
	return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    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 <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>

using namespace std;


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

C++: #include<iostream>

void main(){

	int n;

	int a=0, b=0;

	int x, y;

	f:

	std::cin >> n;

	if (n == 0)
		goto flag;

	for(int i=0;i<n;i++){	
		std::cin >> x >> y;
		if (x > y)
			a += x + y;
		if (x < y)
			b += x + y;
		if (x == y)
			a += x, b += y;
	}

	goto f;

flag:

	std::cout << a << b << std::endl;

}