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 <stdio.h>
#define loop(num)	for(int a = 0; a < num; a++)

int main(){
	int num;
	do{
		long long A = 0, B = 0;
		int a_card, b_card;
		scanf("%d", &num);
		loop(num){
			scanf("%d%d", &a_card, &b_card);
			if (a_card < b_card) B += (a_card + b_card);
			if (b_card < a_card) A += (a_card + b_card);
			if (a_card == b_card){
				A += a_card;
				B += b_card;
			}
		}
		if (num != 0)
		printf("%lld %lld\n", A, B);
	} while (num != 0);
	return 0;
}

C++: #include <cstdio>
int main(){
 int asum,bsum,a,b,n,i;
 asum=bsum=0;
 scanf("%d",&n);
 for(i=0;i<n;i++){
  scanf("%d %d",&a,&b);
  if (a>b) asum += a+b;
  if (a<b) bsum += a+b;
  if (a==b) { asum += a; bsum += b; }
 };
 printf("%d %d\n",asum,bsum);
 return 0;
};

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

int main(void)
{
  int n;

  while (true) {
    int n;
    std::cin >> n;
    if (n == 0) break;
    std::vector<int> cards_A, cards_B;
    for (int i = 0; i < n; i++) {
      int card_A, card_B;
      std::cin >> card_A >> card_B;
      cards_A.push_back(card_A);
      cards_B.push_back(card_B);
    }
    int score_A = 0;
    int score_B = 0;
    for (int i = 0; i < n; i++) {
      if (cards_A.at(i) == cards_B.at(i)) {
        score_A += cards_A.at(i);
        score_B += cards_B.at(i);
      }
      else {
        int score_sum = cards_A.at(i) + cards_B.at(i);
        if (cards_A.at(i) > cards_B.at(i)) score_A += score_sum;
        if (cards_A.at(i) < cards_B.at(i)) score_B += score_sum;
      }
    }
    std::cout << score_A << " " << score_B << std::endl;
  }

  return 0;
}

C++: #include<cstdio>

using namespace std;

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

C++: #include<iostream>

using namespace std;

int main()
{
	int n;
	int i;
	int card_A,card_B;
	int ans_A,ans_B;
	
	for(;;)
	{
		cin >> n;
		if(n==0)
			break;
			
		ans_A=ans_B=0;
		
		for(i=0;i<n;i++)
		{
			cin >> card_A >> card_B ;
			if(card_A>card_B)
				ans_A+=card_A+card_B;
			else if(card_A == card_B)
			{
				ans_A+=card_A;
				ans_B+=card_B;
			}
			else
				ans_B+=card_A+card_B;
		}
		
		cout << ans_A << " " << ans_B << endl;
	}
}

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

int main ()
{
while  (true)
  {
  int loop,vna,vnb;
  scanf("%d",&loop);
  if (loop == 0)
    {
	break;
	  };
  vna=0;
  vnb=0;
  for (int i=0;i<loop;i++)
    {
      int vn2,vn3;
      scanf("%d",&vn2);
      scanf("%d",&vn3);
      if (vn2 > vn3)
	{
	  vna = vna + vn2 + vn3;
	    };
      if (vn2 < vn3)
	{
	  vnb = vnb + vn2 + vn3;
	    };
      if(vn2 == vn3)
	{
	  vna = vna + vn2;
	  vnb = vnb + vn3;
	};
    };
  printf ("%d %d\n",vna,vnb);


 };

}

C++: #include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
	long long int a,b,n,x,y;
	a=0;
	b=0;
	scanf("%lld",&n);
	for(long long int i=0;i<n;i++){
		scanf("%lld %lld",&x,&y);
		if(x>y) {a+=(x+y);}
		if(x<y) {b+=(x+y);}
		if(x==y){
			a+=x;
			b+=y;
		}
	}
	printf("%lld %lld\n",a,b);
	return 0;
}

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

int main(void){
  int a,b;
  a=b=0;
  int n;
  cin>>n;
  while(n--){
    int c,d;
    cin>>c>>d;
    if(c>d)
      a += c + d;
    else
      b += c + d; 
  }
  cout<< a << " " << b << endl;
}

C++: #include<iostream>
using namespace std;
 
int main () {
    int n, i,A,B, resa, resb;
    while(cin >> n,n){
        resa=0;resb=0;
        for(i=0;i<n;i++){
             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(void)
{
	int n,a,b,i,k=0,h=0;
	
	scanf("%d",&n);
	for(i=0;i!=n;i++){
	    scanf("%d %d",&a,&b);
	    if(a>b){
		    k+=a+b;
		   }
	    else if(a==b){
			  k+=a;
			  h+=b;
			 }
	    else
		h+=a+b;
	}
	printf("%d %d",k,h);
return 0;	
}

C++: #include <stdio.h>

int main(void) {
	while (1) {
		int n;
		scanf("%d", &n);
		
		if (n == 0) {
			break;
		}
		
		int a_score = 0;
		int b_score = 0;
		
		int i;
		for (i = 0; i < n; i++) {
			int a;
			int b;
			scanf("%d %d", &a, &b);
			
			*(a >= b ? &a_score : &b_score) += a;
			*(b >= a ? &b_score : &a_score) += b;
		}
		
		printf("%d %d\n", a_score, b_score);
	}
	
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int point[2];
	enum {
		A,
		B,
	};
	int sum[2] = {};
	for (int i = 0; i < n; i++) {
		cin>>point[A]>>point[B];
		if (point[A]>point[B]) {
			for (auto j : point) {
				sum[A]+=j;
			}
		} else if(point[A] == point[B]) {
			for (auto j : sum) {
				j+=point[A];
			}
		} else {
			for (auto j : point) {
				sum[B]+=j;
			}
		}
	}
	cout<<sum[A]<<" "<<sum[B]<<endl;
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <sstream>
#include <fstream>
//#include <tuple>
#include <set>
#include <string.h>
#include <functional>

#define X first
#define Y second
#define MP make_pair
//#define MT make_tuple
#define REP(i, a, n) for(int (i) = (a); (i) < (n); ++(i))
#define FOR(i, n) REP(i, 0, n)
typedef long long ll;
using namespace std;
const int MAX = 101;

template<class T, class U>
void convert(T &t, U &u)
{
	stringstream ss;
	ss << t;
	ss >> u;
}

int main()
{
	int n;
	while (cin >> n && n){
		int a = 0, b = 0;
		FOR(i, n){
			int s, t; cin >> s >> t;
			if (s > t) a += s + t;
			else if (s < t) b += s + t;
			else a += s, b += t;
		}

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

	return 0;
}

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

int main(){
    int cnt[2];
    while(1){
        int n;
        cin >> n;
        if(n == 0) break;
        cnt[0] = 0;
        cnt[1] = 0;
        for(int i = 0; i < n; i++){
            int a,b;
            cin >> a >> b;
            if(a > b){
                cnt[0] += a + b;
            }else if(a < b){
                cnt[1] += a + b;
            }else{
                cnt[0] += a;
                cnt[1] += b;
            }
        }
        cout << cnt[0] << cnt[1] << endl;
    }
    return 0;
}

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

			cin>>c>>d;
			if (c>d)
			{
				e=e+c+d;
			}
			else if (c<d)
			{
				f=f+d+c;
			}
			else if (c==d)
			{
				e=e+c;
				f=f+d;
			}
		}
		cout<<e<<" "<<f<<endl;
	}
	return 0;
}