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<stdio.h>
#include<iostream>

using namespace std;

int main(){

int n;
while(cin>>n,n){
int Ac[10001];
int Bc[10001];
int Ap=0;
int Bp=0;

for(int i=0;i<n;i++)cin>>Ac[i]>>Bc[i];

for(int i=0;i<n;i++){

  if(Ac[i]>Bc[i])Ap+=Ac[i]+Bc[i];
  else if(Ac[i]<Bc[i])Bp+=Ac[i]+Bc[i];
  else if(Ac[i]==Bc[i]){
   Ap+=Ac[i];
   Bp+=Bc[i];
  }
 }

cout<<Ap<<' '<<Bp<<endl;

}

return 0;

}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<math.h>

using namespace std;

int n,a,b,asum,bsum;

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

C++: #include<iostream>
using namespace std;
int main(){
  int n,i,asum,bsum,a_card,b_card;
  cin >> n;
  while(n!=0){
    asum=0; bsum=0;
    for(i=0;i<n;i++){
      cin >>a_card>>b_card;
      if(a_card>b_card){
	asum+=a_card+b_card;
      }else if(a_card<b_card){
	bsum+=a_card+b_card;
      }else{
	asum+=a_card;
	bsum+=b_card;
      }
    }
      cout << asum<<" "<<bsum<<endl;
      cin >>n;
  }
}

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

C++: #include<iostream>
using namespace std;
int main(){
	int n;
	int a,b;
	int A,B;
	cin>>n;
	if(n==0){break;}
	while(true){
	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 <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 1 << 30
#define LLINF LLONG_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll fact(ll a){ll b=1;FOR(i,1,a)b*=i;return b;}
ll power(ll x,ll n){ll a=1;REP(i,n)a*=x;return a;}

int n,x,y;

int main()
{
  while(1)
  {
    scanf("%d",&n);
    if(n==0) return 0;
    int A = 0;
    int B = 0;
    REP(i,n)
    {
      scanf("%d %d",&x,&y);
      if(x>y) A+=(x+y);
      else if(x<y) B+=(x+y);
      else
      {
        A+=x;
        B+=y;
      }
    }
    printf("%d %d\n",A,B);
  }
}

C++: #include <iostream>
#include <string>
using namespace std;
   
#define MAX_PLAY 2
#define MAX_ROUNDS 10000
   
int rounds[MAX_ROUNDS][MAX_PLAY];
int total_a = 0, total_b = 0;
   
void cards(int i) {
    if(rounds[i][0] > rounds[i][1]) {
        total_a += (rounds[i][0] + rounds[i][1]);
    }
    else if (rounds[i][0] < rounds[i][1]) {
        total_b += (rounds[i][0] + rounds[i][1]);
    }
    else {
        total_a += rounds[i][0];
        total_b += rounds[i][1];
    }
}
  
void card_counter()
{
    int n;
    while(cin >> n) {
      if(n == 0) {
          break;
      }
      for(int i = 0; i < n; i++) {
          cin >> rounds[i][0] >> rounds[i][1];
      }
      for(int j = 0; j < n; j++) {
          cards(j);
      }
      cout << total_a << " " << total_b << endl;
      total_a = 0, total_b = 0;
    }
}
  
int main() {
card_counter();
return 0;
}

C++: #define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

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

C++: #include<iostream>
using namespace std;
int main(){
	int n;
	int a,b;
	int A,B;
	cin>>n;
	if(n=0){break;}
	for(int j=0;j<5;j++){
	for(int i=0;i<10000;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<stdio.h>
int main()
{
  int a,aa;
  int cou,n,i;
  while(1){
    scanf("%d",&n);
    if(n==0){
      break;
    }
    a=i/2;
    aa=n/i;
    cou=0;
    for(i=2;i<=n/2;i++){
      if((double)i%2.000000==0.000000&&(double)n%(double)i==0.000000){
	continue;
      }
      if((double)i%2.000000!=0.000000&&(double)n%(double)i!=0.000000){
	continue;
      }
      if((double)i%2.000000==0.000000&&(double)n%(double)i!=0.000000){
	cou++;
      }
      if((double)i%2.000000!=0.000000&&(double)n%(double)i==0.000000){
	cou++;
      }
    }
    printf("%d",cou);
  }
  return 0;
}

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

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

C++: #include <stdio.h>

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