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 N;

int main() {
	int a, b, totalA, totalB;

	while (cin >> N, N) {
		totalA = totalB = 0;
		for (int i = 0; i < N; ++i) {
			cin >> a >> b;
			if (a > b) {
				totalA += a + b;
			}
			else if (a < b) {
				totalB += a + b;
			}
			else {
				totalA += a;
				totalB += b;
			}
		}
		cout << totalA << " " << totalB << endl;
	}

	return 0;
}

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define vi vector<int>
#define VS vector<string>
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back

using namespace std;



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

C++: #include<stdio.h>
int main(void)
{
	int n;
	int a[10000];
	int b[10000];
	int i;
	int suma,sumb;
	
	scanf("%d",&n);
	while(n!=0){	
		suma=0;
		sumb=0;
		for(i=0;i<n;i++){
			scanf("%d %d",&a[i],&b[i]);
			if(a[i]>b[i]){
				suma=suma+a[i]+b[i];
			}
			else if(a[i]<b[i]){
				sumb=sumb+a[i]+b[i];
			}
			else{
				suma=suma+a[i];
				sumb=sumb+b[i];
			}
		}
		printf("%d %d\n",suma,sumb);
		scanf("%d %d",&a[i],&b[i]);
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int m,a,b;int x=0,y=0;
	cin>>m;
	
	for(int i=0;i<m;i++){
	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;

return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
	int n, a, b, bt, at;

	while (cin >> n){
		at = bt = 0;

		for (int i = 0; i < n; i++){
			cin >> a >> b;
			if (a < b) bt += a + b;
			else if (b < a) at += a + b;
			else {
				at += a;
				bt += b;
			}
		}
		if (n != 0) cout << at << " " << bt << endl;
	}
	return (0);
}

C++: #include <stdio.h>

int main(){
int n,i;
int a,b,f,t;

while(1){
scanf("%d",&n);
if(n==0)break;
a=0;
b=0;
f=0;
t=0;
for(i=0;i<n;i++){
scanf("%d %d",&a,&b);
if(a==b){
f+=a;
t+=b;
}
else if(a>b){
f+=a+b;
}
else if(a<b){
t+=a+b;
}
}
ptintf("%d %d\n",f,t);
}

return 0;
}

C++: #include <cstdio>

using namespace std;

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

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

int main(){
	int n;
	int A, B;
	int res_A, res_B;
	
	while(true){
		scanf("%d", &n);
		
		if(n == 0) return 0;
		
		res_A = 0; res_B = 0;
		for(int i = 0; i < n; i++){
			scanf("%d%d", &A, &B);
			if(A > B) res_A += A + B;
			else if(A < B) res_B += A + B;
			else{
				res_A += A; res_B += B;
			}
		}
		
		printf("%d %d\n", res_A, res_B);
	}
}

C++: #include <stdio.h>
 
int main(){
int n,a=0,b=0;
scanf("%d",&n);
while(n){
int aa,bb;
for(int i=n;i>0;i--){
scanf("%d %d",&aa,&bb);
if(aa>bb){
a+=aa+bb;
}else if(aa<bb){
b+=aa+bb;
}else{
a+=aa;
b+=bb;
}
}
scanf("%d",&n);
}
}

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

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

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

int A = 0, B = 0, j, as, bs;

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

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

int main(void){
  int a,b;
  int n;
  while(cin>>n,n){

    a = b = 0;
  while(n--){
    int c,d;
    cin>>c>>d;
    if(c==d){
      a += c ;
      b += c ;
    }else if(c>d)
      a += c + d;
    else
      b += c + d; 
  }
  cout<< a << " " << b << endl;
  }
}

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

int main(){
int a,b,c;
while(scanf("%d",&c),c){
	a=b=0;
	for(int d=0;d<c;d++){
	int e,f;
	scanf("%d%d",&e,&f);
	if(e>f)a+=e+f;
	else if(e<f)b+=e+f;
	else {a+=e;b+=f;}
}
printf("%d %d\n",a,b);
}
}

C++: #include <iostream>
using namespace std;
int main(){
	int pa=0, pb=0;

	int n;

	while(cin >> n){
	int a[n], b[n];
	for(int i=0; i<n; i++){
		cin >> a[i] >> b[i];
	}
	for(int i=0; i<n; i++){
		if(a[i]>b[i]) pa+=a[i]+b[i];
		if(a[i]<b[i]) pb+=a[i]+b[i];
		if(a[i]==b[i]){
			pa+=a[i];
			pb+=b[i];
		}
	}
	cout << pa << " " << pb << endl;
	}
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() {

    int n, a, b, i;
    int ap, bp;

    while (cin >> n, n) {
        ap = 0;
        bp = 0;

        for (i = 0; i < n; i++) {
            cin >> a >> b;
            if (a > b) {
                ap += a + b;
            } else if (a < b) {
                bp += a + b;
            } else {
                ap += a;
                bp += b;
            }
        }

        cout << ap << " " << bp << endl;

        return 0;

    }
}