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>
using namespace std;
int main() {
	int n, play1 = 0, play2 = 0, card1[10000], card2[10000];
	while (true) {
		cin >> n;
		if (n == 0)
			break;
		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<iostream>
using namespace std;
int main(){
int n;
while(cin>>n){
int a[10000]={},b[10000]={};
int ap=0,bp=0;
	for(int i=0;i<n;i++){
	cin>>a[n]>>b[n];
	if(a[n]>b[n]){
		ap+=a[n]+b[n];
	}else if(a[n]<b[n]){
		bp+=a[n]+b[n];
	}else{
		ap+=a[n];
		bp+=b[n];
	}
	cout<<ap<<" "<<bp<<endl;
}

return 0;
}

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

C++: #include<iostream>
#include<vector>
int main() {
	int vec=0;
	int n;
	int a=0;
	int b=0;
	int game_a, game_b;
	std::vector<int>veca, vecb;
	while (1) {
		std::cin >> n;
		if (n == 0)break;
		else {
			for (int i = 0; i < n; ++i) {
				std::cin >> game_a>>game_b;
				if (game_a > game_b)a += game_a + game_b;
				else b += game_a + game_b;
			}
			veca.push_back(a); vecb.push_back(b); a = 0; b = 0;
		}
	}
	for (int i = 0; i < veca.size(); ++i) {
		std::cout << veca[i] <<" "<<vecb[i]<< std::endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
  int n,a,b,A,B;
  cin>>n;
  A=B=0;
  while(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;
}

C++: #include <stdio.h>
int main(){
int n,l,r,a,b;
while(1){
scanf("%d",&n);
if(n==0)return 0;
a=b=0;
while(n--){
scanf("%d%d",&l,&r);
if(l>=r)a+=l+r;
if(r>=l)b+=l+r;
}
printf("%d %d\n",a,b);
}
}

C++: #include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n,a,b,countA=0,countB=0;
    cin>>n;
    if(n!=0){
    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);
    }
    cout<<endl;
}

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[2] = {0};
	int n,i,x,y;
	scanf("%d", &n);
	while (n != 0){
		a[0] = 0;
		a[1] = 0;
		for (i = 0; i < n; i++){
			scanf("%d %d", &x, &y);
			if (x>y)a[0] = a[0] + x + y;
			else if (x < y)a[1] = a[1] + x + y;
			else{
				a[0] = a[0] + x;
				a[1] = a[1] + y;
			}
		}
		printf("%d %d\n", a[0], a[1]);
		scanf("%d", &n);
	}
	return 0;

}

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

int main()
{
  while(1){
    int n;
    cin>>n;

    if(n){
      int a[10000];
      int b[10000];

      for(int i=0;i>n;i++){
		cin>>a[i]>>b[i];
      }

      int ap=0,bp=0;
      
      for(int i=0;i>n;i++){
		if(a[i]>b[i]){ap+=a[i]+b[i];}
		else if(a[i]<b[i]){bp+=a[i]+b[i];}
		else{ap+=a[i];bp+=b[i];}
      }
      
      cout<<ap<<" "<<bp<<endl;
    }
    else{break;}
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	while (1){
		int n, a[15] = {0}, b[15] = {0}, 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<iostream>
using namespace std;
int main(){
	int n;
	int a,b;
	int A,B;
	cin>>n;
	if(n==0){break;}
	while(true){
	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 <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",&a,&b);
scanf("%d",&n);
}
return 0;
}

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

int main(){
    int n;
    int a=0,b=0;
    int at[10000]={0},bt[10000]={0};
    int j=0;
    for(;;){
        scanf("%d",&n);
        if(n==0)break;
        for(int i=0;i<n;i++){
            scanf("%d%d",&a,&b);
            if(a>b){
                at[j]+=(a+b);
            }else if(b>a){
                bt[j]+=(a+b);
            }else{
                at[j]+=a;
                bt[j]+=b;
            }
        }j++;
    }
    for(int i=0;i<j;i++){
        printf("%d %d\n",at[i],bt[i]);
    }
    return 0;
}

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

int main(){
int n,a,b;
int sumA=0,sumB=0;
while(cin>>n){
for(int i=0;i<n;i++){
cin>>a>>b;
if(a>b){
sumA+=a;
sumA+=b;
}
if(a==b){
sumA+=a;
sumB+=b;
}
if(a<b){
sumB+=a;
sumB+=b;
}}}

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

C++: #include<stdio.h>
int main()
{
	int i1, i2, b, k, n, m[2], **c, max[2], min[2];
	scanf("%d", &n);
	m[0] = n;
	m[1] = n;
	c    = new int * [2];
	c[0] = new int [n];
	c[1] = new int [n];
	for (i1 = 0; i1 < n; i1++)
		scanf("%d", &c[0][i1]);
	qsort(c[0], n, sizeof(int), compare);
	min[0] = 0;
	max[0] = n - 1;
	k = 0;
	for (i1 = 1; i1 < c[0][0]; i1++) {
		c[1][k] = i1;
		k++;
	}
	for (i1 = 0; i1 < n-1; i1++) {
		for (i2	= c[0][i1]+1; i2 < c[0][i1+1]; i2++) {
			c[1][k] = i2;
			k++;
		}
	}
	min[1] = 0;
	max[1] = n - 1;
	k       = 1;
	b       = c[0][0];
	min[0]  = 1;
	c[0][0] = 0;
	m[0]--;
	while (m[0] > 0 && m[1] > 0) {
		if (b > c[k][max[k]])
			b = -1;
		else {
			for (i1 = min[k]; i1 <= max[k]; i1++) {
				if (c[k][i1] > b) {
					b        = c[k][i1];
					c[k][i1] = 0;
					m[k]--;
					if (i1 == min[k]) {
						for (i2 = min[k]+1; i2 <= max[k]; i2++) {
							if (c[k][i2] > 0) {
								min[k] = i2;
								break;
							}
						}
					}
					else if (i1 == max[k]) {
						for (i2 = max[k]-1; i2 >= min[k]; i2--) {
							if (c[k][i2] > 0) {
								max[k] = i2;
								break;
							}
						}
					}
					break;
				}
			}
		}
		k = (k + 1) % 2;
	}
	printf("%d\n%d\n", m[1], m[0]);

	return 0;
}

C++: #include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <time.h>
#include <stdlib.h>
using namespace std;

int main(){
	while(1){
		int a,b,n,aa,bb;
		cin >> n;
		if(n==0) return 0;
		aa=0;
		bb=0;
		for(int i=0;i<n;i++){
			cin >> a;
			cin >> b;
			if(a>b) aa+= a+b;
			else if(b>a) bb += a+b;
			else{
				aa+=a;
				bb+=b;
			}
		}
		printf("%d %d\n",aa,bb);
	}
	return 0;
}