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<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
typedef pair<string,string> Ps;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	// 1 変数を入れる;
	int x,y,sx,sy,cost;
};

int main() {

	while(1){
		int a,b,c,d;
		int e,f,g,h;
		int t[10]={};
		int hi=0,bu=0;
		cin>>a>>b>>c>>d;
		cin>>e>>f>>g>>h;
		if(cin.eof())return 0;
		t[a]++;
		t[b]++;
		t[c]++;
		t[d]++;
		t[e]++;
		t[f]++;
		t[g]++;
		t[h]++;
		for(int i=1; i<10; i++){
			if(t[i]==2)bu++;
		}
		if(a==e)hi++;
		if(b==f)hi++;
		if(c==g)hi++;
		if(d==h)hi++;
		cout<<hi<<" "<<bu-hi<<endl;
	}

	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>

using namespace std;

int main(void) {

	int hit = 0, blow = 0;
	int num[4],data[4];

		for (int i = 0; i < 4; i++) {
			cin >> num[i];
		}
		for (int i = 0; i < 4; i++) {
			cin >> data[i];
		}
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				if (i == j && num[i] == data[j])
					hit++;
				else if (num[i] == data[j])
					blow++;
			}
		}
		cout << hit << " " << blow << endl;
		hit = 0, blow = 0;
	

	return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){

  int a[4],b[4],n,m;

  while(cin >> a[0]){
    n = 0;
    m = 0;
    cin >> a[1] >> a[2] >> a[3];
    for(int i=0;i<4;i++){
      cin >> b[i];
      if(a[i] == b[i]) n++;
    }
    sort(a,a+4);
    for(int i=0;i<4;i++){
      if(*lower_bound(a,a+4,b[i])==b[i]) m++;
    }
    cout << n << " " << (m-n) << endl;
  }
  return (0);
}

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

int main(void) {
    std::array<u_int, 4> a;
    std::array<u_int, 4> b;

    while (std::cin >> a[0] >> a[1] >> a[2] >> a[3]
                    >> b[0] >> b[1] >> b[2] >> b[3])
    {
        int hit = 0;
        for (int i = 0; i < 4; ++i) {
            if (a[i] == b[i]) ++hit;
        }

        int blow = -hit;
        std::sort(a.begin(), a.end());
        for (auto v : b) {
            if ( std::binary_search(a.begin(), a.end(), v) ) ++blow;
        }

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

    return 0;
}

C++: #include <iostream>

using namespace std;

int debug = 0;

class ANumber{
private:
	int have[10];
	int place[10];
	int hit;
	int blow;
public:
	ANumber(){
		int i;
		for(i=0;i<=9;i++){
			have[i] = 0;
			place[i] = 0;
		}
		hit = 0;
		blow = 0;
	}

	void clearNum(){
		int i;
		for(i=0;i<=9;i++){
			have[i] = 0;
			place[i] = 0;
		}
		hit = 0;
		blow = 0;
		if(debug) cout << "all reset! " << hit << " " << blow << endl;
	}

	void addNum(int num, int placeNum){
		have[num] = 1;
		place[num] = placeNum;
		if(debug) cout << num << "is placed #" << placeNum << endl;
	}

	void chkNum(int b1, int b2, int b3, int b4){
		if(debug) cout <<"chk"<< b1 << b2 << b3 << b4 << endl;
		if(have[b1] == 1){
			if(place[b1] == 1){
				if(debug) cout << "b1 hit" <<endl; 
				hit++;
			}else{
				if(debug) cout << "b1 blow" <<endl;
				blow++;
			}
		}
		if(have[b2] == 1){
			if(place[b2] == 2){
				if(debug) cout << "b2 hit" <<endl;
				hit++;
			}else{
				if(debug) cout << "b2 blow" <<endl;
				blow++;
			}
		}
		if(have[b3] == 1){
			if(place[b3] == 3){
				if(debug) cout << "b3 hit" <<endl;
				hit++;
			}else{
				if(debug) cout << "b3 blow" <<endl;
				blow++;
			}
		}
		if(have[b4] == 1){
			if(place[b4] == 4){
				if(debug) cout << "b4 hit" <<endl;
				hit++;
			}else{
				if(debug) cout << "b4 blow" <<endl;
				blow++;
			}
		}

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

int main(void){
	ANumber A;
	int a1, a2, a3, a4;
	int b1, b2, b3, b4;

	while(cin >> a1 >> a2 >> a3 >> a4){
		A.addNum(a1, 1);
		A.addNum(a2, 2);
		A.addNum(a3, 3);
		A.addNum(a4, 4);
		cin >> b1 >> b2 >> b3 >> b4;
		A.chkNum(b1, b2, b3, b4);
		A.clearNum();
	}

	return 0;
}

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

int hit(int str[],int str2[]){
  int i, j = 0;

  for(i = 0;i < 4;i++){
    if(str[i] == str2[i]){
      j++;
    }
  }

  return j;
}

int blow(int str3[],int str4[]){
  int i, j = 0;

  sort(str3, str3 + 4);
  sort(str4, str4 + 4);

  for(i = 0;i < 4;i++){
    if(str3[i] == str4[i]){
      j++;
    }
  }

  return j;
}

int main(){
  int str[4], str2[4];

  cin >> str[0] >> str[1] >> str[2] >> str[3];

  cin >> str2[0] >> str2[1] >> str2[2] >> str2[3];

  int hit_var = hit(str, str2);
  int blow_var = blow(str, str2);

  cout << hit_var << " " << blow_var - hit_var << endl;

  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int a[4]={0},b[4]={0},hi,br;
	while(cin>>a[0]>>a[1]>>a[2]>>a[3]>>b[0]>>b[1]>>b[2]>>b[3]){
		hi=0;
		br=0;
		for(int i=0;i<4;i++){
			if(a[i]==b[i]){
				hi++;
			}
		}
		for(int i=0;i<4;i++){
			for(int n=0;n<4;n++){
				if(i!=n&&a[i]==b[n]){
					br++;
					cout<<br<<endl;
				}
			}
		}
		cout<<hi<<" "<<br<<endl;
	}
}

C++: #include <bits/stdc++.h>

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;

int main() {
	int a[4], b[4];
	while (cin >> a[0]) {
		rep (i, 3) cin >> a[i + 1];
		rep (i, 4) cin >> b[i];

		int hit = 0, blow = 0;
		rep(i, 4) {
			rep(j, 4) {
				if (a[i] == b[j]) blow++;
			}
			if (a[i] == b[i]) {
				hit++;
				blow--;
			}
		}
		cout << hit << " " << blow << endl;
	}
}

C++: #include<iostream>
#include<iomanip>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<algorithm>
#include<cmath>
#include<memory>
#include<array>

using namespace std;

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

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

      int ht = 0;
      int bl = 0;
      
      for ( auto i = 0; i < 4; ++i )
        for ( auto j = 0; j < 4; ++j )
          if ( a[i] == b[j] )
            if ( i == j )
              ++ht;
            else
              ++bl;
      cout << ht << " " << bl << endl;
    }
  
  return 0;
}