Go: package main

import (
	"bufio"
	"os"
	"strings"
	"strconv"
	"fmt"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	a := make([]int, 4)
	b := make([]int ,4)
	for scanner.Scan() {
		inputa := strings.Split(scanner.Text(), " ")
		for i := range a {
			a[i], _ = strconv.Atoi(inputa[i])
		}
		scanner.Scan()
		inputb := strings.Split(scanner.Text(), " ")
		for i := range b {
			b[i], _ = strconv.Atoi(inputb[i])
		}
		hit := 0
		blow := 0
		if a[0] == b[0] {
			hit++
		}
		if a[1] == b[1] {
			hit++
		}
		if a[2] == b[2] {
			hit++
		}
		if a[3] == b[3] {
			hit++
		}
		if a[0] == b[1] {
			blow++
		}
		if a[1] == b[2] {
			blow++
		}
		if a[2] == b[3] {
			blow++
		}
		if a[1] == b[0] {
			blow++
		}
		if a[2] == b[1] {
			blow++
		}
		if a[2] == b[0] {
			blow++
		}
		if a[3] == b[2] {
			blow++
		}
		if a[3] == b[1] {
			blow++
		}
		if a[3] == b[0] {
			blow++
		}
		if a[0] == b[2] {
			blow++
		}
		if a[1] == b[3] {
			blow++
		}
		if a[0] == b[3] {
			blow++
		}
		fmt.Printf("%d %d\n", hit, blow)
	}
}

C++: #include <iostream>

using namespace std;

int main(){
	int a[4];
	int b[4];
	int m, n;

	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(m=0; m<4; m++){
		for(n=0; n<4; n++){
			if(a[m] == b[n] && m == n){
				hit = hit + 1;
			}
			else if(a[m] == b[n]){
				blow = blow + 1;
			}
		}
	}
		
	cout << hit << " " << blow << endl;
}
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

bool used1[4], used2[4];

int main()
{
//	cut here before submit 
//	freopen ("testcase.HB", "r", stdin );
	while (1 ){
		memset (used1, false, sizeof (used1 ) );
		memset (used2, false, sizeof (used2 ) );

		string s1 = "", s2 = "";
		getline (cin, s1 );
		getline (cin, s2 );
		if (s1.empty() || s2.empty() ) break;
		int hit = 0, blow = 0;
		vector<int> a (4, 0 ), b (4, 0 );
		stringstream ssa (s1 ), ssb (s2 );
		rep (i, 4 ) ssa >> a[i];
		rep (j, 4 ) ssb >> b[j];

		rep (i, 4 ){
			if (a[i] == b[i] ){
				hit++;
				used1[i] = true; used2[i] = true;
			} // end if
		} // end rep
		rep (i, 4 ){
			rep (j, 4 ){
				if (!used1[i] && !used2[j] && a[i] == b[j] ){
					blow++;
					used1[i] = true;
					used2[j] = true;
				} // end if
			} // end rep
		} // end rep
		cout << hit << ' ' << blow << endl;
	} // end loop
		
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;

int main(){
	int a[4],b[4],h,bl;
	while(scanf("%d %d %d %d\n%d %d %d %d",&a[0],&a[1],&a[2],&a[3],&b[0],&b[1],&b[2],&b[3])!=EOF){
		h=0;bl=0;
		for(int i=0;i<4;i++){
			if(a[i]==b[i])h++;
			else for(int j=0;j<4;j++)if(a[i]==b[j])bl++;
		}
		cout<<h<<" "<<bl<<endl;
	}
}

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

using namespace std;

int main(int argc, char *argv[]) {
  vector<int> result;
  int a[4], b[4], hit, blow;

  while (cin >> a[0] >> a[1] >> a[2] >> a[3]) {
    cin >> b[0] >> b[1] >> b[2] >> b[3];
    hit = blow = 0;

    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++;
    blow -= hit;

    result.push_back(hit);
    result.push_back(blow);
  }

  for (int i = 0; i < result.size(); i += 2)
    cout << result[i] << ' ' << result[i+1] << 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], cin >> B[0] >> B[1] >> B[2] >> B[3] ){
		int hit = 0, blow = 0;
		bool check[10] = {false};
		//cin >> A[0] >> A[1] >> A[2] >> A[3];
		//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++) check[A[i]] = true;
		for( int i=0; i<4; i++ ) if( A[i] != B[i] && check[B[i]] ) blow++;
		cout << hit << " " << blow << endl;
	}
}

C++: #include <iostream>
using namespace std;
int main() {
  int a[4] = {};
  int 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(i == j && a[i] == b[j]) {
		  hit++;
		}
		else if(i != j && a[i] == b[j]) {
		  blow++;
		}
	  }
	}
	cout << hit << " " << blow << endl;
  }
  return 0;
}

C++: #include <cstdio>
using namespace std;
int main(){
	int a[4],b[4];
	while(scanf("%d %d %d %d",&a[0],&a[1],&a[2],&a[3])!=EOF){
		for(int i=0;i<4;i++)	scanf("%d",&b[i]);
		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++;
				}
			}
		}
		printf("%d %d\n",hit,blow);
	}
	return 0;
}

C++: #include<iostream>
#define FOR(x) for(int x=0;x<4;x++)
using namespace std;

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

C++: #include <iostream>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;

int main(){
    int a[4], b[4];
    while(1){
        rep(i, 0, 4) cin >> a[i];
        rep(i, 0, 4) cin >> b[i];
        if(cin.eof()) break;        
        bool f[4];
        rep(i, 0, 4) f[i] = false;
        int hit = 0, blow = 0;
        rep(i, 0, 4){
            if(a[i] == b[i]){
                hit++; f[i] = true;
            }
        }
        rep(i, 0, 4){
            if(f[i]) continue;
            rep(j, 0, 4){
                if(a[i] == b[j]) blow++;
            }
        }
        cout << hit << " " << blow << endl;
    }
}

C++: 
#include <iostream>

int main(){
    int a_num[4];
    int b_num[4];
    
    while (true) {
        
        // input a's number.
        for (int i=0; i<4; ++i) {
            std::cin >> a_num[i];
        }
        // input b's number.
        for (int i=0; i<4; ++i) {
            std::cin >> b_num[i];
        }
        
        // count hit.
        int hit=0;
        for (int i=0; i<4; ++i) {
            if (a_num[i] == b_num[i]) {
                ++hit;
            }
        }
        std::cout << hit << " ";
        
        // count blow.
        int blow=0;
        for (int i=0; i<4; ++i) {
            for (int j=0; j<4; ++j) {
                if (b_num[i] == a_num[j]) {
                    ++blow;
                    break;
                }
            }
        }
        std::cout << blow << std::endl;
        
    }
    return 0;
}

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

int main()
{
	typedef std::array<std::uint16_t, 4> NumArray;
	NumArray num_a;
	while (std::cin >> num_a[0] >> num_a[1] >> num_a[2] >> num_a[3]) {
		std::uint16_t num_hit = 0, num_blow = 0;
		for (std::uint16_t i = 0; i < 4; ++i) {
			std::uint16_t b;
			std::cin >> b;
			if (b == num_a[i]) {
				++num_hit;
			}
			else if (std::find(num_a.begin(), num_a.end(), b) != num_a.end()) {
				++num_blow;
			}
		}
		std::cout << num_hit << ' ' << num_blow << std::endl;
	}

	return 0;
}