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 <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


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 H=0,B=0;
        int blow[10]={};
        rep(i,4) blow[a[i]]++;
        rep(i,4) blow[b[i]]++;
        rep(i,10)if(blow[i]==2)B++;
        
        rep(i,4){
            if(a[i]==b[i])H++;
        }
        cout<<H<< " "<<B-H<<endl;
    }
    return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;          
int main(){
  int a[4],b[4],i,n;

  while(cin >> a[0] >> a[1] >> a[2] >> a[3], !cin.eof()){
    cin >> b[0] >> b[1] >> b[2] >> b[3];
    int hit = 0, num =0,blow = 0;

    for(i=0; i<4; i++){
      if(a[i] == b[i]){
	hit++;
      }
    }
    for(i=0; i<4; i++){
      for(n=0; n<4; n++){
	if(a[i] == b[n]){
	  num++;
	}
      }
    }
    blow = num - hit;
    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 (true) {
		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 <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 <stdio.h>

bool d[12];

int a[4];
int b[4];

int main()
{
while(1 == scanf("%d",a))
{
for(int i = 1; i < 4; i++)
{
scanf("%d",a + i);
}
for(int i = 0; i < 4; i++)
{
scanf("%d",b + i);
}
for(auto& i : d)
{
i = false;
}
for(auto i : a)
{
d[i] = true;
}
int hi = 0;
int bu = 0;
for(int i = 0; i < 4; i++)
{
if(a[i] == b[i])
{
hi++;
}
else if(d[b[i]])
{
bu++;
}
}
printf("%d %d\n",hi,bu);
}
}

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

int main(){
    std::vector<int> a, b;
    a.resize(4);
    b.resize(4);
    while(std::cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]){
        int hitcount = 0, blowcount = 0;
        for(int i = 0; i < 4; ++i){
            if(a.at(i) == b.at(i))
                ++hitcount;
        }
        for(int value_a : a){
            for(int value_b : b){
                if(value_a == value_b)
                    ++blowcount;
            }
        }
        std::cout << hitcount << " " << blowcount - hitcount << std::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 %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 "stdio.h"

int main ()
{
    int a[5],b[5];
    while(scanf("%d %d %d %d %d %d %d %d",&a[1],&a[2],&a[3],&a[4],&b[1],&b[2],&b[3],&b[4])!=EOF)
    {
        int hit = 0,blow = 0;
        for(int i = 1;i <= 4 ;i++)
            if (a[i]==b[i])
                hit++;

        for(int i = 1;i <= 4;i++)
            for(int j = 1;j <= 4;j++)
        {
            if (i!=j&&a[i]==b[j])
                blow++;
        }

        printf("%d %d\n",hit,blow);

    }
}

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

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

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

	return res;
}

int main(void){
	while(1){
		string a="",b="";

		for(int i=0;i<4;i++){
			char ch;
			if(!(cin>>ch)) return 0;
			a += ch;
		}

		for(int i=0;i<4;i++){
			char ch;
			cin>>ch;
			b += ch;
		}

		cout<<hit(a,b)<<" "<<blow(a,b)<<endl;
	}

	return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <functional>
#include <sstream>
#include <complex>
#include <climits>
using namespace std;

#define REP(i,a,n) for(int i=(a);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define EPS 1e-8

int main(){
	int a[4],b[4];
	while(~scanf("%d%d%d%d",a,a+1,a+2,a+3)){
		scanf("%d%d%d%d",b,b+1,b+2,b+3);
		int hit=0,bro=0;
		rep(i,4)if( a[i]==b[i] ){
			hit++;
		}
		rep(i,4){
			rep(j,4){
				if( i!=j ){
					if( b[i]==a[j] )bro++;
				}
			}
		}
		printf("%d %d\n",hit,bro);
	}
	return 0;
}

C++: #include <cstdio>

using namespace std;

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

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

int main()
{
  int a[4], b[4];
  int 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){
    hit = blow = 0;
    //cin >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3];
    for (int i = 0; i < 4; i++){
      if (a[i] == b[i]){
        hit++;
      }
      for (int j = 0; i < 4; j++){
        if (a[i] == b[j]){
          blow++;
        }
      }
    }
    blow -= hit;
    cout << hit << " " << blow << endl;
  }

  return 0;
}