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

int main(int argc, char* argv[]) {
  int ina, inb, n;
  cin >> n;
  while(n != 0){
    int a=0, b=0;
    for(int i=0;i<n;i++){
      cin >> ina >> inb;
      if(ina > inb){
        a += ina+inb;
      }else if(ina < inb){
        b += ina+inb;
      }else{
        a += ina;
        b += inb;
      }
    }
    cout << a << " " << b << endl;
    cin >> n;
  }

  return 0;
}

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>
using namespace std;
static const int N = 10000;

int main() {
	int n;
	int i;
	int A[N];
	int B[N];
	int score_A = 0;
	int score_B = 0;

	cin >> n;
    
	for (i = 0; i < n; i++) {
		cin >> A[i];
		cin >> B[i];
	}

	for (i = 0; i < n; i++) {
		if (A[i] > B[i]) {
			score_A += A[i] + B[i];
		}
		else if (A[i] < B[i]) {
			score_B += A[i] + B[i];
		}
		else if (A[i] = B[i]) {
			score_A += A[i];
			score_B += B[i];
			}
	}

	printf("A????????????%d,B????????????%d", score_A, score_B);

	return 0;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000009
#define EPS 1E-9

int n;
int a, b;

int main()
{
  while((cin >> n) && n){
    int res[2] = {0};
    while(n--){
      cin >> a >> b;

      if(a >  b){ res[0] += a + b;  continue; }
      if(a <  b){ res[1] += a + b;  continue; }
      res[0] += a;
      res[1] += b;
    }

    cout << res[0] << " " << res[1] << endl;
  }

  return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int n;
	int a[3]={0};
	int b[3]={0};
	int A,B;
	for(int i=0;i<5;i++){
		cin>>n;
		if(n==0){break;}
		for(int j=0;j<n;j++){
			if(a[j]>b[j]){
				A+=a[j]+b[j];
			}
			else if(a[j]<b[j]){
				B+=a[j]+b[j];
			}
			else if(a[j]==b[j]){
				A+=a[j];
				B+=b[j];
			}
		}
		cout<<A<<" "<<B<<endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;


int main() {

  int n;
  int p_a,p_b;


  while(cin >> n,n) {

    p_a=p_b=0;

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

      int a,b;

      cin >> a >> b;

      if(a>b) p_a+=a+b;

      else if(a==b) {

	p_a+=a;
	p_b+=b;

      }

      else p_b+=a+b;

    }

    cout << p_a << " " << p_b << endl;

  }

  return 0;

}

C++: #include <iostream>
#include <functional>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <map>
#include <cmath>

using namespace std;

namespace _{struct _{_(){ // initialize
  cin.tie(0); ios::sync_with_stdio(false);
}}_;}
template <typename T, size_t size>
inline size_t len(const T (&)[size]) { return size; }
#define println(s) cout << s << '\n';
#define str to_string
#define rep(i, n) for (int i=0; i<int(n); i++)
#define all(c) (c).begin(), (c).end()


int main() {
  int n; cin >> n;

  int A = 0;
  int B = 0;
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    if (a == b) {
      A += a; B += b;
    } else if (a > b)
      A += a+b;
    else
      B += a+b;
  }

  cout << A << " " << B << endl;
  return 0;
}

C++: #include<stdio.h>

int main(){
	int i=0,x,a[10000],b[10000],aP=0,bP=0;
	while(1){
	scanf("%d",&x);
	if(x==0){
	return 0;
	}
	while(i<x){
scanf("%d%d",&a[i],&b[i]);
	++i;
	}
	i=0;
	while(i<x){
		if(a[i]==b[i]){
			aP=aP+a[i];
			bP=bP+b[i];
		}else if(a[i]>b[i]){
		aP=aP+a[i]+b[i];
		}else{
		bP=bP+a[i]+b[i];
		}
		++i;
	}
	printf("%d %d\n",aP,bP);
	}
}

C++: #include<iostream>
using namespace std;
int n[10000000],s1,s2;
int main(){
int p,a,b;
cin>>p;
for(int i=0;i<p;i++){
cin>>a>>b;
if(a>b){s1+=a+b;}
else if(b>a){s2+=a+b;}
else{s1+=a;s2+=b;}
}
cout<<s1<<' '<<s2<<endl;
}

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

int main(){
	
	int n, x, y, sumx=0, sumy=0;

	while(cin >> n && n > 0){
		sumx=0, sumy=0;
		for(int i=0; i<n; i++){
			x=0,y=0;
			cin >> x >> y;
			if(x > y){
				sumx = sumx + x + y;
			}
			else if(x < y){
				sumy = sumy + x + y;
			}
			else if(x == y){
				sumx = sumx + x;
				sumy = sumy + y;
			}
		}
	
		cout << sumx << " " << sumy << endl;
	 }
	return 0;
}

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

int main() {
    while (true) {
        int n;
        cin >> n;
        int PlayerA;
        int PlayerB;
        if (n==0) {
            break;
        }
        PlayerA=0;
        PlayerB=0;
        while (n--) {
            int scoreA;
            int scoreB;
            cin >> scoreA >> scoreB;
            if (scoreA>scoreB) {
                PlayerA+=scoreA+scoreB;
            } else if (scoreA<scoreB) {
                PlayerB+=scoreA+scoreB;
            } else {
                PlayerA+=scoreA;
                PlayerB+=scoreB;
            }
        }
        printf("%d %d\n",PlayerA,PlayerB);
    }
    return 0;
    
}

C++: #include <iostream>

using namespace std;

int main()
{
  int n;
  cin >> n;
  while (n != 0) {
    int inputA, inputB;
    int outA(0), outB(0);
    for (int i=0; i<n; i++) {
      cin >> inputA >> inputB;
      if (inputA > inputB) outA += inputA + inputB;
      else if (inputA < inputB) outB += inputA + inputB;
      else { outA += inputA; outB += inputB;}
    }
    cout << outA << ' ' << outB << endl;
    cin >> n;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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

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

}

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

int main(){
int n,a,b;
int A=0,B=0;
while(cin>>n){
	A=0;
	B=0;
if(n==0)break;
for(int i=0;i<n;i++){
cin>>a>>b;
if(a>b){
A+=a;
A+=b;}
if(b>a){
B+=a;
B+=b;}
if(a==b){
A+=a;
B+=b;}}
cout<<A<<" "<<B<<endl;
}}