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>
#include <string.h>
using namespace std;

int main() {
	int n,i,result[2] = {0,0};
	cin >> n;
	int num[2];
	for(i = 0;i < n;i++){
		cin >> num[0] >> num[1];
		if(num[0] > num[1])result[0]+= num[0] + num[1];
		else if(num[0] < num[1])result[1]+= num[0] + num[1];
		else{
			result[0] += num[0];
			result[1] += num[1];
		}
	}
	cout << result[0] << " " << result[1] <<endl;
	return 0;
}

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

int main()
{	
	
	int n;
	while(cin>>n){
		if(n==0) return 0;
		
		int a[n], b[n];
		int a_cnt=0, b_cnt=0;
		for(int i=0;i<n;i++){
			cin>>a[i]>>b[i];
		}
		for(int i=0;i<n;i++){
			if(a[i]>b[i]){
				a_cnt += a[i] + b[i];
			}else if(a[i]==b[i]){
				a_cnt += a[i]; b_cnt += b[i];
			}else{
				b_cnt += b[i] + a[i];
			}
		}
		cout<<a_cnt<<' '<<b_cnt<<endl;
	}
	return 0;
}

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

int main()
{
  int n;
  int i = 0;
  cin >> n;

  int *a = new int[n];
  int *b = new int[n];

  while (i < n) {
    cin >> a[i];
    cin >> b[i];
    i++;
  }

  i = 0;
  int sum_a = 0;
  int sum_b = 0;
  while (i < n) {
    if (a[i] < b[i]) {
      sum_b += a[i] + b[i];
    } else if (a[i] > b[i]) {
      sum_a += a[i] + b[i];
    } else {
      sum_a += a[i];
      sum_b += b[i];
    }
    i++;
  }

  cout << sum_a
       << " "
       << sum_b
       << endl;    
  
  delete [] a;
  delete [] b;
  
  return (0);
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>

using namespace std;

int main(){
	int n;
	int inputa,inputb;
	int atotal,btotal;
	vector<int> a;
	vector<int> b;
	while(cin >> n, n !=0){
		a.clear();
		b.clear();
		atotal=btotal=0;
		for(int i=0;i<n;i++){
			cin>>inputa>>inputb;
			if(inputa > inputb){
				atotal += inputa + inputb; 
			}else if(inputa < inputb){
				btotal += inputa + inputb;
			}else{
				atotal +=inputa;
				btotal +=inputb;
			}
		}
		cout<<atotal<<" "<<btotal<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cstdio>
using namespace std;
int main(){
	int n,a[10000],b[10000],i,Acount=0,Bcount=0;
	while(cin>>n){
		if(n==0)break;
		for(i=0;i<n;i++){
			cin>>a[i]>>b[i];
			if(a[i]>b[i])Acount+=a[i]+b[i];
			else if(a[i]<b[i])Bcount+=a[i]+b[i];
			else {
				Acount+=a[i];
				Bcount+=b[i];
			}
		}
		cout<<Acount<<" "<<Bcount<<endl;
		Acount=0;
		Bcount=0;
	}
	return 0;
}

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

C++: #include<iostream>

using namespace std;

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

C++: #include <stdio.h>
int main()
{
	int n=1,b[10000]={0},c[10000]={0},i,e=0,f=0;
	while(n!=0){
		scanf("%d",&n);
		if(n==0){continue;}
		for(i=0;i<n;i++)
		{
			scanf("%d %d",&b[i],&c[i]);
		}
		for(i=0;i<n;i++)
		{
			if(b[i]>c[i]){e+=(b[i]+c[i]);}
			else if(b[i]<c[i]){f+=(b[i]+c[i]);}
			else{e+=b[i];f+=c[i];}
		}
		printf("%d %d\n",e,f);
		e=0;f=0;
	}
	return 0;
}

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

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

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

C++: // cardgame.cpp
#include <iostream>
using namespace std;

int main(){
	int g,h;
	cin >> g;
	for(h=0;h<g;h++){
		int n=0;
		int i,j;
		int a[10000], b[10000];
		int a_point=0, b_point=0;
		cin >> n;
		for(i=0;i<n;++i){
				cin >> a[i];
				cin >> b[i];
		}
		for(j=0;j<n;++j){
			if(a[j]>b[j])
				a_point+=(a[j]+b[j]);
	        else if(a[j]<b[j])
				b_point+=(a[j]+b[j]);
			else if(a[j]==b[j]){
				a_point+=a[j];
				b_point+=b[j];
			}
		}
		cout << a_point << " " << b_point << endl;
	}
	return 0;	
}

C++: #include <stdio.h>

int main(void)
{

	int n;
	while(1){
		int n;
		int a=0,b=0;
		int ac,bc;

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

	}
	return 0;
}

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

int main(){
  int n;
  while(cin >> n){
    if(n==0)break;

    int A = 0, B = 0, a, b;
    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;
  }
}

C++: #include<iostream>
using namespace std;
int main() {
	int n,a,b,c,d;
	for(int i=0;i<5;i++){
		c=0;
		d=0;
		cin>>n;
		if(n==0){
			break;
		}
		for(int y=0;y<n;y++){
			cin>>a>>b;
			if(a>b){
				c=c+a+b;
			}else if(b>a){
				d=d+a+b;
			}else{
				c=c+a;
				d=d+b;
			}
		}
		cout<<c<<" "<<d<<endl;
	}
return 0;
}

C++: #include<stdio.h>
#include<stdlib.h>
#include<iostream>
using namespace std;

int main(){
	int a[10002],b[10002],i;
	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;
}