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 <iostream>
using namespace std;

#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i,n) REP(i,0,n)

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

C++: #include <iostream>
#include <vector>
#include <array>
 
int get_hit(std::vector<u_int> *A, std::vector<u_int> *B)
{
    u_int hit = 0;
    for(u_int i = 0; i < A -> size(); ++i)
        if(A -> at(i) == B -> at(i))
            ++hit;
             
    return hit;
}
 
int get_blow(std::vector<u_int> *A, std::vector<u_int> *B)
{
    u_int blow = 0;
    for(u_int i = 0; i < A -> size(); ++i){
        for(u_int j = 0; j < B -> size(); ++j){
            if(A -> at(i) == B -> at(j)){
                if(i != j)
                    ++blow;
                break;
            }
        }
    }
             
    return blow;
}
 
int main()
{
    const u_int number = 4;
    std::vector<u_int> A;
    std::vector<u_int> B;
    A.reserve(number);
    B.reserve(number);
     
    std::array<u_int, number> array;
    bool flag = true;
    while(std::cin >> array[0] >> array[1] >> array[2] >> array[3]){
        if(flag){
            A.clear();
            B.clear();
            for(u_int i = 0; i < number; ++i)
                A.push_back(array.at(i));
            flag = !flag;
        }else{
            for(u_int i = 0; i < number; ++i)
                B.push_back(array.at(i));
            std::cout << get_hit(&A, &B) << " " << get_blow(&A, &B) << std::endl;
            flag = !flag;
        }
    }
         
    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;
				
			blow += std::count(A.begin(), A.end(), B[i]);

		}

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

		return 0;

}

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

bool isin(int n, int x[]){
	for (int i=0; i<4; i++)
		if (n==x[i]) return true;
	return false;
}

int main(void){
	
	while (true){
		int a[4],b[4];
		for (int i=0; i<4; i++)
			cin>>a[i];
		if (cin.eof()) break;
		for (int i=0; i<4; i++)
			cin>>b[i];

		int c1=0, c2=0;
		for (int i=0; i<4; i++)
			if (isin(a[i], b))
				if (a[i]==b[i]) c1++;
				else c2++;
		cout<<c1<<" "<<c2<<endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
    int a[4],b[4],hit,blow;
    for(int i = 0;i < 50;i++){
        hit = blow = 0;
        cin >> a[0] >> a[1] >> a[2] >> a[3] 
            >> b[0] >> b[1] >> b[2] >> b[3] ;
        for(int j = 0;j < 4;j++){
            for(int k = 0;k < 4;k++){
                if(a[j] == b[k]){
                    if(j == k){
                        hit++;
                    }
                    else{
                        blow++;
                    }
                }
            }
        }
        cout << hit << " " << blow << endl;
    }
}

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++<24;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 <iostream>
#define N 4
using namespace std;
int main()
{
	int a[N][N];
	while(1)
	{
		for (int j=0;j<N;j++)
			for (int k=0;k<N;k++)
				cin>>a[j][k];
		for (int i=0;i<N;i++)
		{
			if (a[0][i]==a[1][i])
				cout<<a[1][i]<<" "<<"1"<<endl;
			if (a[2][i]!=a[3][i])
				cout<<a[3][i]<<" "<<"0"<<endl;
		}
	}
}

C++: #include<iostream>
using namespace std;
int main(){
    int a,b,c,d,e,f,g,h,x,y;
    cin >> a >> b >> c >> d;
    cin >> e >> f >> g >> h;
        if (a==e){x++;e=e+10;} 
        if (b==f){x++;f=f+10;} 
        if (c==g){x++;g=g+10;}
        if (d==h){x++;h=h+10;}
        if (e==a||e==b||e==c||e==d){y++;}
        if (f==a||f==b||f==c||f==d){y++;}
        if (g==a||g==b||g==c||g==d){y++;}
        if (h==a||h==b||h==c||h==d){y++;}
        cout << x << y << endl;
    
    
return 0 ;
}

C++:  
 #include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 
 using namespace std;
 
 double abs(double x)
 {
   if(x<0) return -x;
   else return x;       
 }
  
 int main()
 {
   int a[4],b[4];
   int hit,blow;
   while(cin>>a[0])
   {
     hit=blow=0;
     for(int i=1;i<4;i++) cin>>a[i];
     for(int i=0;i<4;i++) cin>>b[i];
     for(int i=0;i<4;i++) if(a[i]==b[i]) hit++;
     sort(a,a+4);
     sort(b,b+4);
     for(int i=0;i<4;i++) if(a[i]==b[i]) blow++;
     blow-=hit;
     cout<<hit<<" "<<blow<<endl;
   }
   //while(1);      
   return 0;    
 }

C++: #include <iostream>
using namespace std;
int main(){
	int a[4],b[4];
	while(cin >> a[0]){
		int hit = 0,brow = 0;
		for(int i = 1; i < 4; i++){
			cin >> a[i];
		}
		for(int i = 0; i < 4; i++){
			cin >> b[i];
		}
		for(int i = 0; i < 4; i++){
			for(int j = 0; j < 4; j++){
				if(a[i] == b[j]){
					i == j? hit++ : brow++;
				}
			}
		}
		cout << hit << " " << brow << endl;
	}
	return 0;
}

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

int main(){
	int num1,num2,num3,num4;
	while(std::cin >> num1 >> num2 >> num3 >> num4){
		//player A number
		std::array<int, 4> a_num = {{num1, num2, num3, num4}};
		std::cin >> num1 >> num2 >> num3 >> num4;
		//player B number
		std::array<int, 4> b_num = {{num1, num2, num3, num4}};
		
		int hit=0,blow=0;
		for(int i=0; i<4; ++i){
			for(int j=0; j<4; ++j){
				//equal numbers
				if(a_num[i] == b_num[j]){
					//same place number
					if(i == j){
						++hit;
					}
					//different place number
					else{
						++blow;
					}
				}
			}
		}
		//hit and blow output
		std::cout << hit << " " << blow << std::endl;
	}
}

C++: #include<iostream>
using namespace std;
int main(){
int a[4];
int b[4];
int hit,blow;
while(cin>>a[0]>>a[1]>>a[2]>>a[3]){
cin>>b[0]>>b[1]>>b[2]>>b[3];
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;}}