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 <cstdio>
using namespace std;

void opera(int n);
int main(void)
{
	int n;
	
	
	while (1){
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		else {
			opera(n);
		}
	}
	
	return (0);
}

void opera(int n)
{
	int a_sum = 0;
	int b_sum = 0;
	
	
	for (int i = 0; i < n; i++){
		int a, b;
		scanf("%d %d", &a, &b);
		
		if (a == b){
			a_sum += a;
			b_sum += b;
		}
		else if (a > b){
			a_sum = a_sum + a + b;
		}
		else {
			b_sum = b_sum + a + b;
		}
	}
	
	printf("%d %d\n", a_sum, b_sum);
}

C++: #include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

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

        int x = 0;
        int y = 0;
        for(int i=0; i<n; ++i){
            int a, b;
            cin >> a >> b;
            if(a > b)
                x += a + b;
            else if(a < b)
                y += a + b;
            else{
                x += a;
                y += b;
            }
        }

        cout << x << ' ' << y << endl;
    }
}

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

using namespace std;

int main(){
  int n;
  while(scanf("%d", &n), n){
    int A = 0;
    int B = 0;

    for(int i = 0; i < n; i++){
      int a, b;
      scanf("%d%d", &a, &b);
      if(a < b) B += a + b;
      if(a > b) A += a + b;
      if(a == b){ A += a; B += b; }
    }

    printf("%d %d\n", A, B);
  }

  return 0;
}

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

int main(){
int n,a,b;
int sumA=0,sumB=0;
while(cin>>n){
	if(n==0)break;
	sumA=0,sumB=0;
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;
}}
printf("%d %d",sumA,sumB);
}}

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

int main() {
	int n = 0;
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		int asum = 0, bsum = 0;
		int a[10000], b[10000];
		for (int i = 0; i < n; i++) {
			cin >> a[i] >> b[i];
			if (a[i] > b[i]) {
				asum += a[i] + b[i];
			}
			else if (a[i] < b[i]) {
				bsum += a[i] + b[i];
			}
			else {
				asum += a[i], bsum += b[i];
			}
		}
		cout << asum <<" "<< bsum << endl;
	}
}

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

C++: #include <iostream>
using std::cout;
using std::endl;
using std::cin;

int main() {
	while (true) {
		int n;
		cin >> n;
		if (n == 0) {
			break;
		}
		int sa = 0,sb = 0;
		while (n--) {
			int a,b;
			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>
#include<vector>
int main() {
	std::vector<int> a, b;
	while (true) {
		int n;
		int as = 0; int  bs = 0;
		std::cin >> n;
		if (!n) {
			break;
		}
		for (int i = 0; i < n;){
			int n, m;
			std::cin >> n >> m;
			if (n > m) {
				as += n + m;
			}
			if (m > n) {
				as += n + m;
			}
		}
		a.push_back(as);
		b.push_back(bs);
	}
	for (int i = 0; i < a.size(); ++i) {
		std::cout << a[i] << " " << b[i] << std::endl;
	}
return 0;
}

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

int main() {
	int n;
	cin>>n;
	
	int sum_a=0,sum_b=0;
	for(int i=0;i<n;i++){
		int a,b;
		cin>>a>>b;
		
		if(a>b){
			sum_a+=a+b;
		} else if(a<b){
			sum_b+=a+b;
		} else{
			sum_a+=a;
			sum_b+=b;
		}
	}
	
	cout<<sum_a<<" "<<sum_b<<endl;
	return 0;
}

C++: #include<iostream>
using namespace std;
int i, n, pA, pB, tA = 0, tB = 0;
int main () {
    whole(cin >> n) {
       if(n == 0) { break; }
       for (i=1; i<=n; i++) {
           cin >> pA >>pB;
           if (pA >pB) {
               tA += pA + pB;
           } else {
               if (pA <pB) {
                   tB += pA + pB;
               } else {
                   tA += pA;
                   tB +- pB;
               }
           }
       }
       cout << tA << " " << tB << endl;
       tA = 0; tB = 0;
     }
     return 0;
}

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

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

  return 0;
  
}

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

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

int A = 0, B = 0, j;

int main(){
    cin >> j;
    for(int i = 0; i < j; i++){
        int as, bs;
        cin >> as >> bs;
        if(as > bs){
            A = A + as + bs;
        }else if(as < bs){
            B = B + as + bs;
        }else{
            A = A + as;
            B = B + bs;
        }
    }
    cout << A << " " << B << endl;
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
#include <cstdio>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  int n;
  int sa,sb;
  while(cin>>n,n){
  sa = sb = 0;
  while(n--){
    int a,b;
    cin>>a>>b;
    if(a>b){
      sa += a + b;
    }else{
      sb += a + b;
    }
  }

  cout<< sa << " " << sb << endl;
  }
}

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

int main(){
int n,a,b;
int A=0,B=0;
while(cin>>n){
if(n==0)break;
for(int i=0;i<n;i++){
cin>>a>>b;
if(a>b){
A+=a;
A+=b;}
if(b<a){
B+=a;
B+=b;}
if(a==b){
A+=a;
B+=b;}}
cout<<A<<B<<endl;
}}