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<cstdio>
using namespace std;
int main(){
  int n,a,b,counta=0,countb=0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a >> b;
    if(a>b){
      counta=counta+a+b;
    } else if(a<b){
      countb=countb+a+b;
    } else if(a==b){
      counta+=a;
      countb+=a;
    }
  }
  cout << counta << " " << countb << endl;
  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 <bits/stdc++.h>
using namespace std;
 
int main() {
    int n,a,b,countA=0,countB=0;
    cin>>n;
    do{
        for(int i=0;i<n;i++){
            cin>>a>>b;
            if(a>b){
                countA+=(a+b);
            }else if(a<b){
                countB+=(a+b);
            }//a==b
        }
        cout<<countA<<" "<<countB;
        cout<<"\n";
        countA=0,countB=0;
        cin>>n;
        if(n==0)break;
    }while(1);
    return(0);
}

C++: #include<stdio.h>
void judge(int n, int a[], int b[], int *result1, int *result2) {
	while (--n >= 0) {
		if (a[n] > b[n]) {
			*result1 += a[n] + b[n];
		}
		else if (a[n] < b[n]) {
			*result2 += a[n] + b[n];
		}
		else if (a[n] == b[n]) {
			*result1 += a[n];
			* result2 += b[n];
		}
	}
}
int main() {
	int a[10];
	int b[10];
	int n, t = 0;
int i;
	int result1 = 0, result2 = 0;
	int result[10][2];
	do {
		scanf_s("%d", &n);
		for (i = 0; i < n; i++) {
			scanf_s("%d %d", &a[i], &b[i]);
		}
		judge(n, a, b, &result1, &result2);
		result[t][0] = result1;
		result[t][1] = result2;
		result1 = 0;
		result2 = 0;
		t++;
	} while (n != 0);

	for (i = 0; i < t-1;i++) {
		printf("%d %d\n", result[i][0], result[i][1]);
	}

	return 0;
}

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

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

C++: #include <iostream>

int main(){
    
    while(true){
    
    int num,a,b,resa=0,resb=0;
    
    std::cin>>num;
    
    if(num==0)
        break;
    
    for(int i=0;i<num;i++){
        std::cin>>a>>b;
        if(a>b)
            resa+=a+b;
        else
        if(a<b)
            resb+=a+b;
        else
            if(a==b)
                resa+=a,resb+=b;
    }
    
    std::cout<<resa<<' '<<resb<<std::endl;
        
    }
    
    return 0;
}

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 m,a,b;int x=0,y=0;
	cin>>m;
	
	for(int i=0;i<m;i++){
	cin>>a>>b;
	
	if(a>b){
	x+=+a+b;
	}
	else if(a<b){
	y+=a+b;
	}
	else{
	x+=a;y+=b;
	}
	}
	cout<<x<<" "<<y<<endl;

return 0;
}

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

C++: #include <iostream>

int main(){
    int n, a, b, apt, bpt;
    while(std::cin >> n, n){
        for(apt = bpt = 0; n; n--){
            std::cin >> a >> b;
            if(a > b)
                apt += a + b;
            else if(b > a)
                bpt += a + b;
            else{
                apt += a;
                bpt += b;
            }
        }
        std::cout << apt << ' ' << bpt << std::endl;
    }
    return 0;
}