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

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

int main(){
	while(true){
		int n,a=0,b=0;
		std::cin>>n;
		if(n==0){
			break;
		}
		std::vector<int> v1(n,0);
		std::vector<int> v2(n,0);
		for(int i=0;i<n;i++){
			std::cin>>v1[i]>>v2[i];
			if(v1[i]>v2[i]){
				a+=v1[i]+v2[i];
			}else if(v1[i]<v2[i]){
				b+=v1[i]+v2[i];
			}else{
				a+=v1[i];
				b+=v2[i];
			}
		}
		std::cout<<a<<" "<<b<<std::endl;
		
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n,a[10000],b[10000],countA=0,countB=0;
    while(cin>>n,n!=0){
        for(int i=0;i<n;i++){
            cin>>a[i]>>b[i];
            if(a[i]>b[i]){
                countA+=(a[i]+b[i]);
            }else if(a[i]<b[i]){
                countB+=(a[i]+b[i]);
            }else{//a[i]==b[i]
                countA+=a[i];
                countB+=b[i];
            }
        }
        cout<<countA<<" "<<countB<<endl;
    }
    return(0);
}

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

  return 0;
}

C++: #include<iostream>
using namespace std;
int main() {
	int n = 0;
	int aa, bb = 0;
	while (cin >> n, n != 0) {
		aa = 0;
		bb = 0;
	}
	int a[10000] = {};
	int b[10000] = {};

	
	for(int i = 0;i < n;i++){
		cin >> a[i] >> b[i];
	}
	for (int j = 0; j < n; j++) {
		if (a[j] > b[j]) {
			aa += a[j] + b[j];
		}
		else if (a[j] < b[j]) {
			bb += a[j] + b[j];
		}
		else if (a[j] == b[j]) {
			aa += a[j];
			bb += b[j];
		}
	}
	cout << aa << bb << endl;

	return 0;
}