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<iostream>
#include<algorithm>
using namespace std;

int main(){

  int a=0,b=0,x,y,n;

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

    a=b=0;

    for(int i=0;i<n;i++){
      cin >> x >> y;

      if(x!=y){
	if(x==max(x,y)) a=a+x+y;
	if(y==max(x,y)) b=b+x+y;
      }

      else{
	a=x+a;
	b=x+b;
      }

    }
    cout << a << ' ' <<  b << endl;
  }
}

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

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

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

int main(){
	int a;
	int uma;
	int ushi;
	int b;
	int c;

	while (true){
		cin >> a;
		if (a == 0){ break; }
		else{
			for (int i; i < a; i++){
				cin >> b;
				cin >> c;
				if (b>c){
					uma = uma + b + c;
				}
				if (b == c){
					uma = uma + b;
					ushi = ushi + c;
				}
				else{
					ushi = ushi + b + c;
				}
			}
		}
		cout << uma << " " << ushi << endl;
		uma = 0;
		ushi = 0;
	}
}

C++: #include <stdio.h>

int N ;
int a ;
int b ;
long long int point[2] ;

void init ( ) ;

int main ( )
{
	while ( scanf ( "%d" , &N ) == 1 ) {
		init ( ) ;
		for ( int i = 0 ; i < N ; i++ ) {
			scanf ( "%d %d" , &a , &b ) ;
			if ( a > b ) {
				point[0] += ( a + b ) ;
			}
			else if ( a == b ) {
				point[0] += a ;
				point[1] += b ;
			}
			else {
				point[1] += ( a + b ) ;
			}
		}
		printf ( "%lld %lld\n" , point[0] , point[1] ) ;
	}
	return 0 ;
}

void init ( )
{
	point[0] = point[1] = 0 ;
}

C++: #include <stdio.h>

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

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

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PA;
using namespace std;
#define MAX 1e7
int main(){
    int n;
    while(cin >> n,n){
        vi v(n+1,0);
        vi v2(n+1,0);
        int ans1 = 0; int ans2 =0;
        rep(i,n){
            cin >> v[i] >> v2[i];
            if(v[i]>v2[i])
                ans1+=v[i]+v2[i];
             if(v[i] < v2[i])
                ans2 += v[i]+v2[i];
             if(v[i] == v2[i]){
                ans1+=v[i]; ans2+= v2[i];}
        }
        cout << ans1 << " " << ans2 << endl;
    }
}

C++: #include <stdio.h>
int main(void){
  int a,b,c,d,e,f,i;
  i=0;  
  a=1;
  b=3;
  c=4;
  d=5;
  e=8;
  f=9; 
  scanf("%d\n",&b);
  scanf("%d%d\n",&f,&a);
  scanf("%d%d\n",&d,&c);
  scanf("%d%d\n",&i,&e);
  scanf("%d\n",&b);
  scanf("%d%d\n",&f,&a);
  scanf("%d%d\n",&d,&c);
  scanf("%d%d\n",&a,&i);
  scanf("%d\n",&b);
  scanf("%d",&b);
  scanf("%d%d",&f,&a);
  scanf("%d%d",&d,&d);
  scanf("%d%d",&a,&e);
  printf("%d%d",f+f+a,e);
  printf("%d%d",c*d,i);
  printf("%d%d",b*d,c*c+a);
  return 0;
}

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

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

int main()
{
	int x,y,n;
	while(cin>>n, n)
	{
		int a=0, b=0;
		while(n--)
		{
			cin>>x>>y;
			if(x<y) { b+=x+y;}
			else if(x>y) { a+=x+y;}
			else if(x==y) {a+=a; b+=b;}
		}
             cout<<a<<b<<endl;
	}
		
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main()
{
  int n;
  int SCORE_A, SCORE_B;
  while (1) {
    scanf("%d", &n);
    if (!n) return 0;
    SCORE_A = SCORE_B = 0;
    for (int i = 0; i < n; i++) {
      int a, b;
      cin >> a >> b;
      if (a == b) {
        SCORE_A += a;
        SCORE_B += b;
      }
      else (a > b ? SCORE_A : SCORE_B) += (a + b);
    }
    cout << SCORE_A << " " << SCORE_B << endl;
  }
}

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


int main(void){
    int n;
    while(true){
        cin >> n;
        if(n==0){
            break;
        }
        int number_A, number_B;
        int sum_A, sum_B;
        sum_A = sum_B = 0;
        for(int i = 0; i < n; i++){
            cin >> number_A >> number_B;
            if(number_A > number_B){
                sum_A += number_A + number_B;
            }else if(number_A == number_B){
                sum_A += number_A;
                sum_B += number_B;
            }else{
                sum_B += number_A + number_B;
            }
        }
        cout << sum_A << " " << sum_B << endl;


    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int a, b[100] = { 0 }, c[100] = { 0 },d=0,e=0;
	cin >> a;
	for (int i = 0; i < a;i++){
		cin >> b[i] >> c[i];
	}
	for (int i = 0; i < a; i++){
		if (b[i]>c[i]){
			d = d + b[i] + c[i];
		}
		else if (b[i] < c[i]){
			e = e + b[i] + c[i];
		}
		else if (b[i] == c[i]){
			d = d + b[i];
			e = e + c[i];
		}
	}
	cout << d << " " << e;
	return 0;
}