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;
#include<stdio.h>
int main()
{
        int v=0,s=0,a[10000+1],b[10000+1],i,n;
        while(1)
        {
                v=0;
                s=0;
                cin>>n;//??\???
                if(n==0)//0?????´???
                {
                        break;
                }
                for(i=0;i<n;i++)//??\???
                {
                        cin>>a[i]>>b[i];
                }
                for(i=0;i<n;i++)
                {
                        if(a[i]>b[i])
                                v=a[i]+b[i]+v;
                        else if(a[i]<b[i])
                                s=a[i]+b[i]+s;
                        else
                        {
                                v=a[i]+v;
                                s=b[i]+s;
                        }
                }
                cout<<v<<" "<<s<<endl;
        }
        return 0;
}

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

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

  int n;
  while (cin >> n && n) {
    int a = 0, b = 0;
    for (int i = 0; i < n; ++i) {
      int c, d;
      cin >> c >> d;

      if (c > d) a += c + d;
      else if (c < d) b += c + d;
      else a += c, b += d;
    }
 
    cout << a << " " << b << '\n';
  }

  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<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<string.h>
using namespace std;
int main(){
	int n;
	int sa, sb;
	int a, b;
	while (1){
		cin >> n;
		if (n == 0){
			break;
		}
		for (int i = 0; i < n; i++){
			cin >> a >> b;
			if (a>b){
				sa = sa + a + b;
			}
			else if (a < b){
				sb = sb + a + b;
			}
			else{
				sa = sa + a;
				sb = sb + b;
			}
		}
		cout << sa << " "<< sb<<endl;

	}
}

C++: #include <stdio.h>

int main(){
	int i,pa,pb,tpa,tpb,count;
	while(1){
		tpa = 0;
		tpb = 0;
		scanf("%d",&count);
		if (count == 0) break;
		for(i=0;i<count;i++){
			scanf("%d %d",&pa,&pb);
			if(pa == pb) {
				tpa += pa;
				tpb += pb;
			}
			else if(pa > pb) tpa += (pa+pb);
			else tpb += (pa+pb);
		}
		printf("%d %d\n",tpa,tpb);
	}
	return 0;
}

C++: #include<iostream>
#include<string>
using namespase 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 <iostream>
using namespace std;

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

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

int main(){
  int n;
  int Acard,Bcard;
  int Atotal,Btotal;
  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<<'\n';
  return 0;
}

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

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

int main()
{
	int a;
	int r, l;
	int rsum, lsum;
	rsum = 0;
	lsum = 0;
	do{
		cin >> a;
		for (int i = a; i > 0; i--){

			cin >> r;
			cin >> l;
			if (r > l){
				rsum += r + l;
			}
			else if (l > r){
				lsum += r + l;
			}
			else{
				rsum += r;
				lsum += l;
			}
		}
		cout << rsum << ' ' << lsum << endl;
	} while (a != 0);
}

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

struct player{
    int point;
    int card[10000];
    inline player(){point = 0;}
};

int main()
{
    int loop;
    player a, b;
    cin >> loop;
    for(int c = 0; c < loop; c++)
    {
        cin >> a.card[c];
        cin >> b.card[c];
    }

    for(int c = 0; c < loop; c++)
    {
        if(a.card[c] < b.card[c])
        {
            b.point += a.card[c] + b.card[c];
            continue;
        }
        if(a.card[c] == b.card[c])
        {
             a.point += a.card[c], b.point +=b.card[c];
             continue;
        }
        a.point += a.card[c] + b.card[c];
    }
    cout << a.point << " " << b.point << endl;
    return EXIT_SUCCESS;
}

C++: #include<iostream>
using namespace std;
 
int main(){
	int a;
	int uma;
	int ushi;
	int b;
	int c;

	cin >> a;
	for (int i; i < a; i++){
		cin >> b;
		cin >> c;
		if (b>c){
			uma = uma + 2;
		}
		if(b=c){
			uma = uma + 1;
			ushi = ushi + 1;
		}
		else{
			ushi = ushi + 2;
		}
	}
	cout << uma <<" "<<ushi;

}

C++: #include <stdio.h>
#define loop(num)	for(int a = 0; a < num; a++)

int main(){
	int num;
	__int64 A = 0, B = 0;
	int a_card, b_card;
	scanf("%d", &num);
	loop(num){
		scanf("%d%d", &a_card, &b_card);
		if (a_card < b_card) B += (a_card + b_card);
		if (b_card < a_card) A += (a_card + b_card);
		if (a_card == b_card){
			A += a_card;
			B += b_card;
		}
	}
	printf("%lld %lld\n", A, B);
	return 0;
}

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

int main()
{
    int n;
    while(cin >> n && n) {
        int a = 0, b = 0, c, d;
        for(int i=0; i < n; ++i) {
            cin >> c >> d;
            if (c > d) a += c+d;
            else if (d > c) b += c+d;
            else a += c, b += d;
        }

        printf("%d %d\n", a, b);
    }

    return 0;
}

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