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 <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 <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++;
}
}
}
}

C++: # include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
using namespace std;

int main() {
	int a[5];
	int b[5];
	while (cin >> a[1] >> a[2] >> a[3] >> a[4] >> b[1] >> b[2] >> b[3] >> b[4]) {
		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 (a[i] == b[j] && i != j) {
					blow++;
				}
			}
		}
		cout << hit << " " << blow << endl;
	}
}

C++: #include <iostream>

using namespace std;

int main() {

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

	cin >> a1 >> a2 >> a3 >> a4;

	while(cin >> b1 >> b2 >> b3 >> b4) {
		h=0;
		b=0;
		if(a1==b1)
			h++;
		if(a2==b2)
			h++;
		if(a3==b3)
			h++;
		if(a4==b4)
			h++;
		if(a1==b2||a1==b3||a1==b4)
			b++;
		if(a2==b3||a2==b4||a2==b1)
			b++;
		if(a3==b4||a3==b1||a3==b2)
			b++;
		if(a4==b1||a4==b2||a4==b3)
			b++;
		cout << h << " " << b << endl;
	}

	return 0;

}

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

bool judgeZeroToNine(int n);
//bool judgeCorr(int n[]);

int main(){
	int a[4], b[4];
	do{
		cin >> a[0] >> a[1] >> a[2] >> a[3];
		while(!(judgeZeroToNine(a[0])&&judgeZeroToNine(a[1])&&
				judgeZeroToNine(a[2])&&judgeZeroToNine(a[3]))){
			cout << "wrong value\n";
			cin >> a[0] >> a[1] >> a[2] >> a[3];
		}
		cin >> b[0] >> b[1] >> b[2] >> b[3];
		while(!(judgeZeroToNine(b[0])&&judgeZeroToNine(b[1])&&
				judgeZeroToNine(b[2])&&judgeZeroToNine(b[3]))){
			cout << "wrong value\n";
			cin >> 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])
					blow++;
			}
			if(a[i] == b[i]){
				blow--;
				hit++;
			}
		}
		cout << hit << " " << blow << "\n";
	}while(true);
    return 0;
}

bool judgeZeroToNine(int n){
	if((n >= 0)&&(n <= 9))
		return true;
	else
		return false;
}
/*
bool judgeCorr(int n[4]){
	for(int i = 0;i < 3;i++){
		for(int j = i + 1;j < 4;j++){
			if(n[i] == n[j])
				return true;
		}
	return false;
	}
}*/

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

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

    return 0;
}

C++: #include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000
typedef long long ll;

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

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

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

int main(void){

	int a[4],b[4];
	int hf,bf,hc,bc;

	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){
		hc=0,bc=0;
		for(int i=0;i<4;i++){
			hf=0,bf=0;
			for(int j=0;j<4;j++){
				if(a[i]==b[j]){
					bf=1;
					if(i==j){
						hf=1;
					}
				}
			}
			if(hf==1){
				hc++;
			}
			else if(bf==1){
				bc++;
			}
		}
		printf("%d %d\n",hc,bc);
	}
	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;
				
			count += std::count(A.begin(), A.end(), B[i]);

		}

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

		return 0;

}

C++: /*AOJ 0025*/

#include<iostream>

using namespace std;

int Hit(int *a,int *b){
	int sum=0;

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

	return sum;
}

int Blow(int *a,int *b){

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

	return sum;
}

int main(){

	int a[4],b[4];

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

		cout<<Hit(a,b)<<" "<<Blow(a,b)<<endl;
	}

	return 0;
}

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

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 h=0,k=0;
    for(int i=0; i<4; i++) {
      for(int j=0; j<4; j++) {
	if(a[i] == b[j]) {
	  if(i==j) h++;
	  else k++;
	}
      }
    }

    cout<<h<<" "<<k<<endl;
  }
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()

int main() {
    int s;
    while (cin >> s) {
        int a[4];
        int b[4];
        a[0] = s;
        REP(i,3) cin >> a[i+1];
        REP(i,4) cin >> b[i];
        
        int hit = 0;
        REP(i,4) {
            if (a[i] == b[i]) hit++;
        }
        
        int blow = 0;
        REP(i,4) {
            if (find(begin(a), end(a), b[i]) != end(a)) blow++;
        }
        
        cout << hit << " " << blow - hit;
    }
    return 0;
}