Go: package main

import "fmt"

func main() {
	var a1, a2, a3, a4, b1, b2, b3, b4 int
	for {
		i, _ := fmt.Scan(&a1, &a2, &a3, &a4)
		if i == 0 {
			break
		}
		fmt.Scan(&b1, &b2, &b3, &b4)
		a := [4]int{a1, a2, a3, a4}
		b := [4]int{b1, b2, b3, b4}
		var hit, blow int

		for j := 0; j < 4; j++ {
			for k := 0; k < 4; k++ {
				if a[j] == b[k] {
					if j == k {
						hit++
					} else {
						blow++
					}
				}
			}
		}
		fmt.Println(hit, blow)
	}
}

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

int main(void){
	int a[4];
	int b[4];
	int h,br;
	
	while(1){
		
		h=0;
		br=0;
		
		for(int i=0;i<4;i++) cin >> a[i];
		for(int j=0;j<4;j++) cin >> b[j];
		
		for(int k=0;k<4;k++){
			for(int l=0;l<4;l++){
				if(a[k]==b[l]){
					if(k==l) h++;
					else br++;
				}
			}
		}
		cout << h << ' '<< br << endl;
	}
}

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

int main(){
    int a[4], b[4];
    
    while(cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]){
        int hit = 0, blow = 0;
        
        for(int i = 0;i < 4;i++){
            for(int j = 0;j < 4;j++){
                if(a[i] == b[j]){
                    if(i == j){
                        hit++;
                    }else{
                        blow++;
                    }
                }
            }
        }
        
        cout << hit << " " << blow << endl;
    }
          
    return 0;
}

C++: // 0025 Hit and Blow
#include <iostream>
using namespace std;

int main()
{
	int a[3]; // 正解の数字
	int b[3]; // 回答者の数字
	
	while(cin >> a[0] >> a[1] >> a[2] >> a[3]){ // 正解の数字を入力
	  int hit  =0; // 初期値
	  int blow =0; // 初期値

	for(int i=0; i<4; i++) // 回答者の数字を入力
		cin >> b[i];

	for(int i=0; i<4; i++)
		for(int j=0; j<4; j++)
			if(a[i]==b[j])	// もし数字が一致しているなら
				if(i==j)	// もし同じ桁数が同じなら
					hit++;	// ヒットの数を増やす
				else
					blow++;	// ブロウの数を増やす
	cout<< hit << "" << blow << endl; // 結果を出力
	}
}

C++: #include <iostream>

using namespace std;

int main(){

	int A[5];
	int B[5];

	//while(1){

		int hit = 0 , blow = 0;

		cin >> A[0];

	//	if(A[0] == 0) break;

		for(int i = 1; i < 4; i++){
			cin >> A[i];
		}

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

		for(int i = 0; i < 4; i++){
			if(A[i] == B[i]){
					hit++;
				}
			for(int j = 0; j < 4; j++){

				if(A[i] ==  B[j] && A[i] != B[i]){
					blow++;
				}
			}
		}

		cout << hit << " " << blow << endl;
	//}

	return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
	int a[4], b[4];
	
	while ( cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3] ) {
		
		int hit_cnt = 0;
		int blow_cnt = 0;
		
		for (int i=0; i<4; i++) {
			if (a[i] == b[i]) { hit_cnt++; a[i] = b[i] = -1; }
		}
		
		for (int i=0; i<4; i++) {
			if (a[i] == -1) continue;
			for (int j=0; j<4; j++) {
				if (a[i] == b[j]) { blow_cnt++; a[i] = b[j] = -1; break; }
			}
		}
		
		cout << hit_cnt << " " << blow_cnt << endl;
	}	
		
	return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
typedef pair<string,string> Ps;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	// 1 変数を入れる;
	int x,y,sx,sy,cost;
};

int main() {

	while(1){
		int a,b,c,d;
		int e,f,g,h;
		int t[10]={};
		int hi=0,bu=0;
		cin>>a>>b>>c>>d;
		cin>>e>>f>>g>>h;
		if(cin.eof())return 0;
		t[a]++;
		t[b]++;
		t[c]++;
		t[d]++;
		t[e]++;
		t[f]++;
		t[g]++;
		t[h]++;
		for(int i=1; i<10; i++){
			if(t[i]==2)bu++;
		}
		if(a==e)hi++;
		if(b==f)hi++;
		if(c==g)hi++;
		if(d==h)hi++;
		cout<<hi<<" "<<bu-hi<<endl;
	}

	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>

using namespace std;

int main(void) {

	int hit = 0, blow = 0;
	int num[4],data[4];

		for (int i = 0; i < 4; i++) {
			cin >> num[i];
		}
		for (int i = 0; i < 4; i++) {
			cin >> data[i];
		}
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				if (i == j && num[i] == data[j])
					hit++;
				else if (num[i] == data[j])
					blow++;
			}
		}
		cout << hit << " " << blow << endl;
		hit = 0, blow = 0;
	

	return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){

  int a[4],b[4],n,m;

  while(cin >> a[0]){
    n = 0;
    m = 0;
    cin >> a[1] >> a[2] >> a[3];
    for(int i=0;i<4;i++){
      cin >> b[i];
      if(a[i] == b[i]) n++;
    }
    sort(a,a+4);
    for(int i=0;i<4;i++){
      if(*lower_bound(a,a+4,b[i])==b[i]) m++;
    }
    cout << n << " " << (m-n) << endl;
  }
  return (0);
}

