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], 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>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cmath>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(x=from;x<to;x++)

using namespace std;


int main(void){
int aa[4], bb[4];
int ht, bl, j;

	while(cin >> aa[0]){
		rep2(j,1,4) cin >> aa[j];
		rep(i,4) cin >> bb[i];
		ht = 0; bl = 0;
		rep(i,4) rep(j,4) {
			if(aa[i] == bb[j]){
				if(i==j) ht++;
				else     bl++;
			}
		}	
		cout << ht << " " << bl << endl;
	}
	
	return 0;
}

C++: #include <cstdio>

int main(int argc, char *argv[]) {
	
	while (true) {
		int player1[4];
		int player2[4];
		int hit = 0, blow = 0;
		
		if (EOF == fscanf(stdin, "%d %d %d %d\n",
			 &player1[0], &player1[1], &player1[2], &player1[3])) {
			break;
		}
		fscanf(stdin, "%d %d %d %d\n", &player2[0], &player2[1],
			&player2[2], &player2[3]);
		
		for (int i = 0; i < 4; i++) {
			// hit
			if (player1[i] == player2[i]) {
				hit++;
			}
			// blow
			for (int j = 0; j < 4; j++) {
				if (i != j) {
					if (player1[i] == player2[j]) {
						blow++;
					}
				}
			}
		}
		printf("%d %d\n", hit, blow);
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int a[4],b[4];
  while(cin >> a[0]){
    int hit =0,blow = 0;
    for(int i=1;i<4;i++)
      cin >> a[i];
    for(int i=0;i<4;i++)
      cin >> b[i];
      for(int k=0;k<4;k++){
        for(int j=0;j<4;j++){
      if(a[k]==b[j]){
        if(k==j) hit++; 
        else blow++;
      }
    }
      }
      cout << hit <<" "<< blow <<endl;
  }
}

C++: #include <bits/stdc++.h>
using namespace std;

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)):((m)-(n))),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)
#define loop for(;;)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;
typedef vector<int> vi;
typedef vector<string> vs;
typedef map<string,int> Dictionary;
const Real PI = acos(-1);

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

int dx[] = { -1, 0, 1, 0 };
int dy[] = {  0, -1, 0, 1 };

int main() {

  loop {
    vi as(4);
    vector<bool> isin(10, false);
    rep (i, 4) {
      int a; cin >> a;
      as[i] = a;
      isin[a] = true;
    }
    int hit = 0;
    int blow = 0;
    rep (i, 4) {
      int b; cin >> b;
      if (isin[b]) ++blow;
      if (as[i] == b) ++hit;
    }
    blow -= hit;
    if (!cin) break;

    cout << hit << ' ' << blow << endl;
  }
  return 0;
}

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

int main()
{
	int a[4];
	int b[4];
	while (true)
	{
		for (int i = 0; i < 4; i++) cin >> a[i];
		for (int i = 0; i < 4; i++) cin >> b[i];
		if (a[0] == EOF) break;

		int hit = 0;
		int blow = 0;

		for (int i = 0; i < 4; i++)
		{
			for (int j = 0; j < 4; j++)
			{
				if (a[i] != b[j])
					continue;
				if (i == j)
					hit++;
				else
					blow++;
			}
		}
		cout << hit << ' ' << blow << endl;
	}
	return 0;
}

C++: #define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#include <bits/stdc++.h>
using namespace std;
  

int main() {
  int a[4],b[4];
  
  while(cin>>a[0]){
    rep(i,3) cin>>a[i+1];
    rep(i,4) cin>>b[i];
    int h=0,v=0;
    
    rep(i,4){
      if(a[i]==b[i]) h++;
    }
    rep(i,4){
      rep(j,4){
        if(a[i]==b[j]) v++;
      }
    }
    
    cout<<h<<" "<<v-h<<endl;

  }
  
  return 0;
}

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

void counter(int* n_a,int* n_b,int* hit,int* blow);

int main() {

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

	while (std::cin) {
		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;
	}

}

/*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;
			}
		}
	}

	return;
}

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;

void check (int a[], int b[], int & hit, int & blow )
{
	rep (i, 4 ){
		rep (j, 4 ){
			if (a[i] == b[j] ){
				if (i == j ) hit++;
				else blow++;
			} // end if
		} // end rep
	} // end rep
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.HB", "r", stdin );

	int a[4],b[4];
	while (scanf ("%d%d%d%d", &a[0], &a[1], &a[2], &a[3] ) != EOF ){
		scanf ("%d%d%d%d", &b[0], &b[1], &b[2], &b[3] );
		int hit = 0, blow = 0;
		check (a, b, hit, blow );
		printf ("%d %d\n", hit, blow );
	} // end while
		
	return 0;
}