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;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define rrep(i,n) for(int (i)=1;i<=(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
	
	int n;
	while(cin >> n, n) {
		int A = 0, B = 0;
		rep(i, n) {
			int a, b;
			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<iostream>
int main() {
	while (1) {
		int n;
		std::cin >> n;
		if (n == 0)
			return 0;
		else {
			int asum = 0, bsum = 0, a, b;
			for (int i = 0; i < n; i++) {
				std::cin >> a >> b;
				if (a > b)
					asum += a+b;
				else
					bsum += a+b;
			}
			std::cout << asum << " " << bsum<<std::endl;
		}
	}
	return 0;
}

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

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

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int main() {
	int n, a = 0, b = 0;
	cin >> n;
	
	for_(i,0,n) {
		int aa, bb;
		cin >> aa >> bb;
		
		if (aa > bb) a += (aa + bb);
		else if (aa < bb) b += (aa + bb);
		else a += aa, b += bb;
	}
	
	cout << a << " " << b << endl;
}

C++: // 2011/09/20 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

		int A = 0;
		int B = 0;
		for(int i=0; i<n; i++){
			int a, b;
			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<iostream>
using namespace std;
int main(){
  int n,pointA,pointB;
  int a[10000],b[10000];
  pointA = 0; pointB = 0;
  for(n = 1;n != 0;cin >> n){  
cout << n; 
cin >> 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]){
      pointB = pointB + a[i] +b[i];
    } else if(a[i] > b[i]){
      pointA = pointA + a[i] +b[i];
    } else if(a[i] == b[i]){
      pointA = pointA + a[i];
      pointB = pointB + b[i];
    }
  }
    
  cout << pointA << " "<< pointB << endl;
  }
}

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

C++: #include<iostream>
#include<vector>
int main() {
	int n;
	int ag = 0, bg = 0;	
	std::cin >> n;
	std::vector<int> a(n), b(n);

	for (int i = 0; i < n; ++i) {
		std::cin >> a[i] >> b[i];
		if (a[i] > b[i])ag += a[i], ag += b[i];
		else bg += a[i], bg += b[i];
	}
	std::cout << ag << " " << bg << std::endl;
	
}

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

int main() {
	int n,i,result[2] = {0,0};
	cin >> n;
	int num[2];
	for(i = 0;i < n;i++){
		cin >> num[0] >> num[1];
		if(num[0] > num[1])result[0]+= num[0] + num[1];
		else if(num[0] < num[1])result[1]+= num[0] + num[1];
		else if(num[0] == num[1]){
			result[0] += num[0];
			result[1] += num[1];
		}
	}
	cout << result[0] << " " << result[1] <<endl;
	return 0;
}

C++: #include <iostream>

int main(void)
{
    int n, data_a, data_b;
    int score_a, score_b;

    std::cin >> n;

    score_a = 0;
    score_b = 0;

    for(; n > 0 ; n--) {
        std::cin >> data_a;
        std::cin >> data_b;
        if (data_a > data_b) {
            score_a += (data_a + data_b);
        } else if(data_a < data_b) {
            score_b += (data_a + data_b);
        } else {
            score_a += data_a;
            score_b += data_b;
        }
    }

    std::cout << score_a << " " << score_b << std::endl;

    return 0;
}

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

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

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

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

int main(){
  int a, b;
  int n;
  while(cin >> n, n){
    int A, B;
    A = B = 0;
    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<iostream>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

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

C++: #include <iostream>

using namespace std;

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