Go: package main

import "fmt"

func main() {
	for {
		var a, b, n int
		fmt.Scanf("%d", &n)

		if n == 0 {
			return
		}

		for i := 0; i < n; i++ {
			var cardA, cardB int
			fmt.Scanf("%d %d", &cardA, &cardB)

			if cardA > cardB {
				a += cardA + cardB
			} else if cardB > cardA {
				b += cardA + cardB
			} else {
				a += cardA
				b += cardB
			}
		}

		fmt.Println(a, b)
	}
}

Python: import sys
def main():
    for line in sys.stdin:
        n = int(line)
        if n == 0:
            break
        else:
            A = []
            B = []
            for _ in range(n):
                hoge, fuga = map(int, input().split())
                A.append(hoge)
                B.append(fuga)

            a, b = 0, 0
            for x in range(n):
                if A[x] == B[x]:
                    a += A[x]
                    b += B[x]
                else:
                    piyo = A[x] + B[x]
                    if A[x] > B[x]:
                        a += piyo
                    else:
                        b += piyo
            print(a, b)


if __name__ == "__main__":
    main()

Python: def input_n(inputfile,outputfile):
	while True:
		n = inputfile.readline()
		n = int(n)
		if n == 0:
			break
		battle(inputfile,outputfile,n)

def battle(inputfile,outputfile,n):
	apoint = 0
	bpoint = 0
	for i in range(n):
		a , b = inputfile.readline().split()
		a = int(a)
		b = int(b)
		if a > b:
			apoint += (a + b)
		elif b > a:
			bpoint += (a + b)
		else:
			apoint += a
			bpoint += b
		print >> outputfile, apoint, bpoint

if __name__ == "__main__":
	import sys
	input_n(sys.stdin,sys.stdout)

Python: while True:
    n = int(input())
    if n == 0:
        break
    a = 0
    b = 0
    for i in range(n):
        input_card = input().split()
        if int(input_card[0]) > int(input_card[1]):
            a += int(input_card[0]) + int(input_card[1])
        elif int(input_card[0]) < int(input_card[1]):
            b += int(input_card[0]) + int(input_card[1])
        else:
            a += int(input_card[0])
            b += int(input_card[1])
    print(f"{a} {b}")

Python: while True:
    n = int(input())
    if n == 0:break
    sum_a = sum_b = 0
    for i in range(n):
        a,b = map(int, raw_input().split())
        if a > b:sum_a = sum_a + a + b
        elif a < b:sum_b = sum_b + a + b
        else:
            sum_a = sum_a + a
            sum_b = sum_b + b
    print(sum_a,sum_b)

Python: while True:
    n = int(input())
    if n == 0:
        break
    pointA, pointB = 0, 0
    for i in range(n):
        cardA, cardB = map(int, input().split())
        if cardA == cardB:
            pointA += cardA
            pointB += cardB
        elif cardA > cardB:
            pointA += cardA + cardB
        else:
            pointB += cardA + cardB
    print(pointA, pointB)

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

C++: #include <stdio.h>

int main(){
	int a[10000], b[10000];
	int sumA, sumB;
	int n;
	int i;
	
	sumA = 0;
	sumB = 0;
	
	while(1){
		scanf("%d", &n);
		
		if(n==0) break;
		
		for(i=0; i<n; i++){
			scanf("%d %d", a+i, b+i);
		}
		
		/*
		for(i=0; i<n; i++){
			printf("%d %d\n", a[i], b[i]);
		}
		*/
		
		for(i=0;i<n;i++){
			if(a[i] > b[i]) sumA += a[i]+b[i];
			if(a[i] < b[i]) sumB += a[i]+b[i];
			if(a[i] == b[i]){
				sumA += a[i];
				sumB += b[i];
			}
		}
		
		printf("%d %d\n", sumA, sumB);
		
		sumA = 0;
		sumB = 0;
		
	};
	
	return 0;
}

C++: #include <stdio.h>

int main(){
int n,i;
int a,b,f,t;

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

return 0;
}

C++: #include<iostream>
#include<vector>
int main() {
	int n;
	int g = 0;
	int s = 0;
	int a, b;
	while (true)
	{
		std::cin >> n;
		if (n == 0)
			break;
		for (int i = 0; i < n; ++i) {
			std::cin >> a >> b;
			if (a == b)g += a, s += b;
			if (a > b) g += a + b;
			if (a < b) s += b + a;
		}
		std::cout << g << " " << s << std::endl;
	}
	return 0;
}

C++: #include <stdio.h>

int main(void)
{
	int i;
	int a[10000], b[10000];
	int n;
	int ans_a, ans_b;
	
	while (1){
		
		ans_a = 0;
		ans_b = 0;
		
		scanf("%d", &n);
		
		if (n == 0){
			break;
		}
		
		for (i = 0; i < n; i++){
			scanf("%d %d", &a[i], &b[i]);
		}
		
		for (i = 0; i < n; i++){
			if (a[i] > b[i]){
				ans_a += (a[i] + b[i]);
			}
			else if (a[i] < b[i]){
				ans_b += (a[i] + b[i]);
			}
			else {
				ans_a += a[i];
				ans_b += b[i];
			}
		}
		printf("%d %d\n", ans_a, ans_b);
	}
	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>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n, a, b;
    int as = 0, bs = 0;
    while(cin >> n){
        rep(i,n){
            cin >> a >> b;
            if(a > b){
                as += (a + b);
            }else if(a < b)
                bs += (a + b);
            else{
                as += a;
                bs += b;
            }
        }
        cout << as << ' ' << bs << endl;
    }
}

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

C++: #include <iostream>

int main(int argc, char **argv)
{
	int a, b;
	int n;
	int acards[10000],bcards[10000];
	while(true){
		a = 0;
		b = 0;
		std::cin >> n;
		if(n == 0){
			break;
		}
		for(int i = 0; i < n; i++){
			std::cin >> acards[i] >> bcards[i];
			if(acards[i] < bcards[i]){
				b += bcards[i] + acards[i];
			}
			if(acards[i] > bcards[i]){
				a += bcards[i] + acards[i];
			}
			if(acards[i] == bcards[i]){
				a += acards[i];
				b += bcards[i];
			}
		}
		std::cout << a << " " << b << std::endl;
	}
	return 0;
}

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