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

C++: #include <bits/stdc++.h>

using namespace std;

int main()
{
    int data_num;

    while (cin >> data_num) {
        if (data_num == 0) break;

        int player1_ans = 0;
        int player2_ans = 0;
        
        for (int i = 0; i < data_num; ++i) {
            int data1, data2;
            
            cin >> data1 >> data2;
            
            if (data1 > data2) {
                player1_ans += data1 + data2;
            } else if (data1 == data2) {
                player1_ans += data1;
                player2_ans += data2;
            } else {
                player2_ans += data1 + data2;
            }

        }

        cout << player1_ans << " " << player2_ans << endl;

    }
    
    return 0;
}

C++: #include<cstdio>

using namespace std;

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

C++: #include <iostream>

using namespace std;

int main(){
    int n;
    while(1){
        cin >> n;
        if(n == 0){
            break;
        }
        int a;
        int b;
        int a_result = 0;
        int b_result = 0;
        for(int i = 0; i < n; i++){
            cin >> a >> b;
            if(a > b){
                a_result += a + b;
            }
            else if(a < b){
                b_result += a + b;
            }
            else{
                a_result += a;
                b_result += b;
            }
        }
        cout << a_result << " " << b_result << endl;
    }
}

C++: #include <stdio.h>

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

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

int main(){
    int a, b, lcm, gcd;
	while(std::cin >> a >> b){
		int _a = a, _b = b;
		while(1){
			if(_b % _a == 0){
				gcd = _a;
				break;
			}
			_a = _a % _b;
			std::swap(_a, _b);
		}
		lcm = a / gcd * b;
		std::cout << gcd << ' ' << lcm << std::endl;
	}
	return 0;
}

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

int main()
{
    int n;

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

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

int main () {
    int n, i,A,B, resa =0, resb =0;
    while(cin >> n,n){
        for(i=0;i<n;i++){
           　cin >> A >> B;
             (A > B)? resa +=A:resb+=B;
             if(A==B) {resa += A; resb +=B};
        }
　　　　cout << resa << " " << resb << endl;
    }
}

C++: #include <iostream>

int main() {
    int a=0;
    while(true){
        int b=0;
        int c=0;
        std::cin>>a;
        if(a==0)
            break;
        for(int i=0;i<a;i++){
            int x,y;
            std::cin>>x>>y;
            if(x>y){
                b+=x+y;
            }else if(x<y){
                c+=x+y;
            }else if(x==y){
                b+=x;
                c+=y;
            }
        }
        std::cout<<b<<" "<<c<<std::endl;
    }
    return 0;
}

C++: #include <stdio.h>

int main(){
	long long Right_Point = 0;
	long long Left_Point = 0;

	int Right_Card, Left_Card;

	int kaisuu;

	Right_Point = 0;
	Left_Point = 0;
	scanf("%d", &kaisuu);
	for (int a = 0; a < kaisuu; a++){
		scanf("%d%d", &Right_Card, &Left_Card);
		if (Right_Card == Left_Card){
			Right_Point += Right_Card;
			Left_Point += Left_Point;
		}
		else if (Right_Card < Left_Card){
			Left_Point = Left_Point + (Right_Card + Left_Card);
		}
		else
			Right_Point = Right_Point + (Right_Card + Left_Card);
	}
	printf("%d %d\n", Right_Point, Left_Point);
	return 0;
}

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

int main(){
  int pnt_a = 0;
  int pnt_b = 0;
  int car_a;
  int car_b;
  int num;

  while(cin >> num){
    if(!num) break;
    for(; num; num--){
      cin >> car_a;
      cin >> car_b;
      if(car_a < car_b) pnt_b += (car_a + car_b);
      else if (car_a > car_b) pnt_a += (car_a + car_b);
      else {pnt_a += car_a; pnt_b += car_b;}
    }

    cout << pnt_a << " " << pnt_b << "\n";
  }

return 0;
}

C++: #include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n;
	while(1){
		cin>>n;
		if(!n)break;
		int a,b;
		int apoint=0,bpoint=0;
		rep(i,n){
			cin>>a>>b;
			if(a>b)apoint+=(a+b);
			else if(a<b)bpoint+=(a+b);
			else{
				apoint+=a;
				bpoint+=b;
			}
		}
		cout<<apoint<<" "<<bpoint<<endl;
	}
	return 0;
}

C++: #include <iostream>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main() {
    int n, a, b;
    while (cin >> n) {
        int apt = 0, bpt = 0;
        rep(i, n) {
            cin >> a >> b;
            if (a > b) {
                apt += a + b;
            }
            else if (a < b) {
                bpt += a + b;
            }
            else {
                apt += a;
                bpt += b;
            }
        }
        cout << apt << " " << bpt << endl;
    }
    return 0;
}

C++: //============================================================================
// Name        : svdzva.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
#include<algorithm>
using namespace std;

int main() {
	int n, play1 = 0, play2 = 0, card1[10000], card2[10000];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> card1[i] >> card2[i];
		if (card1[i] > card2[i]) {
			play1 = play1 + card1[i] + card2[i];
		} else if (card1[i] < card2[i]) {
			play2 = play2 + card2[i] + card1[i];
		} else {
			play1 = play1 + card1[i];
			play2 = play2 + card2[i];
		}
	}

	cout << play1 << " " << play2 << endl;
	return 0;
}

C++: #include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
	long long int a,b,n,x,y;
while(1){	a=0;
	b=0;
	scanf("%lld",&n);
	if(n==0) break;
	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 () {
    int n, i,A,B, resa =0, resb =0;
    while(cin >> n,n){
        resa=0;resb=0;
        for(i=0;i<n;i++){
             cin >> A >> B;
             (A > B)? resa +=(A+B):resb+=(A+B);
             if(A==B) {resa += A; resb +=B;};
        }
    cout << resa << " " << resb << endl;
    }
}

C++: #include<iostream>

int main(){
	while(1){
		int n;
		std::cin >> n;
		if(n == 0)break;
		int a = 0, b = 0;
		for(int i = 0; i < n; ++i){
			int a1,b1;
			std::cin >> a1 >> b1;
			if(a1 > b1) a += a1 + b1;
			else if(a1 < b1) b += a1 + b1;
		}
		std::cout << a << " " << b << std::endl;
	}
	return 0;
}