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>

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define For(i,a) FOR(i,0,a)
#define REP(a) For(i,a)

typedef long long ll;

using namespace std;

int main(){
	int times;
	while(1){
	  ll ans[2]={};
		scanf("%d",&times);
		if(times==0)break;
		REP(times){
			ll tmp[2];
			scanf("%d %d",&tmp[0],&tmp[1]);
			if(tmp[0]<tmp[1])ans[1]+=tmp[0]+tmp[1];
			else if(tmp[0]>tmp[1])ans[0]+=tmp[0]+tmp[1];
			else{ans[0]+=tmp[0];ans[1]+=tmp[1];}
		}
		printf("%d %d\n", ans[0], ans[1]);
	}
	return 0;
}

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

int main(){
int n,a,b;
int sumA=0,sumB=0;
while(cin>>n){
	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>
int main(void){
    int n,a,b,c=0,d=0;
    while(true){
        std::cin>>n;
        if(n==0){
            break;
        }
        else{
            for(int i=0;i<n;++i){
                std::cin>>a>>b;
                if(a>b){
                    c=c+a+b;
                }
                else if(b>a){
                    d=d+a+b; 
                }
                else{
                    c=c+a;
                    d=d+b;
                }
            }
        }
        std::cout<<c<<" "<<d<<std::endl;
        c=0;
        d=0;
    }
    return 0;
}

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

#define rep(v,c) for(int v=0; v<(int)c; ++v)

using pint=pair<int,int>;

pint solve(int 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;
  }
  return pint(A,B);
}

int main(void){
  int n;
  vector<pint> ans;
  while(1){
    cin>>n;
    if(n==0) break;
    auto rec=solve(n);
    ans.push_back(rec);
  }
  rep(i,ans.size()){
    int a,b; tie(a,b)=ans[i];
    cout<<a<<" "<<b<<endl;
  }
}

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

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

C++: #include <stdio.h>

int main(void) {
	int n;
	int a, b;
	int ascore, bscore;

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

C++: #include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int p[10000],q[10000],ptop;
int main(){
	ptop=1,p[0]=2;
	for(int i=3;i<100000;i+=2){
		bool ok=1;
		rep(j,ptop)if(!(i%p[j])){ok=0;break;}
		if(ok)p[ptop]=i,ptop++;
	}
	int n;
	long long x;
	scanf("%d",&n);
	rep(z,n){
		scanf("%lld",&x);
		rep(i,ptop)q[i]=1;
		rep(i,ptop){while(!(x%p[i]))x/=p[i],q[i]++;if(!(x-1))break;}
		int ans=1;
		if(x-1)ans++;
		rep(i,ptop)ans*=q[i];
		printf("%d\n",ans);
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int i, n, pA, pB, tA = 0, tB = 0;
int main () {
    while(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 <bits/stdc++.h>

#define X first
#define Y second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define rep(i, a, b) for (unsigned i = (a); i <= (b); ++i)
#define per(i, a, b) for (unsigned i = (a); i >= (b); --i)

using namespace std;

using I = int;
using L = long;
using F = float;
using S = string;
using LL = long long;
using VI = vector<int>;
using VL = vector<long>;
using VF = vector<float>;
using VS = vector<string>;
using PLL = pair<long, long>;
using PLF = pair<long, float>;
using PLS = pair<long, string>;
using PSL = pair<string, long>;
using PSF = pair<string, float>;
using PSS = pair<string, string>;
using MLL = map<long, long>;
using MLF = map<long, float>;
using MLS = map<long, string>;
using MSL = map<string, long>;
using MSF = map<string, float>;
using MSS = map<string, string>;

const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;

int main(int argc, char const *argv[]) {
  while (1) {
    L n;
    L ans1 = 0;
    L ans2 = 0;
    scanf("%ld", &n);
    if (n == 0) { break; }
    for (unsigned i = 0; i < n; i++) {
      L a, b;
      cin >> a >> b;
      if (a > b) {
        ans1 += a + b;
      } else if (a < b) {
        ans2 += a + b;
      } else {
        ans1 += a;
        ans2 += b;
      }
    }
    printf("%ld %ld\n", ans1, ans2);
  }

  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int n;
	int a,b;
	int A,B;
	cin>>n;
	for(int j=0;j<5;j++){
        if(n==0){break;}
	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 <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

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

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<string>
#include<functional>
#include<queue>
#include<stack>
#include<math.h>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	int n;
	while (1) {
		cin >> n;
		if (n == 0)return 0;
		int a, b;
		int ascore = 0, bscore = 0;
		vector<P>card;
		for (int i = 0; i < n; i++) {
			cin >> a >> b;
			if (a > b)ascore += a + b;
			else if (b > a)bscore += a + b;
			else {
				ascore += a;
				bscore += b;
			}
		}
		cout << ascore << " "<< bscore << endl;
	}

}

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

int main() {
	int q[10000 - 1], w[10000 - 1];
	int n;
	int a = 0;
	int b = 0;
	int x = 1;
	while (x== 10000) {
		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;
			}
		}
		q[x] = a;
		w[x] = b;
		x++;
	}
	for (int j = 1; j <= x; ++j) {
		cout << q[j] << " " << w[j] << endl;
}

C++: #include <iostream>

int main(int argc, char **argv){
	int n = 0;
	int a = 0;
	int b = 0;
	int a_score = 0;
	int b_score = 0;

	std::cin >> n;

	for(int i = 0; i < n; i++){
		std::cin >> a >> b;
		if(a > b){
			a_score += a + b;
		}
		else if(a < b){
			b_score += a + b;
		}
		else{
			a_score += a;
			b_score += b;
		}
	}

	std::cout << a_score << " " << b_score << std::endl;
	return 0;
}