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

}

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

int ans[4], in[4];

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

  return 0;
}

C++: #include<iostream>

using namespace std;

int main()
{
	int ss[8],i,j;
	int ans[2];
	
	for(;cin >> ss[0];)
	{
		ans[0]=ans[1]=0;
		
		for(i=1;i<8;i++)
		{
			cin >> ss[i] ;
		}
		
		for(i=0;i<4;i++)
		{
			if(ss[i]==ss[i+4])
			{
				ans[0]++;
				ss[i+4]=-1;
			}
		}
		for(i=0;i<4;i++)
		{
			for(j=4;j<8;j++)
			{
				if(ss[i]==ss[j])
				{
					ans[1]++;
				}
			}
		}
		cout << ans[0] << " " << ans[1] << endl;
	}
}

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

int main() {
	vector<int> a(4), b(4);
	do{
		for( int i=0; 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 ){
			for( int j=0; j<4; ++j ){
				if( a[i] == b[j] ){
					( i==j ? hit : blow ) += 1;	
				}
			}
		}
		cout << hit << ' ' << blow << endl;
	}while(!cin.eof());
}

C++: #include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
 
typedef long long ll;
typedef pair<int, int> ii;

#define EPS 1e-8

int main(){

	vector<int> a(4);
	vector<int> b(4);
	
	while(cin >> a[0]){
		vector<bool> used(10, false);
		int hit = 0, blow = 0;
		used[a[0]] = true;
		REP(i, 1, 4){
			cin >> a[i];
			used[a[i]] = true;
		}
		rep(i, 4){
			cin >> b[i];
			if(a[i] == b[i]) hit++;
			else if(used[b[i]]) blow++;
		}
		
		cout << hit << " " << blow << endl;
		
	}

	
	return 0;
}

C++: #include<iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<sstream>
#include<algorithm>
#include<map>
#include<complex>
using namespace std;


#define li			long long int
#define rep(i,to)	for(int i=0;i<((int)(to));i++)
#define repp(i,start,to)	for(int i=(int)(start);i<((int)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-10
#define ETOL 1e-8
#define MOD 1000000007
#define F first
#define S second
#define p2(a,b)		cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		cout<<a<<"\t"<<b<<"\t"<<c<<endl

int main(){
	li a[4], b[4];
	while(cin>>a[0]){
		li hit=0, blow=0;
		repp(i,1,4)cin>>a[i];
		rep(i,4)cin>>b[i];
		
		rep(i,4){
			bool found=false;
			rep(j,4){
				if(b[i]==a[j]){
					found=true;
					break;
				}
			}
			if(found){
				if(b[i]==a[i])hit++;
				else blow++;
			}
		}
		cout<<hit<<" "<<blow<<endl;
	}
	
	return 0;
}

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

int main(){

  int a[8];

  while(cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> a[5] >> a[6] >> a[7]){

    int hit=0,blow=0;

    for(int i=0;i<4;i++){
      if(a[i]==a[i+4]){
	hit++;
	a[i]=-1*i;
	a[i+4]=-1*(i+4);
      }
    }

    for(int i=0;i<4;i++){
      for(int j=4;j<8;j++){
	if(a[i]==a[j]){
	  blow++;
	  a[i]=-1*i;
	  a[j]=-1*j;
	}
      }
    }

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