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 <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>

#define ll (long long)
#define REP(i,n) for(int i = 0;i<(int)n;i++)
#define FOR(i,a,b) for(int i = (a);i < (b);i++)
#define RFOR(i,a,b) for(int i = (a);i>(b);i--)


using namespace std;

int main (void){
    
    int a[500] = {0};
    int b[500] = {0};
    int i= 0,j = 0,k = 0,l = 0;
    int answer[1000][2] = {0};
    
    while(cin >> a[i++] >> a[i++] >> a[i++] >> a[i++])
    {
        cin >> b[j++] >> b[j++] >> b[j++] >> b[j++];
        
        FOR(m,i-4,i)
            if(a[m] == b[m])
                answer[l][0]++;
        FOR(m,i-4,i)
            FOR(k,i-4,i)
                if(a[m] == b[k] && m != k)
                    answer[l][1]++;
        l++;
    }
    REP(m,l)
    cout << answer[m][0] << " " << answer[m][1] << endl;
    return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int a[5],b[5],hit=0,brow=0;
    while(cin>>a[0]>>a[1]>>a[2]>>a[3]>>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[i]){
                hit++;
                break;
            }
            else if(a[i]==b[j])brow++;
        }
    }
    cout<<hit<<" "<<brow<<endl;
    }
return 0;
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>

typedef long long ll;
using namespace std;

int main()
{
	int c[8];
	while(~scanf("%d",c)){
		for(int i=1;i<8;i++){
			scanf("%d",c+i);
		}
		int h=0;
		int b=0;

		for(int i=0;i<4;i++){
			if(c[i]==c[i+4]){
				h++;
			}
		}

		for(int i=0;i<4;i++){
			for(int j=0;j<4;j++){
				if(c[i]==c[j+4] && i!=j){
					b++;
				}
			}
		}
		printf("%d %d\n",h,b);
	}
}

C++: #include<bits/stdc++.h>
using namespace std;

int main(){
	string sa,sb;
	int ca=0,cb=0;
	while(getline(cin,sa),getline(cin,sb)){
		if(sa[0]==sb[0]){ca++;}
		if(sa[2]==sb[2]){ca++;}
		if(sa[4]==sb[4]){ca++;}
		if(sa[6]==sb[6]){ca++;}
		
		if(sa[0]==sb[2]||sa[0]==sb[4]||sa[0]==sb[6]){cb++;}
		if(sa[2]==sb[0]||sa[2]==sb[4]||sa[2]==sb[6]){cb++;}
		if(sa[4]==sb[0]||sa[4]==sb[2]||sa[4]==sb[6]){cb++;}
		if(sa[6]==sb[0]||sa[6]==sb[4]||sa[6]==sb[2]){cb++;}
		
		cout<<ca<<" "<<cb<<endl;
		ca=0;cb=0;
		}
		return 0;
	}

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

int main(){

	std::array<int, 4> A;
	while(std::cin >> A[0] >> A[1] >> A[2] >> A[3]){
		std::array<int, 4> B;
		std::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;
			else
				for(int j=0; j<4; ++j)
					if( A[i] == B[j] )
						++blow;
		}
		std::cout << hit << " " << blow << std::endl;
	}
	return 0;
}

C++: #include <iostream>
int main()
{

		int a[4], b[4];
		int eat = 0, bite = 0;
		for (int i = 0; i < 4; i++) {
			std::cin >> a[i];
		}
		for (int i = 0; i < 4; i++) {
			std::cin >> b[i];
		}
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				if (i == j&&a[i] == b[j]) {
					eat++;
				}
				else if (a[i] == b[j]) {
					bite++;
				}
			}
		}
		std::cout << eat << " " << bite << std::endl;
	return 0;
}

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

