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 <fstream>
using namespace std;

int main(void)
{
	int A[4], B[4];

	//ifstream fin("in.txt");
	istream& in=cin;

	while(1)
	{
		for(int i=0; i<4; i++)
			{ if( !(in >> A[i]) )return 0; }
		for(int i=0; i<4; i++)
			{ if( !(in >> B[i]) )return 0; }

		int res[4];
		for(int i=0; i<4; i++)
		{
			if(A[i] == B[i])
			{
				res[i] = 1;
			}
			else
			{
				for(int j=0; j<4; j++)
					if(A[j] == B[i])res[i] = 2;
			}
		}

		int hit=0, blow=0;
		for(int i=0; i<4; i++)
		{
				 if(res[i] == 1)hit++;
			else if(res[i] == 2)blow++;
		}
		cout << hit << ' ' << blow << endl;
	}
	return 0;
}

C++: #include <fstream>
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
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;
    int blow = 0;
    for (int i = 0; i < 4; i++) {
      if (a[i] == b[i]) hit++;
    }
    for (int i = 0; i < 4; i++) {
      if (find(a, a+4, b[i]) != a+4) blow++;
    }
    blow -= hit;
    cout << hit << " " << blow << endl;
  }
}

C++: //#define _USE_MATH_DEFINES
//#include <cmath>
#include <iostream>
//#include <stdio.h>
//#include <stdlib.h>
//#include <iomanip>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <functional>
//#include <time.h>
//#include <sstream>
//#include <queue>

using namespace std;


int main(){

	int a[4], b[4];
	int hit = 0, blow = 0;
	bool flag = false;

	while (1){

		for (int i = 0; i < 4; i++){
			if (!(cin >> a[i])){
				flag = true;
				break;
			}
		}
		if (flag)break;
		for (int i = 0; i < 4; i++){
			cin >> b[i];
		}

		hit = 0;
		blow = 0;

		//hit
		for (int i = 0; i < 4; i++){
			if (a[i] == b[i]) hit++;
		}

		//blow
		for (int i = 0; i < 4; i++){
			for (int j = 0; j < 4; j++){
				if (a[i] == b[j]) blow++;
			}
		}

		blow -= hit;

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


	


	return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <string>
#include <map>
#include <algorithm>
using namespace std;

int main()
{
	int a[5], i, b[5], x, y;
	while (~scanf ("%d", a))
	{
		int has[10] = {0};
		has[a[0]] = 1;
		for (i = 1; i < 4; i++) scanf ("%d", a+i), has[a[i]] = 1;
		for (i = 0; i < 4; i++) scanf ("%d", b+i);
		x = y = 0;
		for (i = 0; i < 4; i++) if (a[i] == b[i]) ++x;
		for (i = 0; i < 4; i++) if (has[b[i]]) ++y;
		printf ("%d %d\n", x, y-x);
	}
	return 0;
}

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

int main(){
    int a[4];
    int b[4];

    int hit;
    int blow;

    while(1){
        hit = 0;
        blow = 0;

        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++){
            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 <cstdio>
#include <iostream>

using namespace std;

int main(){
	int n;
	int hit[4],blow[4];
	int h=0,b=0;
	int hcount = 0,bcount = 0;

	while(cin >> n){
		if(h < 4){
			hit[h] = n;
			h++;
		}else if(b < 4){
			blow[b] = n;
			b++;
		}
		if(b == 4){
			for(int i=0;i<4;i++){
				if(hit[i] == blow[i]){
					hcount++;
				}
			}

			for(int i=0;i<4;i++){
				for(int j=0;j<4;j++){
					if((hit[i] == blow[j]) && (hit[j] != blow[j])){
						bcount++;
					}
				}
			}

			printf("%d %d\n",hcount,bcount);
			h = b = hcount = bcount = 0;
			
		}
	}
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main(){
  vector<int> hit_anss;
  vector<int> bolor_anss;
  int nums_a[4],nums_b[4];
  int hit=0,bolor=0;
  while(cin>>nums_a[0]>>nums_a[1]>>nums_a[2]>>nums_a[3]>>nums_a[3]){
    for(int i=0;i<4;i++){
      cin>>nums_b[i];
    }
    //hit????¢????
    for(int i=0;i<4;i++){
      if(nums_a[i]==nums_b[i])hit++;
    }
    //bolor????¢????
    for(int i=0;i<4;i++){
      for(int j=0;j<4;j++){
        if(i==j)continue;
        if(nums_a[i]==nums_b[j]){
          bolor++;
          break;
        }
      }
    }
    hit_anss.push_back(hit);
    bolor_anss.push_back(bolor);
  }
  for(int i=0;i<hit_anss.size();i++){
    cout<<hit_anss[i]<<' '<<bolor_anss[i]<<endl;
  }
}

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

int main(){
	int a[4],b[4],c,d,i,j;
	while(std::cin>>a[0]){
	for(i=1;i<4;i++){
	std::cin>>a[i];
	}for(i=0;i<4;i++){
	std::cin>>b[i];
	}
	c=0;
	d=0;
	for(i=0;i<4;i++){
		for(j=0;j<4;j++){
			if(i==j&&a[i]==b[j]){
			c++;
			}if(i!=j&&a[i]==b[j]){
			d++;
			}
		}
	}
	}
	std::cout<<c<<" "<<d<<std::endl;
	return 0;
}

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

int main()
{
	int firstset[3], secondset[3], hit=0, blow=0;
	while(cin>>firstset[0]>>firstset[1]>>firstset[2]>>firstset[3]>>secondset[0]>>secondset[1]>>secondset[2]>>secondset[3])
	{
		for(int i=0; i<4; i++)
		{
		if(firstset[0] == secondset[0]) hit++;
		else if(firstset[1] == secondset[1]) hit++;
		else if(firstset[2] == secondset[2]) hit++;
		else if(firstset[3] == secondset[3]) hit++;
		else if(firstset[0] == secondset[1]) blow++;
		else if(firstset[0] == secondset[2]) blow++;
		else if(firstset[0] == secondset[3]) blow++;
		else if(firstset[1] == secondset[2]) blow++;
		else if(firstset[1] == secondset[3]) blow++;
		else if(firstset[2] == secondset[3]) blow++;
		else if(firstset[2] == secondset[1]) blow++;
		else if(firstset[3] == secondset[1]) blow++;
		else if(firstset[3] == secondset[2]) blow++;
		else blow, hit;
		}
	
	cout<<hit<<" "<<blow<<endl;
	hit=0, blow=0;
	}
	cin.get();
	return 0;
}

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

int main(){

	int a1, a2, a3, a4, b1, b2, b3, b4;

	while(std::cin >> a1 >> a2 >> a3 >> a4){
		
		std::cin >> b1 >>b2 >> b3 >>b4;

		std::array<int, 4> A = {a1, a2, a3, a4};
		std::array<int, 4> B = {b1, b2, b3, b4};
		
		int hit = 0;
		int blow = 0;

		for(int i = 0; i < 4; ++i){
			
			if(A[i] == B[i])
				++hit;
				
			hit += std::count(A.begin(), A.end(), B[i]);

		}

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

		return 0;

}