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;
int main(){
    int a[4][50],b[4][50],hit,blow,n;
    n = 50;
    for(int i = 0;i < 50;i++){
        cin >> a[0][i] >> a[1][i] >> a[2][i] >> a[3][i] 
            >> b[0][i] >> b[1][i] >> b[2][i] >> b[3][i] ;
        
    } 
    for(int i = 0;i < n;i++){
        hit = blow = 0;
        for(int j = 0;j < 4;j++){
            for(int k = 0;k < 4;k++){
                if(a[j][i] == b[k][i]){
                    if(j == k){
                        hit++;
                    }
                    else{
                        blow++;
                    }
                }
            }
        }
        cout << hit << " " << blow << endl;
    }
}

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);
     
    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<stdio.h>
int main(){
	int a[4],b[4];
	while(~scanf("%d %d %d %d\n%d %d %d %d",&a[0],&a[1],&a[2],&a[3],&b[0],&b[1],&b[2],&b[3])){
		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;
		printf("%d %d\n",hit,blow);}
	return 0;}

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

int main(void){
	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];
		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(i != j && a[i] == b[j])	blow++;
			}
		}
		cout << hit << " " << blow << endl;
	}
  return 0;
}

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

int main(void){
    int a[4];
    int b[4];
    
    while((scanf("%d", &a[0])) != EOF){
        int hitcount = 0;
        int bcount   = 0;
        
        for(int i = 1; i < 4; i++){
            scanf("%d", &a[i]);
        }
        
        for(int i = 0; i < 4; i++)
            cin >> b[i];
        
        //a???????????????????????????????´????b????????¢??¢?´¢
        for(int i = 0; i < 4; i++){
            int x = a[i];
            for(int j = 0; j < 4; j++){
                if(x == b[j]){
                    if(i == j) hitcount++;
                    else bcount++;
                }
            }
        }
        
        cout << hitcount << " " << bcount << endl;
    }
    
    return 0;
}

C++: #include <iostream>

int main(int argc, char **argv)
{
	int a[4];
	int b[4];
	while(std::cin >> a[0] >> a[1] >> a[2] >> a[3]){
		std::cin >> b[0] >> b[1] >> b[2] >> b[3];
		int hit = 0, 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>

using namespace std;

int main(void) {
  int A[4];
  int B[4];
  int blow;
  int hit;
  int tmp;

  while(cin >> tmp) {
    blow = 0;
    hit = 0;
    
    A[0] = tmp;
    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++;
      }
      else {
        for(int j = 0; j < 4; j++) {
          if(A[i] == B[j]) {
            blow++;
          }
        }
      }
    }
    cout << hit << " " << blow << endl;
  }

  return 0;
}

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

int main() {

  int a[4],b[4];

  while(true) {

    if ( cin.eof() ) break;

    cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3];

    int hit = 0;
    int blow = 0;

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

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

	if ( a[i] == b[j] ) {

	  if ( i == j ) {
	    hit++;
	  }else {
	    blow++;
	  }

	}

      }

    }

    cout << hit << " " << blow << endl;

  }

}

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

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

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

/*This function is a counter for "hit" and "blow".*/
void counter(int* n_a, int* n_b, int* hit, int* blow) {

	*hit = 0;
	*blow = 0;

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

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

	return 0;

}

C++: #include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	while(true){
		int pos[10] = {0} , t , ans[2] = {0};
		rep(i,4) if(cin >> t) pos[t] = i+1; else return 0;
		rep(i,4){
			cin >> t;
			if(pos[t]) ans[pos[t]==i+1]++;
		}
		cout << ans[1] << " " << ans[0] << endl;
	}	
}