C++: #include <iostream>
#include <array>
#include <algorithm>

int main(void) {
    std::array<u_int, 4> a;
    std::array<u_int, 4> b;

    while (std::cin >> a[0] >> a[1] >> a[2] >> a[3]
                    >> b[0] >> b[1] >> b[2] >> b[3])
    {
        int hit = 0;
        for (int i = 0; i < 4; ++i) {
            if (a[i] == b[i]) ++hit;
        }

        int blow = -hit;
        std::sort(a.begin(), a.end());
        for (auto v : b) {
            if ( std::binary_search(a.begin(), a.end(), v) ) ++blow;
        }

        std::cout << hit << " " << blow << std::endl;
    }

    return 0;
}

C++: #include <iostream>

using namespace std;

int debug = 0;

class ANumber{
private:
	int have[10];
	int place[10];
	int hit;
	int blow;
public:
	ANumber(){
		int i;
		for(i=0;i<=9;i++){
			have[i] = 0;
			place[i] = 0;
		}
		hit = 0;
		blow = 0;
	}

	void clearNum(){
		int i;
		for(i=0;i<=9;i++){
			have[i] = 0;
			place[i] = 0;
		}
		hit = 0;
		blow = 0;
		if(debug) cout << "all reset! " << hit << " " << blow << endl;
	}

	void addNum(int num, int placeNum){
		have[num] = 1;
		place[num] = placeNum;
		if(debug) cout << num << "is placed #" << placeNum << endl;
	}

	void chkNum(int b1, int b2, int b3, int b4){
		if(debug) cout <<"chk"<< b1 << b2 << b3 << b4 << endl;
		if(have[b1] == 1){
			if(place[b1] == 1){
				if(debug) cout << "b1 hit" <<endl; 
				hit++;
			}else{
				if(debug) cout << "b1 blow" <<endl;
				blow++;
			}
		}
		if(have[b2] == 1){
			if(place[b2] == 2){
				if(debug) cout << "b2 hit" <<endl;
				hit++;
			}else{
				if(debug) cout << "b2 blow" <<endl;
				blow++;
			}
		}
		if(have[b3] == 1){
			if(place[b3] == 3){
				if(debug) cout << "b3 hit" <<endl;
				hit++;
			}else{
				if(debug) cout << "b3 blow" <<endl;
				blow++;
			}
		}
		if(have[b4] == 1){
			if(place[b4] == 4){
				if(debug) cout << "b4 hit" <<endl;
				hit++;
			}else{
				if(debug) cout << "b4 blow" <<endl;
				blow++;
			}
		}

		cout << hit << " " << blow << endl;
	}
};

int main(void){
	ANumber A;
	int a1, a2, a3, a4;
	int b1, b2, b3, b4;

	while(cin >> a1 >> a2 >> a3 >> a4){
		A.addNum(a1, 1);
		A.addNum(a2, 2);
		A.addNum(a3, 3);
		A.addNum(a4, 4);
		cin >> b1 >> b2 >> b3 >> b4;
		A.chkNum(b1, b2, b3, b4);
		A.clearNum();
	}

	return 0;
}

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

int hit(int str[],int str2[]){
  int i, j = 0;

  for(i = 0;i < 4;i++){
    if(str[i] == str2[i]){
      j++;
    }
  }

  return j;
}

int blow(int str3[],int str4[]){
  int i, j = 0;

  sort(str3, str3 + 4);
  sort(str4, str4 + 4);

  for(i = 0;i < 4;i++){
    if(str3[i] == str4[i]){
      j++;
    }
  }

  return j;
}

int main(){
  int str[4], str2[4];

  cin >> str[0] >> str[1] >> str[2] >> str[3];

  cin >> str2[0] >> str2[1] >> str2[2] >> str2[3];

  int hit_var = hit(str, str2);
  int blow_var = blow(str, str2);

  cout << hit_var << " " << blow_var - hit_var << endl;

  return 0;
}