Go: package main

import (
	"fmt"
)

// Game is one game.
type Game struct {
	pointA, pointB int
}

func main() {
	var n int
	game := &Game{0, 0}
	fmt.Scanf("%d", &n)
	for n != 0 {
		game.initGame()
		game.execGame(n)
		game.printResult()
		fmt.Scanf("%d", &n)
	}
}

func (game *Game) execGame(n int) {
	var a, b int
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a)
		fmt.Scanf("%d", &b)
		switch {
		case a == b:
			game.pointA += a
			game.pointB += b
		case a > b:
			game.pointA += a + b
		case b > a:
			game.pointB += a + b
		}
	}
}

func (game *Game) initGame() {
	game.pointA = 0
	game.pointB = 0
}

func (game *Game) printResult() {
	fmt.Println(game.pointA, game.pointB)
}

C++: #include <iostream>

void Game(int round, std::istream& in, std::ostream& out)
{
    int scoreA = 0;
    int scoreB = 0;
    for(int i = 0; i < round; ++i){
        int a, b;
        in >> a >> b;
        if(a > b){
            scoreA += a + b;
        }else
        if(a < b){
            scoreB += a + b;
        }else{
            scoreA += a;
            scoreB += b;
        }
    }
    out << scoreA << " " << scoreB;
}

int main()
{
    int n;
    std::cin >> n;
    while(n){
        Game(n, std::cin, std::cout);
        std::cin >> n;
    }
    return 0;
}

C++: #include <iostream>
int main()
{

	while (1) {
		int card;
		std::cin >> card;
		if (card == 0) {
			break;
		}
		int a[10000], b[10000];
		int ascore = 0, bscore = 0;
		for (int i = 0; i < card; i++) {
			std::cin >> a[i] >> b[i];
			if (a[i] > b[i]) {
				ascore = ascore + (a[i] + b[i]);
			}
			else if (b[i] > a[i]) {
				bscore = bscore + (a[i] + b[i]);
			}
			else {
				ascore = ascore + a[i];
				bscore = bscore + b[i];
			}
		}
		std::cout << ascore << " " << bscore << std::endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

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

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

int main(void){
	int n;
	int a,b,c,d;
	while(cin >> n, n !=0){
		a = 0; b = 0;
		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;
			}
		}
		cout << a << ' ' << b << 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<iostream>
using namespace std;
int main(){
  int n,a[10000],b[10000],ap=0,bp=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i];
  }
  for(int i=0;i<n;i++){
    if(a[i]>b[i]){
      ap+=a[i]+b[i];
    }else if(a[i]<b[i]){
      bp+=a[i]+b[i];
    }else if(a[i]==b[i]){
      ap+=a[i];
      bp+=b[i];
    }
  }
  cout<<ap<<" "<<bp<<endl;
  return 0;
}

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

struct Game {
    int a, b;
    Game() {
        a = 0;
        b = 0;
    }
    void score(int card_a, int card_b) {
        if (card_a > card_b)
            a += card_a + card_b;
        else if (card_a < card_b)
            b += card_a + card_b;
        else {
            a += card_a;
            b += card_b;
        }
    }
    void board() {
        cout << a << " " << b << endl;
    }
};

int main()
{
    for (int n; cin >> n && n;) {
        Game game;
        for (int a, b; n-- && cin >> a >> b;)
            game.score(a, b);
        game.board();
    }

    return 0;
}

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

int main(){
	int n,a,b;
	long suma=0,sumb=0;
	cin >> n;
	while(n!=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;}
		}
		printf("%ld %ld\n",suma,sumb);
		cin >> n;
		suma = sumb = 0;
	}
	return 0;
}

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

int main(void){
	int n;
	int a,b,c,d;
	while(cin >> n, n !=0){
		a = 0; b = 0;
		for(int i = 0; i < n; i++){
			cin >> c >> d;
			if(c > d)
				a += c + d;
			else
				b += c + d;
		}
		cout << a << ' ' << b << endl;
	}
	return 0;
}

C++: #include<iostream>

int main(){
	while(1){
		int n,A,B,Ap=0,Bp=0;
		std::cin>>n;
		if(n==0)
			break;
		for(int i=0;i<n;++i){
			std::cin>>A>>B;
			if(A>B)
				Ap+=A+B;
			else if(A==B){
				Ap+=A;
				Bp+=B;
			}
			else Bp+=A+B;
		}
		std::cout<<Ap<<' '<<Bp<<std::endl;
	}
	return 0;
}

C++: #include<stdio.h>

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

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

int main() {
  int n;
  while (cin >> n and n != 0) {
    int acard, bcard, ascore = 0, bscore = 0;

    for (int i = 0; i < n; i++) {
      cin >> acard >> bcard;
      
      if (acard > bcard) {
        ascore += acard + bcard;
      } else if (acard < bcard) {
        bscore += acard + bcard;
      } else {
        ascore += acard;
        bscore += bcard;
      }
    }

    cout << ascore << " " << bscore << endl;
  }
}

C++: #include <iostream>

int score_a, score_b;

int main(void)
{
    using namespace std;
    int n, data_a, data_b;

    while(1)
    {
        cin >> n;
        if (n == 0) break;
        score_a = 0;
        score_b = 0;
        for(; n > 0 ; n--) {
            cin >> data_a;
            cin >> data_b;
            if (data_a > data_b) {
                score_a += (data_a + data_b);
            } else if(data_a < data_b) {
                score_b += (data_a + data_b);
            } else {
                score_a += data_a;
                score_b += data_b;
            }
        }
        cout << score_a << " " << score_b << endl;
    }

    return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
	string s, m;
	int cnt = 0, k, n;
	cin >> s >> k;
	for (int i = 0; i < k; i++)
	{
		cin >> m;
		m = m + m;
		n = m.find(s);
		if (n>=0)
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}

C++: #include <iostream>
using namespace std;
   
int main()
{
  int n;
 
  while (cin >> n, n){
    int a, b, n_a, n_b;
    a = b = 0;

    for (int i = 0; i < n; i++){
      cin >> n_a >> n_b;
      if (n_a == n_b){
        a += n_a;
        b += n_b;
      }
      else if(n_a > n_b){
        a += n_a + n_b;
      }
      else {
        b += n_a + n_b;
      }
    }
                                                                                                                                                                                 
    cout << a << ' ' << b << endl;
  }
}

C++: #include <iostream>

int score_a, score_b;

void main(void)
{
    using namespace std;
    int n, data_a, data_b;

    while(1)
    {
        cin >> n;
        if(!n) break;
        score_a = 0;
        score_b = 0;
        for(; n > 0 ; n--) {
            cin >> data_a;
            cin >> data_b;
            if (data_a > data_b) {
                score_a += (data_a + data_b);
            } else if(data_a < data_b) {
                score_b += (data_a + data_b);
            } else {
                score_a += data_a;
                score_b += data_b;
            }
        }
        cout << score_a << " " << score_b << endl;
    }
}