Go: package main

import "fmt"

func main() {
	var a1, a2, a3, a4, b1, b2, b3, b4 int
	for {
		i, _ := fmt.Scan(&a1, &a2, &a3, &a4)
		if i == 0 {
			break
		}
		fmt.Scan(&b1, &b2, &b3, &b4)
		a := [4]int{a1, a2, a3, a4}
		b := [4]int{b1, b2, b3, b4}
		var hit, blow int

		for j := 0; j < 4; j++ {
			for k := 0; k < 4; k++ {
				if a[j] == b[k] {
					if j == k {
						hit++
					} else {
						blow++
					}
				}
			}
		}
		fmt.Println(hit, blow)
	}
}

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

int main(void) {
    int a[4], b[4], i, j, hit, blow;
    while (1) {
        hit = 0;
        blow = 0;
        for (i = 0; i < 4; i++) {
            cin >> a[i];
            if (cin.eof()) {
                goto END;
            }
        }
        for (i = 0; i < 4; i++) {
            cin >> b[i];
        }
        for (i = 0; i < 4; i++) {
            if (a[i] == b[i]) {
                hit++;
            }
        }
        for (i = 0; i < 4; i++) {
            for (j = 0; j < 4; j++) {
                if (i != j && a[i] == b[j]) {
                    blow++;
                }
            }
        }
        cout << hit << " " << blow << endl;
    }
    END:
    return 0;
}

C++: #include <stdio.h>

int main(void){
  int a[50][4];
  int b[50][4];
  int i, j, k;
  int h, br;
  int num=0;

  /*
  for ( i=0; i<2; i++) {
    scanf("%d %d %d %d", &a[i][0], &a[i][1], &a[i][2], &a[i][3]);
    scanf("%d %d %d %d", &b[i][0], &b[i][1], &b[i][2], &b[i][3]);
  }*/

  while(scanf("%d %d %d %d", &a[i][0], &a[i][1], &a[i][2], &a[i][3])){
  	scanf("%d %d %d %d", &b[i][0], &b[i][1], &b[i][2], &b[i][3]);
  	num++;
  }
  
  for ( i=0; i<num; i++) {
  	for(j=0;j<4;j++) {
  	  for(k=0;k<4;k++) {
  		if ( a[i][j]==b[i][k] ) {
  		  if ( j==k ) {
  		  	h++;
  		  } else {
  		  	br++;
  		  }
  		}
  	  }
  	}
  	printf("%d %d\n",h, br);
  	br = h = 0;
  }


  return 0;
}

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

int main(){
	int a[4];
	int b[4];
	int hit;
	int 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(a[i] == b[j]){
					blow++;
					if(i == j) blow--;
					break;
				}
			}
		}
		cout << hit << " " << blow << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>

#define rep(i,n)	for(int i = 0;i < n;i++)
#define rep2(i,n)	for(int i = 1;i <= n;i++)
#define each(i,x)	for(auto & i : x)

using namespace std;

int main()
{
	vector<vector<int>> ary;
	while(!feof(stdin))
	{
		vector<int> vec(4);
		rep(i,4)
		{
			cin >> vec[i];
		}
		ary.push_back(vec);
	}
	int len = ary.size()/2;
	rep(i,len)
	{
		vector<int> a = ary[i*2];
		vector<int> b = ary[i*2+1];
		int hit = 0;
		rep(j,4)
		{
			if(a[j] == b[j])
				hit++;
		}
		sort(b.begin(),b.end());
		int blow = -hit;
		rep(j,4)
		{
			auto it = find(b.begin(),b.end(),a[j]);
			if(it != b.end())
			{
				blow++;
			}
		}
		cout << hit << " " << blow << endl;
	}
	return 0;
}

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] && i!=j)
                n++;
        }
    }
    return n;
}

C++: #include<algorithm>
#include<functional>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

typedef unsigned long long ull;
typedef long long ll;

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

using namespace std;

typedef pair<int ,int > P;

int a1,a2,a3,a4;
int b1,b2,b3,b4;
vector<int> a,b;

int main()
{
	while(cin>>a1>>a2>>a3>>a4>>b1>>b2>>b3>>b4)
	{
		int hit=0,blow=0;
		if(a1==b1)
			hit++;
		if(a2==b2)
			hit++;
		if(a3==b3)
			hit++;
		if(a4==b4)
			hit++;
		
		if(a1==b2||a1==b3||a1==b4)
			blow++;
		if(a2==b1||a2==b3||a2==b4)
			blow++;
		if(a3==b2||a3==b1||a3==b4)
			blow++;
		if(a4==b2||a4==b3||a4==b1)
			blow++;

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


	return 0;
}

C++: #include <iostream>
#include <array>
void counter(unsigned int* n_a,unsigned int* n_b,int* hit,int* blow);

int main() {

	std::array<unsigned int, 4> n_a;//selection of "A"
	std::array<unsigned 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(unsigned int* n_a,unsigned int* n_b,int* hit,int* blow) {
	
	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;
			}
			//otherwise
			else {
				//nothing to do
			}
		}
	}

	return;
}

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]){
        if (cin.eof()){break;}
        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 <array>

int main(){

	std::array<int, 4> num_a, num;

	while(std::cin >> num_a[0] >> num_a[1] >> num_a[2] >> num_a[3]){
		std::cin >> num[0] >> num[1] >> num[2] >> num[3];
		int hit = 0, blow = 0;
		for(std::size_t i = 0; i < 4; ++i){
			if(num_a[i] == num[i]){
				++hit;
			}else{
				for(std::size_t j = 0; j < 4; ++j){
					if(num_a[j] == num[i]){
						++blow;
					}
				}
			}
		}
		std::cout << hit << " " << blow << std::endl;
	}

	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
using namespace std;

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