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<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;

#define clr(p,v) memset(p,v,sizeof(p))

int main()
{
	int a[4],b[4],ans,res;
	bool vis[4];
	while(scanf("%d",&a[0])==1)
	{
		ans = res = 0;
		clr(vis,true);
		for(int i=1;i<4;i++) scanf("%d",&a[i]);
		for(int i=0;i<4;i++) scanf("%d",&b[i]);
		for(int i=0;i<4;i++) if(a[i]==b[i]) { ans++;vis[i]=false; }
		for(int i=0;i<4;i++) if(vis[i])
			for(int j=i+1;j<4;j++) if(vis[j])
			{
				if(a[i] == b[j])
				{
					vis[j] = false;
					res++;
				}
			}
		printf("%d %d\n",ans,res);
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
int main()
{
	std::vector<int> a(4);
	
	while (std::cin >> a[0] >> a[1] >> a[2] >> a[3])
	{
		int hit  = 0;
		int blow = 0;

		for (auto i : a) {
			int b;
			std::cin >> b;
			std::vector<int>::iterator it = find(a.begin(), a.end(), b);
			if (b == a[i]) {
				hit++;
			}
			else if (it != a.end()) {
				blow++;
			}
		}
		std::cout << blow << ' ' << hit<< std::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 (!cin.eof())
    {
        int a[4], b[4];
        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;
}

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

	}

      }

    }

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

  }

}

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

int main() {
  vector<int> a(4);
  while (cin >> a[0] >> a[1] >> a[2] >> a[3]) {
    map<int, int> mp;
    for (int i = 0; i < 4; ++i) mp[a[i]] = i + 1;
    int hit = 0, blow = 0;
    for (int i = 0; i < 4; ++i) {
      int b; cin >> b;
      if (mp[b] > 0) {
        ++( (i + 1 == mp[b]) ? hit : blow );
      }
    }
    cout << hit << ' ' << blow << 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],!cin.eof()){
        int Hit=0,Blow=0;
        bool hantei[4];
        cin>>b[0]>>b[1]>>b[2]>>b[3];
        if(cin.eof()){
            break;
        }
        for(int i=0;i<4;i++){
            if(a[i]==b[i]){
                Hit++;
                hantei[i]=true;
            }
        }
        for(int i=0;i<4;i++){
            for(int j=0;j<4;j++){
                if(i==j){
                    continue;
                }
                if(!(hantei[i]) && b[i]==a[j]){
                    Blow++;
                    break;
                }
            }
        }
        cout<<Hit<<' '<<Blow<<endl;
    }
    return 0;
}

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

int main(){
  std::array<int, 4> a = {};
  std::array<int, 4> b = {};
  int hit = 0;
  int blow = 0;
  int N = 0;

  while(N <= 50 && std::cin >> a[0] >> a[1] >> a[2] >> a[3] && std::cin >> b[0] >> b[1] >> b[2] >> b[3]){
    for(int i = 0;i < 4;++i){
      for(int j = 0;j < 4;++j){
          if(a[i] == b[j] && i == j)
              ++hit;
          if(a[i] == b[j] && i != j)
              ++blow;
            }
        }
    std::cout << hit << " " << blow << std::endl;

    hit = 0;
    blow = 0;
    ++N;
  }
}

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 <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
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()
{
	while(true)
	{
		vint a(4), b(4);

		rep(i, 4)
			cin >> a[i];
		rep(i, 4)
			cin >> b[i];

		int blow = 0, hit = 0;
		rep(i, 4)
		{
			if(a[i] == b[i])
				hit++;
			else
				blow += (0 < count(ALL(b), a[i]));
		}

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

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

int main(void)
{
	int A[4], B[4];

	while(1)
	{
		for(int i=0; i<4; i++)
			cin >> A[i];
		for(int i=0; i<4; i++)
			cin >> B[i];
		if(cin.eof())break;

		int res[4];
		for(int i=0; i<4; i++)
		{
			if(A[i] == B[i])
			{
				res[i] = 1;
			}
			else
			{
				for(int j=0; j<4; j++)
					if(A[j] == B[i])res[i] = 2;
			}
		}

		int hit=0, blow=0;
		for(int i=0; i<4; i++)
		{
				 if(res[i] == 1)hit++;
			else if(res[i] == 2)blow++;
		}
		cout << hit << ' ' << blow << endl;
	}

	return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int a[4],b,i,j,Hit,Blow,x=0;

	while(scanf("%d %d %d %d",&a[0],&a[1],&a[2],&a[3])!=EOF)
	{
		Hit=0;
	    Blow=0;

		for(i=0;i<4;i++)
		{
			scanf("%d",&b);
			if(b==a[i])
				Hit++;
			else
				for(j=0;j<4;j++)
				{
					if(b==a[j])
					{
						Blow++;
						break;
					}
				}
		}
		printf("%d %d\n",Hit,Blow);
	}
  return 0;
}

C++: #include<cstdio>
int main(){
  int a1,a2,a3,a4,b1,b2,b3,b4;
  while(scanf("%d %d %d %d",&a1,&a2,&a3,&a4)>0){
    scanf("%d %d %d %d",&b1,&b2,&b3,&b4);
    int h=0,b=0;
    if(b1==a1) h++;
    if(b1==a2||b1==a3||b1==a4) b++;
    if(b2==a2) h++;
    if(b2==a1||b2==a3||b2==a4) b++;
    if(b3==a3) h++;
    if(b3==a1||b3==a2||b3==a4) b++;
    if(b4==a4) h++;
    if(b4==a1||b4==a2||b4==a3) b++;
    printf("%d %d\n",h,b);
  }
}