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 <cstdio>
int main(){
 int asum,bsum,a,b,n,i;
 asum=bsum=0;
 scanf("%d",&n);
 for(i=0;i<n;i++){
  scanf("%d %d",&a,&b);
  if (a>b) asum += a+b;
  if (a<b) bsum += a+b;
  if (a==b) { asum += a; bsum += b; }
 };
 printf("%d %d\n",asum,bsum);
 return 0;
};

C++: #include <stdio.h>
int main(){
  for(;;){
    int n,i,j,k;
    int A=0,B=0;
    scanf("%d",&n);
    if(n==0){
      return 0;
    }
      for(i=0;i<n;i++){
      scanf(" %d %d",&j,&k);
      if(j>k){
        A+=(j+k);
      } else if(j<k){
        B+=(j+k);
      } else if(j==k){
        A+=j;
        B+=k;
      }
      printf("%d %d\n",A,B);
    }
  }
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int n,a,b,counta=0,countb=0;
  while(1){
    cin >> n;
    if(n==0) break;
    for(int i=0;i<n;i++){
      cin >> a >> b;
      if(a>b){
	counta=counta+a+b;
      } else if(a<b){
	countb=countb+a+b;
      } else if(a==b){
	counta+=a;
	countb+=a;
      }
    }
    cout << counta << " " << countb << endl;
  }
  return 0;
}

C++: #include <stdio.h>
#include <iostream>

int main()
{
	//std::ios::
	int n;
	int a,b;
	int sa,sb;//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<<a<<" "<<b<<"\n";
	return 0;
}

C++: #include<iostream>
using namespace std;
int n,a,b,c,d;
int main(){
	while(true){
		cin>>n;if(n==0)break;c=0;d=0;
		for(int i=0;i<n;i++){
			cin>>a>>b;
			if(a>b)c+=(a+b);
			if(a<b)d+=(a+b);
			if(a==b){c+=a;d+=b;}
		}
		cout<<c<<' '<<d<<endl;
	}
	return 0;
}

C++: #include<stdio.h>
int main()
{
	int n, a, b, i, point1, point2;
	point1 = 0;
	point2 = 0;
	scanf("%d", &n);
	for ( i = 0; i < n; i++)
	{
		scanf("%d %d", &a, &b);
		if ( a > b )point1 = point1 + a + b;
		else if ( a < b )point2 = point2 + a + b;
		else if ( a == b )
	 	{
			point1 = point1 + a;
			point2 = point2 + b;
		}
	}
	printf("%d %d\n", point1, point2);
}

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

int main() {
	int n; //何枚ずつのカードを使うか
	int a_score; //Aの得点
	int b_score; //Bの得点
	int a, b;
	int ab_score[200]; //AとBの得点を入れておく箱
	int count = 0;
	while (true) {
		a_score=0;//初期化
		b_score=0;//初期化
		cin >> n;
		if(n==0)break;
		for (int i = 0; i < n; i++) {
			cin >> a >> b; //a,bに入力させる
			if (a > b)
				a_score += a + b;
			else if (b > a)
				b_score += a + b;
			else {
				a_score += a;
				b_score += b;
			}
		}
		ab_score[count] = a_score;
		ab_score[count + 1] = b_score;
		count += 2;
	}
	for (int i = 0; i < count - 1; i+=2) {
		cout << ab_score[i] << " " << ab_score[i + 1] << "\n";
	}
	return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
	int n, left = 0, right = 0, stage, stage2, i;

	while (true) {
		cin >> n;
		if(n == 0) break;
		for(i = 0; i < n; i ++){
			cin >> stage >> stage2;
			if(stage > stage2) left += stage + stage2;
			else if(stage < stage2) right += stage + stage2;
			else{
				left += stage;
				right += stage2;
			}
		}
		cout << left << " " << right << endl;
	}
	return 0;
}

C++: #include<bits\stdc++.h>
using namespace std;
int main(void){
	int n,asum,bsum,a,b,i;
	while(1){
		cin>>n;
		if(n==0)break;
		asum=0; bsum=0;
		for(i=0;i<n;i++){
			cin>>a>>b;
			if(a==b)asum+=a,bsum+=b;
			if(a>b)asum+=a+b;
			if(b>a)bsum+=a+b;
		}
		cout<<asum<<' '<<bsum;
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n, ans[11][3], an;
	an = 0;
	while (1) {
		cin >> n;
		if (n == 0) {
			goto a;
		}
		an = an + 1;
		int a, b;
		ans[an][1] = 0;
		ans[an][2] = 0;
		for (int i = 1; i <= n; i++) {
			cin >> a >> b;
			if (a == b) {
				ans[an][1] = ans[an][1] + a;
				ans[an][2] = ans[an][2] + b;
				goto b;
			}
			if (a > b) {
				ans[an][1] = a + b + ans[an][1];
			}
			if (a < b) {
				ans[an][2] = a + b + ans[an][2];
			}
		b:;
		}
	}
a:;
	for (int i = 1; i <= an; i++) {
		cout << ans[i][1] << " " << ans[i][2] << endl;
	}
}

C++: #include <iostream>
#include <vector>
#include <utility>

#define FOR(i,begin,end) for(int i = (begin); i < (end); ++i)

using namespace std;

struct Data {
    int A, B;
    Data(int a, int b) : A(a), B(b) {}
};

int N;
vector<Data> inputs;

void solve() {
    int A_sum = 0, B_sum = 0;
    FOR(i, 0, N) {
        int A = inputs[i].A;
        int B = inputs[i].B;
        if (A > B) {
            A_sum += A + B;
        } else if (A < B) {
            B_sum += A + B;
        } else {
            A_sum += A;
            B_sum += B;
        }

        cout << A_sum << " " << B_sum << endl;
    }
}

int main() {
    cin >> N;
    while (N > 0) {
        inputs.clear();

        FOR(i, 0, N) {
            int A, B;
            cin >> A >> B;
            inputs.push_back(Data(A, B));
        }

        solve();
        cin >> N;
    }

    return 0;
}

C++: #include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
  int a,b,n;
  int ai,bi;
  while(cin>>n,n){
	  a=b=0;
	  for(int i=0;i<n;i++)
	  {
		  cin>>ai>>bi;
		  if(ai>bi) a+=ai+bi;
		  else if(bi>ai) b+=ai+bi;
		  else{
			  a+=ai;
			  b+=bi;
		  }
	  }
	 cout<<a<<' '<<b<<endl;
  }
    return 0;
}

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

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


  return 0 ;
}

C++: #include<iostream>
#include<string>
using namespace std;
int N, S, i, cnt, R, num;
string str, s;
string ring[101];
int main(){
    cin >> str >> N;
    S = str.size();
    for (i=0; i<N; i++){
        cin >> s;
        ring[i] = s + s;
    }
    cnt = 0;
    for (i=0; i<N; i++){
        R = ring[i].size();
        for (num = 0; num < R-S+1; num++){
            if( ring[i].substr(num,S) == str ){
                cnt++; break;
            }
        }
    }
    cout << cnt << endl;
   return 0;
}

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

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) {
      break;
    }
    vector<int> A(n), B(n);
    for (int i = 0; i < n; ++i) {
      cin >> A[i] >> B[i];
    }

    int ans_A = 0, ans_B = 0;
    for (int i = 0; i < n; ++i) {
      if (A[i] > B[i]) {
        ans_A += A[i] + B[i];
      } else if (A[i] == B[i]) {
        ans_A += A[i], ans_B += B[i];
      } else {
        ans_B += A[i] + B[i];
      }
    }

    cout << ans_A << ' ' << ans_B << endl;
  }
}