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,s1=0,s2=0,a,b;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a>>b;
		if(a>b)s1+=a+b;
		else if(a<b)s2+=a+b;
		else{
			s1+=a;
			s2+=b;
		}
	}
	cout<<s1<<" "<<s2<<'\n';
	return 0;
}

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

using namespace std;

int main() {
	int a, b, n;
	vector<int*> scores;

	while (cin >> n) {
		if (n == 0)
			break;
		int *score = new int(2);
		score[0] = 0;
		score[1] = 0;
		for (int i = 0; i < n; i++) {
			cin >> a >> b; 
			if (a > b)
				score[0] += a + b;
			if (a < b)
				score[1] += a + b;
			if (a == b) {
				score[0] += a;
				score[1] += b;
			}
		}
		scores.push_back(score);
	}

	for (int i = 0; i < scores.size(); i++) {
		cout << scores[i][0] << " " << scores[i][1] << endl;
	}

	return 0;
}

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

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

C++: #include <iostream>
#include <string>
using namespace std;
int main(){
int n;
int a;
int b;
int c;
int d;
int e;
while(cin >>n){
c=0;
d=0;
e=0;
while(e<n){
cin >>a;
cin >>b;
if(a>b){c=c+a+b;}
if(a==b){c=c+a; d=d+b;}
if(a<b){d=d+a+b;}
e=e+1;}
cout << c <<" "<<d<<endl
}

}

C++: #include <iostream>

int score_a, score_b;

int main(void)
{
    int n, data_a, data_b;

    while(1)
    {
        std::cin >> n;
        if (n == 0) break;
        score_a = 0;
        score_b = 0;
        for(; n > 0 ; n--) {
            std::cin >> data_a;
            std::cin >> data_b;
            if (data_a > data_b) {
                score_a += (data_a + data_b);
            } else if(data_a < data_b) {
                score_b += (data_a + data_b);
            } else {
                score_a += data_a;
                score_b += data_b;
            }
        }
        std::cout << score_a << " " << score_b << std::endl;
    }

    return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
  
  int n;
  while(cin >> n && n>0){
  int a,b;
  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;
}
}

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

C++: main(n,a,b,A,B){for(;A=B=0,scanf("%d", &n),n;printf("%d %d\n",A,B))for(;n--;)scanf("%d%d",&a,&b),(a>b)?A+=a+b:(a<b)?B+=a+b:(A+=a,B+=b);}

C++: #include <cstdio>

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

C++: #include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n,a[10000],b[10000],countA,countB;
    while(cin>>n,n!=0){
        countA=0,countB=0;
        for(int i=0;i<n;i++){
            cin>>a[i]>>b[i];
            if(a[i]>b[i]){
                countA+=(a[i]+b[i]);
            }else if(a[i]<b[i]){
                countB+=(a[i]+b[i]);
            }else{//a[i]==b[i]
                countA+=a[i];
                countB+=b[i];
            }
        }
        cout<<countA<<" "<<countB<<endl;
    }
    return(0);
}

C++: #include<stdio.h>

int main(void){
	int a_point,b_point,i,a_card,b_card,n;
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		a_point=0,b_point=0;
		for(i=0;i<n;n++){
			scanf("%d %d",&a_card,&b_card);
			if(a_card>b_card) a_point+=a_card+b_card;
			else if(a_card<b_card) b_point+=a_card+b_card;
			else {
				a_point+=a_card;
				b_point+=b_card;
			}
			printf("%d %d\n",a_point,b_point);
		}
	return 0;
}

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

C++: #include <iostream>

using namespace std;

int main() {
    while(true) {
        int N;
        cin >> N;
        if(!N) break;

        int a = 0, b = 0;
        while(N--) {
            int i, j;
            cin >> i >> j;
            if(i > j) a += i+j;
            else if(i < j) b += i+j;
            else {
                a += i;
                b += j;
            }
        }
        cout << a << ' ' << b << endl;
    }
    return 0;
}

C++: #include <stdio.h>
#include <iostream>
using namespace std;
int main (){
while (1){
int i,ny[100]={0},ny2[100]={0},sum=0,sum2=0;
scanf ("%d",&i);
if (i==0)break;
for (int s=0;s<i;s++){
        scanf ("%d%d",&ny[s],&ny2[s]);
}
for (int s=0;s<i;s++){
        if (ny[s]==ny2[s]){
        sum=sum+ny[s];
        sum2=sum2+ny2[s];
        }
        else if (ny[s]>ny2[s]){
                sum=sum+ny[s]+ny2[s];
        }
        else {
                sum2=sum2+ny[s]+ny2[s];
        }
}
printf ("%d %d\n",sum,sum2);
}
return -1;
}

C++: #include <iostream>

int main(int argc, char **argv){
	int n = 0;
	while(std::cin >> n, n > 0){
		int a = 0;
		int b = 0;
		int a_score = 0;
		int b_score = 0;

		for(int i = 0; i < n; i++){
			std::cin >> a >> b;
			if(a > b){
				a_score += a + b;
			}
			else if(a < b){
				b_score += a + b;
			}
			else{
				a_score += a;
				b_score += b;
			}
		}

		std::cout << a_score << " " << b_score << std::endl;
	}
	return 0;
}

C++: #include <stdio.h>
#include <iostream>

using namespace std;

int main() {

	int c;
	int a,b;
	int tokuten1 = 0;
	int tokuten2 = 0;
	
	while (cin >> c) {
		if (c == 0) {
			break;
		}
		for (int i = 0; i < c; i++) {
			cin >> a >> b;
			if (a > b) {
				tokuten1 += (a + b);
			} else if (a < b) {
				tokuten2 += (a + b);
			} else {
				tokuten1 += a;
				tokuten2 += b;
			}
		}
		cout << tokuten1 << " " << tokuten2 << endl;
	}
	return 0;
}

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;
}