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>
#include <vector>

int get_hit(std::vector<u_int> *A, std::vector<u_int> *B)
{
    u_int hit = 0;
    for(u_int i = 0; i < A -> size(); ++i)
        if(A -> at(i) == B -> at(i))
            ++hit;
            
    return hit;
}

int get_blow(std::vector<u_int> *A, std::vector<u_int> *B)
{
    u_int blow = 0;
    for(u_int i = 0; i < A -> size(); ++i){
        for(u_int j = 0; j < B -> size(); ++j){
            if(A -> at(i) == B -> at(j)){
                if(i != j)
                    ++blow;
                break;
            }
        }
    }
            
    return blow;
}

int main()
{
    const u_int number = 4;
    std::vector<u_int> A;
    std::vector<u_int> B;
    A.reserve(number);
    B.reserve(number);
    
    u_int num1, num2, num3, num4;
    bool flag = true;
    while(std::cin >> num1 >> num2 >> num3 >> num4){
        if(flag){
            A.clear();
            B.clear();
            A.push_back(num1);
            A.push_back(num2);
            A.push_back(num3);
            A.push_back(num4);
            flag = !flag;
        }else{
            B.push_back(num1);
            B.push_back(num2);
            B.push_back(num3);
            B.push_back(num4);
            std::cout << get_hit(&A, &B) << " " << get_blow(&A, &B) << std::endl;
            flag = !flag;
        }
    }
        
    return 0;
}

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

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

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

			if(a[i] == b[(i + 1) % 4] || a[i] == b[(i + 2) % 4] || a[i] == b[(i + 3) % 4])
				blow++;
		}

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

	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

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

C++: #include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    int a[4],b[4];
    while(~scanf("%d%d%d%d%d%d%d%d",a+0,a+1,a+2,a+3,b+0,b+1,b+2,b+3))
    {
        int x=0,y=0;
        for(int i=0;i<4;++i)
        if(a[i]==b[i])++x;
        else if(a[i]<b[i])++y;
        printf("%d %d\n",x,y);
    }
    return 0;
}

C++: #include <iostream>
#include <string>
#include <math.h>
#include <stdio.h>
#include <ctype.h>

using namespace std;

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

C++: #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 1000000000;
using namespace std;
int main() {
  int a[4], b[4];
  while (cin >> a[0] >> a[1] >> a[2] >> a[3]) {
    int ansb = 0, ansh = 0;
    rep(i, 4) cin >> b[i];
    rep(i, 4) rep(j, 4) {
      if (a[i] == b[j]) {
        if (i == j)
          ansh++;
        else
          ansb++;
      }
    }
    cout << ansh << ' ' << ansb << endl;
  }
  return 0;
}

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

int main() {
  while(true) {
    int A[4],B[4];
    int hit = 0;
    int blow = 0;
    cin >> A[0] >> A[1] >> A[2] >> A[3];
    if(cin.eof()) break;
    cin >> B[0] >> B[1] >> B[2] >> B[3];
    for(int i=0;i<4;i++) {
      if(A[i] == B[i])
        hit++;
    }
    for(int i=0;i<4;i++) {
      for(int j=0;j<4;j++) {
        if(A[i] == B[j]) {
          blow++;
          break;
        }
      }
    }
    blow = blow - hit;
    cout << hit << " " << blow << endl;
  }
}

C++: #include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


V<string> split(const string& s, char c) {
  V<string> res;
  stringstream ss(s);
  string t;
  while (getline(ss, t, c)) res.push_back(t);
  return res;
}

int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  string s;
  while (getline(cin, s)) {
    auto ss = split(s, ' ');
    V<> a(4);
    for (int i = 0; i < 4; ++i) a[i] = stoi(ss[i]);
    getline(cin, s);
    ss = split(s, ' ');
    V<> b(4);
    for (int i = 0; i < 4; ++i) b[i] = stoi(ss[i]);
    int h = 0;
    for (int i = 0; i < 4; ++i) h += a[i] == b[i];
    int bl = 0;
    for (int i = 0; i < 4; ++i) {
      for (int j = 0; j < 4; ++j) if (i != j) {
        if (b[i] != a[j]) continue;
        ++bl;
        break;
      }
    }
    cout << h << ' ' << bl << '\n';
  }
}

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>
#include <array>

/*This function is a counter for "hit" and "blow".*/
void counter(int* n_a, int* n_b, int* hit, int* blow) {

	*hit = 0;
	*blow = 0;

	for (int i = 0; i < 4; ++i) {
		for (int j = 0; j < 4; ++j) {
			//the case of factor and place are same
			if (n_a[i] == n_b[j] && i == j) {
				*hit = *hit + 1;
			}
			//the case of only factor is same
			else if (n_a[i] == n_b[j]) {
				*blow = *blow + 1;
			}
		}
	}
}

int main() {

	std::array<int, 4> n_a;//selection of "A"
	std::array<int, 4> n_b;//selection of "B"

	while (std::cin >> n_a[0] >> n_a[1] >> n_a[2] >> n_a[3] && std::cin >> n_b[0] >> n_b[1] >> n_b[2] >> n_b[3]) {
		//std::cin >> n_a[0] >> n_a[1] >> n_a[2] >> n_a[3];
		//std::cin >> n_b[0] >> n_b[1] >> n_b[2] >> n_b[3];

		int hit = 0;//factor and place are same
		int blow = 0;//only factor is same

		counter(n_a.data(),n_b.data(),&hit,&blow);

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

	return 0;

}