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 <cstdio>
#include <stack>

using namespace std;

int main(){
	stack<int> st;
	int k;
	int i,j;
	int result;
	char c;
	while(scanf("%c", &c) != EOF){
		if(c == ' ' || c == '\n'){
		} else if(c == '+'){
			i = st.top();
			st.pop();
			j = st.top();
			st.pop();
			result = i + j;
			st.push(result);

		} else if ( c == '-'){
			i = st.top();
			st.pop();
			j = st.top();
			st.pop();
			result = j - i;
			st.push(result);

		} else if ( c == '*'){
			i = st.top();
			st.pop();
			j = st.top();
			st.pop();
			result = i * j;
			st.push(result);

		} else {
			k = (int)(c - '0');
			st.push(k);
		}
	}
	cout << st.top() << endl;
}

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

int main(void) {
  int n;
  vector<int> A, B;
  int i = 0. j;
  int a, b;
  for(; i < 5; i++) {
    cin >> n;
    if(!n) break;
    A.push_back(0), B.push_back(0);
    for(j = 0; j < n; j++) {
      cin >> a >> b;
      if(a > b) A[i] += a;
      else if(a < b) B[i] += b;
      else A[i] += a, B[i] += b;
    }
  }
  for(int i = 0; i < A.size(); i++) cout << A[i] << " " << B[i] << endl;
}

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

int main(){
int a=0;
int uma=0;
int ushi=0;
int b=0;
int c=0;
int i=0;
while (true){
cin >> a;
if (a == 0){ break; }
else{
	while (true){
	if (i<a){
	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;
	}
	i = i + 1;
}if (i == a){ break; }
}
cout << uma << " " << ushi << endl;
uma = 0;
ushi = 0;
i = 0;
}
}
}

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

int main(){

    int a,b,acard,bcard,match;

    while(1){

      a = b = 0;

      cin >> match;

      if(match == 0){
        break;
      }



      for(int i=0;i < match; i++){
        cin >> acard >> bcard;
        if(acard > bcard){
          a += acard+bcard;
        }
        else if(acard < bcard){
          b += acard+bcard;
        }
        else{
          a += acard;
          b += bcard;
        }
      }

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

    }


    return 0;
}

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

int main() {
		int n;
		int a;
		int b;
	while( true ){
		int sa=0;
		int sb=0;
		cin >> n;
		
		if(n == 0){
			return 0;
		}
		for(int i=0;i<n;i++){
			cin >> a >> b;
			if(a>b){
				sa+=a+b;
			}else{
				if(a<b){
				sb+=a+b;	
				}else{
					sa+=a;
					sb+=b;
				}
			}
		}
		cout << sa << " " << sb << endl;
	}
}

