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 <algorithm>
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, blow=0;
    bool checked[4][4]; for(int i=0;i<4;i++)for(int j=0;j<4;j++)checked[i][j]=false;
    
    for(int i = 0; i < 4; i++) {
      for(int j = i; j < 4; j++) {
	if(checked[i][j]) continue;
	
	if(i == j && a[i] == b[j]) {
	  hit++;
	  checked[i][j] = true; checked[j][i] = true;
	}
	else if(a[i] == b[j]) {
	  blow++;
	  checked[i][j] = true; checked[j][i] = true;
	}
      }
    }

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

C++: #include<iostream>
#include<fstream>
#include<vector>
#include<string>

using namespace std;

string HitBlow(vector<int> A, vector<int> B){
	int hit = 0, blow = 0;
	for(int i = 0; i< 4; i++)
		if(A[i] == B[i]){
			B[i] = -1;
			hit++;
		}
	for(int i = 0; i< 4; i++){
		if(B[i] == -1) continue;
		for(int j = 0; j< 4; j++){
			if(A[j] == B[i]){
				blow++;
			}
		}
	}
	string rtn = to_string(hit)+" "+to_string(blow)+"\n";
	return rtn;
}

int main(){
	vector< vector<int> > inputA, inputB;
	bool isA = true;
	string line;
	ofstream outfile("outfile.txt");
	ifstream input_file("test_input.txt");
	if(input_file.is_open()){
		while(getline(input_file, line)){
			vector<int> tmp;
			for(int i = 0; i< line.length(); i++){
				if(line[i] == ' ') continue;
				tmp.push_back(int(line[i]-'0'));
			}
			if(isA)
				inputA.push_back(tmp);
			else
				inputB.push_back(tmp);
			isA = !isA;
		}
	}
	string ss;
	for(int i = 0; i< inputA.size(); i++){
		ss = HitBlow(inputA[i], inputB[i]);
		if(outfile.is_open())
			outfile<<ss;
	}
	return 0;
}

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

int main(){
  int A[4];
  int B[4];
  while(cin >> A[0] >> A[1] >> A[2] >> A[3]){
    cin >> B[0] >> B[1] >> B[2] >> B[3];
    
    int hit = 0;
    int blow = 0;
    for(int i=0;i<4;i++){
      if(A[i] == B[i]) hit++;

      for(int j=0;j<4;j++){
        if(j==i) continue;
        else if(B[i] == A[j]) blow++;
      }
    }
    cout << hit << " " << blow << endl;
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

int main() {
    while (1) {
        int a[4], b[4], hit = 0, blow = 0;
        for (int i = 0; i < 4; i++) {
            if (!(cin >> a[i])) {
                return 0;
            }
        }
        for (int i = 0; i < 4; i++) {
            cin >> b[i];
            if (a[i] == b[i]) {
                hit++;
            }
        }
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                if (i == j) {
                    continue;
                }
                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],count,count_2;

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

		for(int i=0;i<4;i++)
		{
			for(int j=0;j<4;j++)
			{
				if(a[i] == b[j])
				{
					if(i == j)
					{
						count++;
					}
					else
					{
						count_2++;
					}
				}
			}
		}
		cout << count << " " << count_2 << endl;

	}
	return 0;
}

C++: #include <iostream>

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, blow=0;
		for (int i=0; i<4; i++) {
			for (int j=i; j<4; j++) {
				if (i==j&&a[i]==b[j]) hit++;
				else if (a[i]==b[j]) blow++;
			}
		}
		cout << hit << " " << blow << endl;
	}
}

C++: #include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

#define vcitr vector<int>::iterator
#define vcsitr vector<string>::iterator
#define mapcitr map<char, int>::iterator
#define mapsitr map<string, int>::iterator

typedef long long ll;

const int iINF = 2147483647;
const ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }

int main() {
	vci a(4), b(4);
	bool use[10] = { 0 };
	
	while (~scanf("%d %d %d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &b[0], &b[1], &b[2], &b[3])) {		
		for_(i, 0, 4) use[ a[i] ] = 1;
		
		int hit = 0, blow = 0;
		for_(i, 0, 4) {
			if (a[i] == b[i]) hit++;
			else if (use[ b[i] ]) blow++;
		}
		cout << hit << " " << blow << endl;
	}
	
	return 0;
}

C++: #include<iostream>

using namespace std;

int main()
{
	int ss[8],i,j;
	int ans[2];
	
	for(;cin >> ss[0];)
	{
		ans[0]=ans[1]=0;
		
		for(i=1;i<8;i++)
			cin >> ss[i] ;
		
		for(i=0;i<4;i++)
		{
			if(ss[i]==ss[i+4])
			{
				ans[0]++;
				ss[i+4]=-1;
			}
		}
		for(i=0;i<4;i++)
			for(j=4;j<8;j++)
				if(ss[i]==ss[j])
					ans[1]++;
		
		cout << ans[0] << " " << ans[1] << endl;
	}
}

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

int main(){

	int a1, a2, a3, a4, b1, b2, b3, b4;

	while(std::cin >> a1 >> a2 >> a3 >> a4){
		
		std::cin >> b1 >>b2 >> b3 >>b4;

		std::array<int> A = {a1, a2, a3, a4};
		std::array<int> B = {b1, b2, b3, b4};
		
		int hit = 0;
		int blow = 0;

		for(int i = 0; i < 4; ++i){
			
			if(A[i] == B[i])
				hit++;
				
			count += std::count(A.begin(), A.end(), B[i]);

		}

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

		return 0;

}

C++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
const int MAX = (int)2e5 + 5;

int a[4];
int b[4];

int main() {
	while (cin >> a[0]) {
		rep(i, 3) {
			cin >> a[i+1];
		}
		rep(i, 4) {
			cin >> b[i];
		}
		int hit_n = 0;
		rep(i, 4) {
			if (a[i] == b[i]) hit_n++;
		}
		int blow_n = 0;
		rep(i, 4) rep(j, 4) {
			if (i == j) continue;
			if (a[i] == b[j]) blow_n++;
		}
		cout << hit_n << " " << blow_n << endl;
	}
	return 0;
}

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