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>
#include <vector>

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);
    
    u_int num1, num2, num3, num4;
    bool flag = true;
    while(std::cin >> num1 >> num2 >> num3 >> num4){
        if(flag){
            A.clear();
            B.clear();
            A.push_back(num1);
            A.push_back(num2);
            A.push_back(num3);
            A.push_back(num4);
            flag = !flag;
        }else{
            B.push_back(num1);
            B.push_back(num2);
            B.push_back(num3);
            B.push_back(num4);
            std::cout << get_hit(&A, &B) << " " << get_blow(&A, &B) << std::endl;
            flag = !flag;
        }
    }
        
    return 0;
}

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

int main(){
	std::vector<int> a(4);
	
	while(std::cin >> a[0] >> a[1] >> a[2] >> a[3]){
		int hit = 0, blow = 0;
		
		for(int i = 0; i < 4; ++i){
			int b;
			std::cin >> b;
			
			auto it = std::find(a.begin(), a.end(), b);
			if(it == a.begin() + i) ++hit;
			else if(it != a.end()) ++blow;
		}
		
		std::cout << hit << " " << blow << std::endl;
		
	}
	
	return 0;
}

C++: //26
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  for(;;){
    int n[8];
    for(int i=0;i<8;i++){
      if(!(cin>>n[i]))return 0;
    }
    int hit=0;
    for(int i=0;i<4;i++){
      hit+=n[i]==n[i+4];
    }
    int blow=-hit;
    for(int i=0;i<4;i++){
      blow+=find(n+4,n+8,n[i])!=n+8;
    }
    cout<<hit<<' '<<blow<<endl;
  }
}

C++: def hit_blow(arr1, arr2)
  n, m = 0, 0
  
  4.times do |i|
    n += 1 if arr1[i] == arr2[i]
    m += 1 if arr1.include?(arr2[i]) 
  end
  
  return [n, m - n]
end

while gets
  arr1, arr2 = $_.split, gets.split
  h, b = hit_blow(arr1, arr2)
  puts "#{h} #{b}"
end

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

int h(int a, int b){
	if(a==b){
		return 1;
	}
	else {
		return 0;
	}
}

int main(){
	int a[4], b[4];

	while (true)
	{
		cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3];
		if (cin.eof()) { break; }
		int hit = 0, blow = 0;
		for(int i=0;i<4;i++){
			for (int j = 0;j<4;j++){
				if (i==j){
					hit += h(a[i], b[j]);
				}
				else{
					blow += h(a[i], b[j]);
				}
			}
		}
		cout << hit << " " << blow << endl;
	}

	return 0;
}

C++: #include <iostream>

using namespace std;

int main(int argc, char **argv)
{
	int a[4], b[4], s, t; 
	
	while(cin >> a[0] >> a[1] >> a[2] >> a[3]){
		cin >> b[0] >> b[1] >> b[2] >> b[3];
		s = t = 0;
		for(int i = 0; i < 4; i++){
			if(a[i] == b[i]){
				a[i] = b[i] = -1;
				s++;
			}
		}
		
		for(int i = 0; i < 4 && s != 4; i++){
			for(int j = 0; j < 4 && a[i] != -1; j++){
				if(a[i] == b[j]){
					t++;
				}
			}
		}
		
		cout << s << " " << t << endl;
	}
	
	return 0;
}

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

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

int main(){
	std::array(u_int, 4) a, b;
	int hit=0, blow=0;

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

    return 0;
}

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

int main(void){
  int Q,A,qq[4],aa[4],Hit,Blow,num;


  while(1){

    num = 1000;
    Hit = Blow = 0;

  cin >> Q >> A;
  if( Q == 0 && A == 0 ) break;

  for( int i = 0 ; i < 4 ; i++ ){

    qq[i] = Q / num % 10;
    aa[i] = A / num % 10;
    num /= 10;

  }

  for( int i = 0 ; i < 4 ; i++ ){
    for( int j = 0 ; j < 4 ; j++ ){

      if( qq[i] == aa[j] && i == j ) Hit++;
      else if( qq[i] == aa[j] && i != j ) Blow++;

    }
  }

  cout << Hit << " " << Blow << endl;

  }

  return 0;
}

C++: /***** ?????¬???????????¬?????? *****/

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

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int const MOD = 1000000007;

int main() {
    set<int>s1, s2;
    int a[4], b[4];
    while(cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) {
        rep(i,0,4) s1.insert(a[i]);
        rep(i,0,4) s2.insert(b[i]);

        int hit = 0, blow = 0;
        rep(i,0,4) {
            if(a[i] == b[i]) hit++;
            else if(s1.count(b[i]) != 0) blow++;
        }

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

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

int main(){
  int a[4],c[4];
  while(1){
    int e=0,b=0,k;
    for(int i=0;i<4;i++)
      k=cin >> a[i];
    if(!k)break;
    for(int i=0;i<4;i++){
      cin >> c[i];
      for(int j=0;j<4;j++)
	if(c[i]==a[j]){
	  if(i==j)e++;
	  else b++;
	}
    }
    cout<<e<<' '<<b<<endl;
  }
  return 0;
}

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

int main(void){
  int a[50][4];
  int b[50][4];
  int i=0, 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(cin>>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++;
  	i++;
  }
  
  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;
}