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>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <sstream>
#include <numeric>
#include <set>
#include <map>
//#include <bits/stdc++.h>

#define rep(i, j) for(int i = 0; i < j; i++)
#define all(i) i.begin(), i.end()
#define ll long long
#define bl bool
#define nn printf("\n");
#define mod 1000000007

using namespace std;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<int> a(4, 0), b(4, 0);

	while (cin >> a[0] >> a[1] >> a[2] >> a[3])
	{
		int hit = 0, blow = 0;
		rep(i, 4) { cin >> b[i]; }
		rep(i, 4)
		{
			if (a[i] == b[i]) { hit += 1; }
		}
		rep(i, 4)
		{
			blow += count(all(b), a[i]);
		}
		printf("%d %d\n", hit, blow - hit);
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	vector<int> a(4);
	while(cin>>a[0]>>a[1]>>a[2]>>a[3]){
		vector<int> b(4);
		cin>>b[0]>>b[1]>>b[2]>>b[3];
		int h=0,bl=0;
		for(int i=0;i<4;++i){
			if(b[i]==a[i]) ++h;
			else if(find(a.begin(),a.end(),b[i])!=a.end()) ++bl;
		}
		cout << h << " " << bl << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(){
 int a[4],b[4],h,bb,i;
 while(cin>>a[0]>>a[1]>>a[2]>>a[3]>>b[0]>>b[1]>>b[2]>>b[3]){
  h=bb=0
  for(i=0;i<4;i++)if(a[i]==b[i])h++;
  sort(a,a+4);sort(b,b+4);
  for(i=0;i<4;i++)if(find(b,b+4,a[i])!=b+4)bb++;
  bb -= h;
  cout<<h<<" "<< bb << endl;
 }
 zreturn 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;
		for (int i=0; i<4; i++) {
			for (int j=i; j<4; j++) {
				if (i==j&&a[i]==b[j]) hit++;
				else if (a[i]==b[j]) blow++;
			}
		}
		cout << hit << " " << blow << endl;
	}
}

C++: #include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
int main(){
	int a[3],b[3],dat=1;

	while(scanf("%d %d %d %d",&a[0],&a[1],&a[2],&a[3])!=EOF){
		int h=0,n=0;

		for(int j=0;j<4;j++){
			cin>>dat;
			b[j]=dat;
	}
	for(int k=0;k<4;k++){
			if(a[k]==b[k]){
				h++;
			}

		for(int o=0;o<4;o++){
			if(a[k]!=b[k] && a[k]==b[o]){
				n++;
			}
		}
	}
	cout<<h<<" "<<n<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <array>
//ヒットの数を数え上げる
int checkNumOfHit(std :: array<int, 4> x, std :: array<int, 4> y){
    int num = 0;
    for(int i = 0;i < 4;i++){
        if(x.at(i) == y.at(i)) num++;
    }
    return num;
}

//ブローの数を数え上げる
int checkNumOfBlow(std :: array<int, 4> x, std :: array<int, 4> y){
    int num = 0;
    for(int i = 0;i < x.size();i++){
        for(int j = 0;j < y.size();j++){
            if((i != j) && (x.at(i) == y.at(j))) num++;
        }
    }
    return num;
}
int main(){
    std :: array<int, 4> a, b;
    while(std :: cin >> a.at(0) >> a.at(1) >> a.at(2) >> a.at(3)>> b.at(0) >> b.at(1) >> b.at(2) >> b.at(3)){  
        std :: cout << checkNumOfHit(a, b) << checkNumOfBlow(a, b) << std :: endl;
    }
}

C++: #include <iostream>

using namespace std;

void solve()
{
	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(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;
	}
}

int main()
{
	solve();
	return(0);
}

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

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

}

C++: #include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;

int main()
{
	int a[4];
	while(1){
		rep(i, 4){
			if(scanf("%d", &a[i]) == EOF)
				return 0;
		}

		int hit=0, blow=0;
		rep(i, 4){
			int b;
			scanf("%d", &b);
			rep(j, 4) (i==j ? hit : blow) += a[j] == b;
		}

		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] >> 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]) {        			
                    i == j ? ++hit : ++blow;
        		}
        	}
        }        
        cout << hit << " " << blow << endl;
    }
    return 0;
}

C++: #include<stdio.h>
int main()
{
	int a[4],b[4],hi,bl,bca[4],bcb[4],c,j;
	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])==EOF)){
		hi=0;
		bl=0;
		j=0;
		for(int i=0;i<4;i++){
			if(a[i]==b[i]){
				hi++;
			}else{
				bca[j]=a[i];
				bcb[j]=b[i];
				j++;
			}
		}
		for(int i=0;i<j-1;i++){
			c=0;
			for(int k=0;k<j-1;k++){
				if(bca[i]==bcb[k]&&c==0){
					c=1;
					bl++;
				}
			}
		}
		printf("%d %d\n",hi,bl);
	}
	return 0;
}

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) {
            if(! (std::cin >> a_num[i]) ){
                return 0;
            }
        }
        // input b's number.
        for (int i=0; i<4; ++i) {
            if(! (std::cin >> b_num[i]) ){
                return 0;
            }
        }
        
        // 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;
}