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*****/
#include <iostream>
#include <fstream>
#include <string>

/*****デバッグ定義*****/
//#define DEBUG
/*****マクロ定義*****/

/*****名前空間*****/
using namespace std;

/*****グローバル変数置き場*****/
/*****その他関数置き場*****/

/*****main関数*****/
int main(){
	/*****ファイルオープン*****/
#ifdef DEBUG
	ofstream fout("output.txt");
	ifstream fin("input.txt");
	if(!fout || !fin){
		cout << "Can't open the file.\n";
		return;
	}
#endif
	/*****変数置き場*****/
	int a_number[4];
	int b_number[4];
	int hit;
	int blow;
	/*****処理部*****/
	while(1){
		for(int i=0;i<4;i++)	cin >> a_number[i];
		for(int i=0;i<4;i++)	cin >> b_number[i];
		hit = 0;
		blow = 0;
		for(int i=0;i<4;i++)
			for(int j=0;j<4;j++)
				if(j >= i){		//全ての組み合わせ（×順列）を試す
					if(a_number[i] == b_number[j])
						if(i == j)	hit++;
						else		blow++;
				}
		cout << hit << " " << blow << endl;
	}
	/*****処理終了後*****/
#ifdef DEBUG
	fout.close();
	fin.close();
#endif
	return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
#include <string.h>

#define max(a, b)  a > b ? a : b
#define min(a, b)  a < b ? a : b

int main()
{
	int A[4], B[4], C[2][10], HIT, BLOW;

	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)
	{
		memset(C, 0, sizeof(C));

		HIT  = 0;
		BLOW = 0;

		for (int i = 0; i < 4; i++)
		{
			if (A[i] == B[i])
			{
				HIT += 1;
			}

			C[0][A[i]] += 1;
			C[1][B[i]] += 1;
		}

		for (int i = 0; i < 10; i++)
		{
			BLOW += min(C[0][i], C[1][i]);
		}

		BLOW -= HIT;
		
		printf("%d %d\n", HIT, BLOW);
	}

	return 0;
}

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

int main() {
	int a[4],b[4];
	vector<int> r1,r2;
	while(scanf("%d %d %d %d",&a[0],&a[1],&a[2],&a[3]) != EOF)
	{
		int map[10]={0};
		int hit=0,blow=0;
		scanf("%d %d %d %d",&b[0],&b[1],&b[2],&b[3]);
		for (int i=0; i<4; i++)
		{
			map[a[i]] = 1;
		}
		for (int i=0; i<4; i++)
		{
			if (a[i] == b[i])
			{
				hit++;
			} else if (map[b[i]]==1)
			{
				blow++;
			}
		}
		r1.push_back(hit);
		r2.push_back(blow);
	}
	for (int i=0; i<r1.size(); i++)
	{
		cout << r1[i] << " " << r2[i] << 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;
 }
}

C++: #include <iostream>
using namespace std;
int hit(int a[],int b[]);
int blow(int a[], int b[]);
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 hi = hit(a,b);
        int bl = blow(a,b);
        cout << hi << " " << bl << endl;
    }
}

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

int blow(int a[], int b[]){
    int n=0;
    for (int i=0; i<4; i++){
        for (int j=0; j<4; j++){
            if (a[i]==b[j])
                n++;
        }
    }
    n -= hit(a,b);
    return n;
}

C++: #include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

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

	return 0;
}

C++: #include<iostream>
int main()
{
	while (true)
	{
		int hit = 0, blow = 0;
		int num[2][4];
		for (int i = 0; i < 2; i++)
		{
			for (int j = 0; j < 4; j++)
			{
				std::cin >> num[i][j];
			}
		}
		if (std::cin.eof())
		{
			break;
		}
		for (int i = 0; i < 4; i++)
		{
			for (int j = 0; j < 4; j++)
			{
				if (num[0][i] == num[1][j])
				{
					if (i == j)
					{
						hit++;
					}
					else
					{
						blow++;
					}
				}
			}
		}
		std::cout << hit << ' ' << blow << std::endl;
	}
	return 0;
}

C++: #include <cmath>
#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)
      if (a[i] == b[i])
        ++hit;

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

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

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

using namespace std;

int main(){
	int a[4], b[4];
	while (scanf("%d %d %d %d\n%d %d %d %d\n", &a[0], &a[1], &a[2], &a[3], &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++;
				}
			}
		}
		printf("%d %d\n", hit, blow);
	}
	return 0;
}

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

int main() {
	int a[4], b[4];
	while (cin >> a[0] >> a[1] >> a[2] >> a[3]) {
		int hit = 0, blow = 0;
		set<int> S;
		for (int i = 0; i < 4; i++) {
			S.insert(a[i]);
		}
		for (int i = 0; i < 4; i++) {
			cin >> b[i];
			if (b[i] == a[i]) hit++;
			if (S.find(b[i]) != S.end()) {
				blow++;
			}
		}
		cout << hit << " " << blow - hit << endl;
	}
}

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

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

	while (cin >> a[0]) {
		int hit = 0, brow = 0;

		for (int i = 1; i < 4; i++) {
			cin >> a[i];
		}
		for (int j = 0; j < 4; j++) {
			cin >> b[j];
		}

		for (int k = 0; k < 4; k++) {
			for (int l = 0; l < 4; l++) {
				if (a[k] == b[k]) {
					if (k == l) {
						hit++;
					}
					else {
						brow++;
					}
				}
			}
		}

		cout << hit << " " << brow << endl;
	}

	return 0;
}

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

int main(){
	int a[4], b[4];
	int hit, blow;
	
	while((scanf("%d", &a[0])) != EOF){
		for(int i = 1; i < 4; i++) scanf("%d", &a[i]);
		for(int i = 0; i < 4; i++) scanf("%d", &b[i]);
		
		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>
#include <vector>

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