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

C++: #include<stdio.h>
int main(void)
{
	int i,j;
	int hit,blow;
	int dataA[4],dataB[4];

	while(scanf("%d",&dataA[0])!=EOF) {

		hit=0;
		blow=0;

		for(i=1;i<4;i++){
			scanf("%d",dataA[i]);
		}
		
		for(i=0;i<4;i++) {
			scanf("%d",&dataB[i]);
		}

		for(i=0;i<4;i++) {
			for(j=0;j<4;j++){
				if(dataA[i] == dataB[j] && i==j) {
					hit++;
				}
			}
		}

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

		return 0;
}