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 <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        vector<int> a(4), b(4);
        for(int i=0; i<4; ++i)
            if(!(cin >> a[i]))
                return 0;
        for(int i=0; i<4; ++i)
            cin >> b[i];

        int ret = 0;
        for(int i=0; i<4; ++i)
            if(a[i] == b[i])
                ++ ret;
        cout << ret << ' ';

        sort(a.begin(), a.end());
        sort(b.begin(), b.end());
        ret = -ret;
        int i=0, j=0;
        while(i < 4 && j < 4){
            if(a[i] < b[j])
                ++ i;
            else if(a[i] > b[j])
                ++ j;
            else{
                ++ ret;
                ++ i;
                ++ j;
            }
        }
        cout << ret << 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]; 
		hit = 0;
		blow = 0;
		for(int i = 0; i < 4; i++){
			if(b[i] == a[i]){
				hit++;
			}else{
				for(int j = 0; j < 4; j++){
					if(b[i] == a[j]){
						blow++;
						break;
					}
				}
			}
		}
		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++ ) {

	int k = ( i + j ) % 4;

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

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

	}

      }

    }

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

  }

  return 0;

}

C++: #include <iostream>
#include <string>
using namespace std;
int main(){
int a[4];
int b[4];
int c;
int d;
int e;
int f;
while(cin >>a[0]>>a[1]>>a[2]>>a[3]>>b[0]>>b[1]>>b[2]>>b[3]){
e=0;
f=0;
c=0;
while(c<4){
d=0;
while(d<4){
if(a[c]==b[d]){if(c==d){e=e+1;} else{f=f+1;}
d=d+1;}
c=c+1;}
cout <<e<<" "<<f<<endl;
}}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=10000009;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };
int main() {
	int a[4],d[4];
	while(true){
		int h=0,b=0;
		cin>>a[0]>>a[1]>>a[2]>>a[3]>>d[0]>>d[1]>>d[2]>>d[3];;
		if (cin.eof())break;
		for(int i=0;i<4;i++){
			for(int j=0;j<4;j++){
				if(i==j&&a[i]==d[j]) h++;
				if(i!=j&&a[i]==d[j]) b++;
			}
		}
		cout<<h<<" "<<b<<endl;
	}
}

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;
			for(int j=0;j<4;j++){
				if(a[i]==b){
					H++;
				}else if(a[j]==b){
					B++;
				}
			}
		}
		H/=4;
		if(H==4)break;
		cout<<H<<" "<<B<<endl;;
	}
	return 0;
}

C++: #include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
	int a[4],b[4];
	while(cin>>a[0]>>a[1]>>a[2]>>a[3]>>b[0]>>b[1]>>b[2]>>b[3]){
		int hit=0,bl_a=0,bl_b=0,blow=0;
		for(int i=0;i<4;i++){
			if(a[i]==b[i])hit++;
			else{bl_a+=1<<(a[i]-1);bl_b+=1<<(b[i]-1);}
		}
		int ans=bl_a&bl_b;
		for(int i=0;i<10;i++)if(ans>>i&1)blow++;
		printf("%d %d\n",hit,blow);
	}
    return 0;
}

C++: #include <iostream>
#include <vector>
bool input (std::vector<int> & v)
{
	for (std::vector<int>::size_type i = 0; i < v.size(); i++) {
		if(!(std::cin >> v[i])) return false;
	}
	return true;
}
void get_hit_blow(int & hit, int & blow, std::vector<int> a, std::vector<int> b)
{
	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;
		}
	}
}
int main()
{
	std::vector<int> a(4), b(4);
	while (input(a) && input(b)) {
		int hit = 0, blow = 0;
		get_hit_blow(hit, blow, a, b);
		std::cout << hit << ' ' << blow - hit << std::endl;
	}
}

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


int main(){
  vector<int> a(4), b(4);

  while(cin >> a[0]){
    cin >> a[1] >> a[2] >> a[3];
    cin >> b[0] >> b[1] >> b[2] >> b[3];

    int hit = 0, 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 <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <iostream>


using namespace std;

int main()
{
	int a[4], b[4];
	while (!feof(stdin))
	{
		for (int i = 0; i < 4; ++i)
			scanf("%d", a+i);
		for (int i = 0; i < 4; ++i)
			scanf("%d", b+i);

		set<int> included;
		for (int i = 0; i < 4; ++i)
			included.insert(a[i]);
		
		int hit, blow;
		hit = blow = 0;
		for (int i = 0; i < 4; ++i)
		{
			if (a[i] == b[i])
				++hit;
			else if (included.count(b[i]) > 0)
				++blow;
		}
		printf("%d %d\n", hit, blow);
	}
	
	return 0;
}

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

int main(){

    std::array<int, 4> num_a, num;

    while(std::cin >> num_a[0] >> num_a[1] >> num_a[2] >> num_a[3]){
        std::cin >> num[0] >> num[1] >> num[2] >> num[3];
        int hit = 0, blow = 0;
        for(size_t i = 0; i < 4; ++i){
            if(num_a[i] == num[i]){
                ++hit;
            }else{
                for(size_t j = 0; j < 4; ++j){
                    if(num_a[j] == num[i]){
                        ++blow;
                    }
                }
            }
        }
        std::cout << hit << " " << blow << std::endl;
    }

    return 0;
}

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