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 <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 (cin>>a[0]) {
		for_(i, 1, 4) cin>>a[i];
		for_(i, 0, 4) cin>>b[i];
		memset(use, 0, sizeof(use));
		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 hit, brow;

void op(int a[4], int b, int i)
{
  for (int j = 0; j < 4; j++){
    if (b == a[j] && i == j){
      hit++;
    }
    else if (b == a[j] && i != j){
      brow++;
    }
  }
}

int main()
{
  int a[4], b[4];
  int i;
  
  while (cin >> a[0] >> a[1] >> a[2] >> a[3]){
    cin >> b[0] >> b[1] >> b[2] >> b[3];
    hit = brow = 0;
    for (i = 0; i < 4; i++){
      op(a, b[i], i);
    }
    
    cout << hit << " " << brow << endl;
  }
}

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

using namespace std;

int main(void) {
	int a[4], b[4];
	int hit, blo;

	while (true) {
		for (int i = 0; i < 2; ++i) {
			for (int j = 0; j < 4; ++j) {
				if (i == 0) {
					cin >> a[j];
				} else {
					cin >> b[j];
				}
				if (cin.eof()) {
					return 0;
				}
			}
		}
		hit = blo = 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 {
						blo++;
					}
				}
			}
		}
		cout << hit << " " << blo << endl;
	}
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000009
#define EPS 1E-9

int a[4];
int b[4];
bool used[2][4];

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

    int hit = 0;
    int blow = 0;
    rep(i, 4) used[0][i] = used[1][i] = false;
    rep(i, 4) if(a[i] == b[i]) hit += 1,  used[0][i] = used[1][i] = true;
    rep(i, 4) rep(j, 4) if(a[i] == b[j] && !used[0][i] && !used[1][j]) blow += 1;

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

  return 0;
}

C++: #include <stdio.h>

int main(){
	int i,j,a[4],b[4],hit,blow;
	while(scanf("%d %d %d %d",&a[0],&a[1],&a[2],&a[3]) != EOF){
		hit = 0;
		blow = 0;
		scanf("%d %d %d %d",&b[0],&b[1],&b[2],&b[3]);
		for(i = 0;i < 4;i++){
			for(j = 0;j < 4;j++){
				if(a[i] == b[j]){
					if(i == j) hit++;
					else blow++;
				}
			}
		}
		printf("%d %d\n",hit,blow);
	}
}

C++: #include <iostream>

int main(int argc, const char * argv[])
{
    int a1, a2, a3, a4, b1, b2, b3, b4;
    int cnt_h, cnt_b;
    while (std::cin >> a1 >> a2 >> a3 >> a4 >> b1 >> b2 >> b3 >> b4) {
        cnt_h = cnt_b = 0;
        cnt_h = (a1 == b1) + (a2 == b2) + (a3 == b3) + (a4 == b4);
        if (a1 != b1) {
            cnt_b = (a1 == b2) + (a1 == b3) + (a1 == b4);
        }
        if (a2 != b2) {
            cnt_b += (a2 == b1) + (a2 == b3) + (a2 == b4);
        }
        if (a3 != b3) {
            cnt_b += (a3 == b1) + (a3 == b2) + (a3 == b4);
        }
        if (a4 != b4) {
            cnt_b += (a4 == b1) + (a4 == b2) + (a4 == b3);
        }
        printf("%d %d\n", cnt_h, cnt_b);
    }
    return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
	vint a(4), b(4);
	while(true)
	{
		rep(i, 8)
			cin >> (i < 4 ? a[i] : b[i-4]);
		if(cin.eof()) break;

		int hit = 0;
		rep(i, 4)
			hit += a[i] == b[i];

		int brow = -hit;
		rep(i, 4)
			brow += (a[i] == b[0] || a[i] == b[1] || a[i] == b[2] || a[i] == b[3]);
		cout << hit << " " << brow << endl;
	}
}

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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

int main()
{
    while (true)
    {
        int a[4], b[4];
        if (cin.eof())
            break;
        rep(j, 4) cin >> a[j];
        rep(j, 4) cin >> b[j];
        int hit = 0, bl = 0;
        rep(i, 4)
        {
            rep(j, 4)
            {
                if (a[i] == b[j])
                {
                    if (i == j)
                        hit++;
                    else
                        bl++;
                }
            }
        }
        cout << hit << ' ' << bl << endl;
    }
    return 0;
}