int a[4],b[4];
int main(){
  int i,j,m,n,x;
  for(;~scanf("%d%d%d%d%d%d%d%d",a,a+1,a+2,a+3,b,b+1,b+2,b+3);printf("%d %d\n",x,m-x)){
    for(m=x=i=j=0;i<4;i++)if(a[i]==b[i])x++;
    for(;j++<25;next_permutation(b,b+5),m=n>m?n:m)for(n=i=0;i<4;i++)if(a[i]==b[i])n++;
  }
}

C++: #include<stdio.h>

int main(void){
	
	int d1[4],d2[4];
	short flag[4];
	
	int i,j,k,l;
	int h,b;
	
	h = 0;
	b = 0;
	
	scanf(" %d %d %d %d",d1[0],d1[1],d1[2],d1[3]);
	scanf(" %d %d %d %d",d2[0],d2[1],d2[2],d2[3]);
	
	for(i = 0;i < 4;i++){
		if(d1[i] == d2[i]){
			flag[i] == 1;
		}
	}
	
	for(i = 0;i < 4;i++){
		if(flag[i]==1){
			continue;
		}
		for(j = 0;j < 4;j++){
			if(flag[j]==1){
				continue;
			}else if(d1[i] == d2[j]){
				b++;
			}
		}
	}
	
	for(i = 0;i < 4;i++){
		if(flag[i]==1){
			h++;
		}
	}
	
	printf("%d %d",h,b);
	
	return(0);
	
}

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

#define M 4
int a[M], b[M];

double sub_in(int a[], int n)
{
	for (int i = 0; i < n; i++)
	{
		if (!(cin >> a[i]))
			return false;
	}
	return true;
}

bool in_ab(int a[], int b[], int n)
{
	if (!sub_in(a, n) || !sub_in(b, n))
		return false;
	return true;
}

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

int blow(int a[], int b[], int n)
{
	int c = 0;
	for(int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
		{
			if (a[i] == b[j] && i != j)
				c++;
		}
	return c;
}

int main()
{
	while (in_ab(a,b,M))
	{
		cout << hit(a,b,M) << " " << blow(a,b,M) << endl;
	}
	return 0;
}

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

int main() {

	std::array<int, 4> n_a;//selection of "A"
	std::array<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(int* n_a,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
			}
		}
	}

}

C++: #include<iostream>

int main(){
int a[4],b[4],i,j,H,B;
	while(std::cin>>a[0]){
		for(i=0;i<4;i++){
			std::cin>>a[i];
		}
		for(j=0;j<4;j++){
			std::cin>>b[j];
		}
		H=0;
		B=0;
		for(i=0;i<4;i++){
			for(j=0;j<4;j++){
				if(a[i]==b[j]){
					if(i==j){
						H++;
					}
					else(){
						B++;
					}
				}
			}
		}
		std::cout<< H << " " << B <<std::endl;
	}
return 0;
}

C++: #define scanf_s scanf
//#define gets_s gets
#include <stdio.h>
#include <string>
#include <iostream>
#include <math.h>
using namespace std;
#define MAX 50//00
#define MIN -100001
#define _MAX 100
#define g 9.8
#define d 4.9
int main(void)
{
	int a[4], b[4], hit = 0, blow = 0;
	while (scanf_s("%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) {
		for (int i = 0; i < 4; ++i) {
			for (int j = 0; j < 4; ++j) {
				if (b[i] == a[j]) {
					if (i == j) ++hit;
					else ++blow;
				}
			}
		}
		printf("%d %d\n", hit, blow);
		hit = blow = 0;
	}
}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
bool use[10];
int main()
{
    int a[4],b[4];
    while(~scanf("%d%d%d%d",&a[0],&a[1],&a[2],&a[3])){
        memset(use,0,sizeof(use));
        for(int i=0;i<4;i++) use[a[i]]=1;
        scanf("%d%d%d%d",&b[0],&b[1],&b[2],&b[3]);
        int aa=0,bb=0;
        for(int i=0;i<4;i++){
            if(a[i]==b[i]) aa++;
            else if(use[b[i]]) bb++;
        }
        cout<<aa<<" "<<bb<<endl;
    }
    return 0;
}