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;

int A=0,B=0;

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

C++: #include<stdio.h>
int main(void){
    int loop,a,b,c,d;
    scanf("%d",&loop);
    for(;loop--;){
        scanf("%d %d",&a,&b);
        if(a!=b){
            if(a>b){
                c+=a+b;
            }else{
                d+=a+b;
            }
        }else{
            c+=a;
            d+=b;
        }
    }
    printf("%d %d",c,d);
    return 0;
}

C++: #include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=x && x<w && 0<=y && y<h)

const int INF = 10000000;
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};
using namespace std;
typedef pair<int, int> P;

/** Problem0500 : Card Game **/
int main()
{
	int n;
	while (cin>>n, n) {
		int sa=0, sb=0;
		rep(i, n) {
			int a, b;
			cin >> a >> b;
			if (a>b) {
				sa+=a+b;
			} else if (b>a) {
				sb+=a+b;
			} else {
				sa+=a; sb+=b;
			}
		}
		cout << sa << " " << sb << endl;
	}
}

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

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

C++: #include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>

using namespace std;

int main() {
	int n;
	while (true) {
		cin >> n;
		if (!n) {
			break;
		}
		int a = 0, b = 0;
		for (int i = 0; i < n; i++) {
			int x, y;
			cin >> x >> y;
			if (x > y) {
				a += x + y;
			} else if (x < y) {
				b += x + y;
			} else {
				a += x;
				b += y;
			}
		}
		cout << a << ' ' << b << endl;
	}
	return 0;
}

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

int main(){
  int n;
  int Acard,Bcard;
  int Atotal,Btotal;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>Acard>>Bcard;
    if(Acard>Bcard){
      Atotal+=Acard+Bcard;
    }else if(Bcard>Acard){
      Btotal+=Acard+Bcard;
    }else{
      Atotal+=Acard;
      Btotal+=Bcard;
    }
  }

  cout<<Atotal<<' '<<Btotal<<'\n';
  return 0;
}

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

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

C++: #include<stdio.h>
#include<iostream>
using namespace std;
int main(){
int card[20000],i,j,a=0,b=0,c=1,n;
cin>>n;
while(n!=0){
for(i=0;i<2*n;i++){
cin>>card[i];
}
for(i=0;i<2*n;i=i+2){
if(card[i]>card[c]){
a=a+card[i]+card[c];
}
else if (card[i]==card[c]){
a=a+card[i];
b=b+card[c];
}
else{
b=b+card[i]+card[c];
}
c=c+2;
}
cout<<a<<" "<<b<<endl;
c=1;
a=0;
b=0;
cin>>n;
}
return 0;
}

C++: #include <iostream>

using namespace std;

int main() {

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

  return 0;
}

C++: #include <iostream>

int main(void)
{
    int n;
    int a=0,b=0;
    while(true)
    {
        std::cin >> n;
        if(n==0) break;
        a=b=0;
        for(int i=0;i<n;i++)
        {
            int a1,b1;
            std::cin >> a1 >> b1;
            if(a1==b1) {a+=a1;b+=b1;}
            else if(a1>b1) {a+=a1+b1;}
            else {b+=a1+b1;}
        }
        std::cout << a << " " << b << std::endl;
    }

    return 0;
}

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

bool get_input(std::vector<int>& cards_a, std::vector<int>& cards_b)
{
	int n;
	std::cin >> n;

	if (n == 0) return false;

	cards_a.clear(), cards_b.clear();
	int card_a, card_b;
	for (int i = 0; i < n; i++) {
		std::cin >> card_a >> card_b;
		cards_a.push_back(card_a);
		cards_b.push_back(card_b);
	}
	return true;
}

void calc_and_output(std::vector<int>& cards_a, std::vector<int>& cards_b)
{
	int point_a = 0, point_b = 0;
	std::vector<int>::iterator a_itr = cards_a.begin();
	std::vector<int>::iterator b_itr = cards_b.begin();
	for (; a_itr != cards_a.end() && b_itr != cards_b.end(); a_itr++, b_itr++) {
		if (*a_itr > *b_itr) {
			point_a += (*a_itr + *b_itr);
		} else if (*a_itr < *b_itr) {
			point_b += (*a_itr + *b_itr);
		} else {
			point_a += *a_itr;
			point_b += *b_itr;
		}
	}
	std::cout << point_a << " " << point_b << std::endl;
}

int main()
{
	std::vector<int> cards_a, cards_b;
	while (get_input(cards_a, cards_b)) {
		calc_and_output(cards_a, cards_b);
	}
	return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
	int lim;
	
	while( cin >> lim, lim != 0){
		int a = 0, b = 0;
		while(lim-- > 0){
			int n, m;
			cin >> n >> m;
			(n == m)? a+=n, b+=m:
			(n > m)? a += n+m: b += n+m;
		}
		printf("%d %d\n", a, b);
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
 
int main () {
    int n, i,A,B, resa =0, resb =0;
    while(cin >> n,n){
        for(i=0;i<n;i++){
             cin >> A >> B;
             (A > B)? resa +=A:resb+=B;
             if(A==B) {resa += A; resb +=B;};
        }
    cout << resa << " " << resb << endl;
    }
}

C++: #include<stdio.h>

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

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

int main(){
	int n,a,b;
	long suma=0,sumb=0;
	cin >> n;
	while(n!=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;}
		}
		printf("%ld %ld\n",suma,sumb);
		cin >> n;
	};
	return 0;
}

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

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

int main()
{
    int n;
    while(cin >> n && n) {
        int a, b, c, d;
        for(int i=0; i < n; ++i) {
            cin >> a >> b;
            if (a > b) c += a+b;
            else if (b > a) d += a+b;
            else c += a, d += b;
        }

        printf("%d %d\n", c, d);
    }

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