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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n;
  int a_score;
  int b_score;
  while(true) {
    a_score = 0;
    b_score = 0;
    cin >> n;
    if(n == 0) break;
    for(int i=0;i<n;i++) {
      int a_card,b_card;
      cin >> a_card >> b_card;
      if( a_card > b_card ) {
        a_score += a_card + b_card;
      }
      else if( b_card > a_card) {
        b_score += a_card + b_card;
      }
      else {
        // if a_card == b_card
        a_score += a_card;
        b_score += b_card;
      }
    } // end for
    cout << a_score << " " << b_score << "\n";
  } // end while
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  ll a,b,A=0,B=0;
  rep(i,n){
    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;
	int a = 0;
	int b = 0;
	int x = 0;
	while (1) {

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

C++: #include <cstdio>
int main(){
	int a, b, c;
	scanf("%d", &a);
	b = 0;
	c = 0;
	int n_a[a];
	int n_b[a];
	for(int i=0; i<a; i++){
		scanf("%d %d", &n_a[i], &n_b[i]);
	}
	for(int i=0; i<a; i++){
		if(n_a[i] > n_b[i]){
			b += n_a[i]+n_b[i];
		}else if(n_a[i] < n_b[i]){
			c += n_a[i]+n_b[i];
		}else if(n_a[i] == n_b[i]){
			b += n_a[i];
			c += n_b[i];
		}
	}
	printf("%d %d", b, c);
	return 0;
}

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

int main() {
	int num;
	int score_a = 0;
	int score_b = 0;
	
	cin >> num;
	for (int i = 0; i < num; i++) {
		int a;
		int b;

		cin >> a >> b;
		if (a > b) {
			score_a += a + b;
		}else if (b > a) {
			score_b += a + b;
		}else {
			score_a += a;
			score_b += b;
		}
	}
	cout << score_a << " " << score_b << endl;
	score_a = 0;
	score_b = 0;

	return 0;
}

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

C++: #include <iostream>
using namespace std;
int main(){

	int n, a, b, ap = 0, bp = 0;

	cin >> n;

	while (n != 0){

		for (int 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;

		cin >> n;

	}
}

C++: #include <cstdio>

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

C++: #include <cstdio>

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

C++: #include<iostream>
#include<vector>
int main(){
int n;
int s=0;
int g=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]) g+=a[i];
else s+=b[i];
}
std::cout<<g<<" "<<s<<std::endl;
}

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

int main(){
 int n;
 int Acard,Bcard,Apoint,Bpoint;
 while(true){
  cin>>n;
  if(n==0){
   break;
  }else{
    for(int i=0;i<n;i++){
     cin>>Acard>>Bcard;
     if(Acard>Bcard){
      Apoint+=Acard+Bcard;
     }else if(Acard<Bcard){
      Bpoint+=Acard+Bcard;
     }else{
      Apoint+=Acard;
      Bpoint+=Bcard;
     }
    }
   cout<<Apoint<<' '<<Bpoint<<'\n';
   Apoint=0;
   Bpoint=0;
  }
 }
 return 0;
}

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

int main()
{
	int x,y,n;
	while(cin>>n, n)
	{
		int a=0, b=0;
		while(n--)
		{
			cin>>x>>y;
			if(x<y) { a+=x+y;}
			else if(x>y) { b+=x+y;}
			else if(x==y) {a+=a; b+=b;}
		}
	}
		cout<<x<<y<<endl;
	return 0;
}

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"
int main() {
	int N; cin >> N;
	int as=0, bs=0;
	for (int i = 0; i < N; ++i) {
		int a, b; cin >> a >> b;
		if (a > b) {
			as += a + b;

		}
		else if (b > a) {
			bs += a + b;
		}
		else {
			as += a;
			bs += b;
		}

	}
	cout << as <<" "<< bs << endl;
	return 0;
}

C++: #include <iostream>

using namespace std;

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