C++: #include<iostream>
using namespace std;
int main(){
	while(true){
  int a=0,b=0,N,Card[2];
  cin >> N;
  if(N==0)
 	break;
  for(int i=0;i<N;i++){
  	cin >> Card[0] >> Card[1];
  	int sum=Card[0]+Card[1],truth=(Card[0]>Card[1]);
 	if(Card[0]!=Card[1]){
  	a+=sum*truth;
  	b+=sum*!(truth);
 	}
 	else{
 		a+=sum/2;
 		b+=sum/2;
 	}
  }
  cout << a << " "<< b << endl;
	}
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int n;
	int a,b;
	int A,B;
	for(int j=0;j<5;j++){
        cin>>n;
        if(n==0){break;}
	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++: a,b,c,d;main(n){for(s="%d %d\n";scanf(s+3,&n),n;printf(s,c,d))for(c=d=0;n--;*(a<b?&d:&c)+=a,*(b<a?&c:&d)+=b)scanf(s,&a,&b);}

C++: #include<stdio.h>
int main(void)
{
	int a[101] = { 0 }, b[101] = { 0 }, ruio = 0, hideo = 1, nagase = 0, masako = 0;
	int temp = 0, c[101] = { 0 }, k = 1;
	while (scanf("%d", &ruio) >0) {
		if (ruio == 0)return 0;
		for (int i = 1; i <= ruio; i++) {
			scanf("%d", &a[i]);
			c[a[i]]++;
		}
		hideo = nagase = ruio;
		for (int i = 1; i < ruio; i++) {
			for (int j = ruio; j > i; j--) {
				if (a[j] < a[j - 1]) {
					temp = a[j];
					a[j] = a[j - 1];
					a[j - 1] = temp;
				}
			}
		}
		for (int j = 1; j <= ruio * 2; j++) {
			if (c[j] == 0) {
				b[k] = j;
				k++;
			}
		}
		k = 0;
		while (nagase != 0 && hideo != 0) {
			k++;
			if (masako == 0) {
				masako = a[k];
				nagase--;
			}
			else if (masako < a[k]) {
				masako = a[k];
				nagase--;
			}
			else {
				masako = 0;
			}
			a[k] = 0;
			if (masako == 0) {
				masako = b[k];
				hideo--;
			}
			else if (masako < b[k]) {
				masako = b[k];
				hideo--;
			}
			else {
				masako = 0;
			}
			b[k] = 0;

		}
		printf("%d\n**%d\n**", hideo , nagase);
		for (int i = 1; i <= 100; i++) {
			a[i] = 0;
			b[i] = 0;
			c[i] = 0;
		}
		hideo = nagase = 0;
		masako = temp = 0;
		k = 1;
		
	}
	
}

C++: #include<iostream>

using namespace std;
#define MAX_N 10000

int N;//カードの枚数
int A[MAX_N],B[MAX_N];
  
int main(){
  while(true){
  int PA = 0,PB = 0;//A,Bのそれぞれの得点
  scanf("%d",&N);//配られるカードの枚数
  if(N==0)
    break;
  for(int i = 0;i < N;i++){
    scanf("%d %d",&A[i],&B[i]);
    if(A[i] > B[i])
      PA += A[i]+B[i];
    else if(A[i] < B[i])
      PB += A[i]+B[i];
  }
  printf("%d %d\n",PA,PB);
  }
  return 0;
 
}

C++: #include <iostream>

int A[10000], B[10000];

int main()
{
	int n, a, b;
	std::cin >> n;
	while (n != 0)
	{
		a = 0; 
		b = 0;
		for (int i = 0; i < n; i++)
		{
			std::cin >> A[i] >> B[i];
			if (A[i] > B[i])
			{
				a += A[i] + B[i];
			}
			if (A[i] == B[i])
			{
				a += A[i];
				b += B[i];
			}
			if (A[i] < B[i])
			{
				b += A[i] + B[i];
			}
		}
		std::cout << a << " " << b << std::endl;
		std::cin >> n;
	}
    return 0;
}

C++: #include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
int main(void){
int n,a,b,a1,b1;
while(1){
scanf("%d",&n);
a1=0;
b1=0;
if(n==0){break;}
for(int i=0;i<n;i++){
scanf("%d%d",&a,&b);
if(a>b){
a1=a+b;
}else if(b>a){
b1=a+b;
}else{
a1+=a;
b1+=b;
}
}
printf("%d %d\n",a1,b1);
}
return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <string>
#include <algorithm>
#include <string>
#include <climits>
#include <utility>

#define REP(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define REG(i, a, b) for (int (i) = ((int)(a)); (i) < ((int)(b)); i++)
#define ALL(V) (V).begin(), (V).end()
#define PRINT(STR) cout << (STR) << endl
#define ROUNDED(N) fixed << setprecision(N)
#define SPACE " "

typedef long long ll;
using namespace std;

int nextInt() { int n; cin >> n; return n; }
double nextDouble() { double d; cin >> d; return d; }
string nextString() { string str; cin >> str; return str; }

int main() {
	cin.tie(0); //対話型には使えない
	ios::sync_with_stdio(false); //printfと共には使えない
	while (true) {
		int n = nextInt();
		if (!n) break;
		int a_sum = 0, b_sum = 0;
		for (int i = 0; i < n; i++) {
			int a = nextInt(), b = nextInt();
			if (a > b) a_sum += a + b;
			else b_sum += a + b;
		}
		cout << a_sum << SPACE << b_sum << endl;
	}
	return 0;
}

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

using namespace std;

void func(int n)
{
    int Acard, Bcard;
    int Ascore = 0, Bscore = 0;
    for (int i = 0; i < n; ++i) {
        cin >> Acard >> Bcard;
        if (Acard > Bcard) {
            Ascore += Acard + Bcard;
        } else if (Acard < Bcard) {
            Bscore += Acard + Bcard;
        } else if (Acard == Bcard) {
            Ascore += Acard;
            Bscore += Bcard;
        }
    }
    cout << Ascore << " " << Bscore << '\n';
    return;
}

int main()
{
    for (;;) {
        int n;
        cin >> n;
        if (n == 0) break;
        func(n);
    }
    return 0;
}