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++)
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;
		int blow = 0;
		rep(i, 4)if (a[i] == b[i])hit++;
		rep(i, 4) if (find(a, a + 4, b[i]) != a + 4)blow++;
		cout << hit << ' ' << blow - hit << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
    int a,b,c,d,e,f,g,h,x=0,y=0;
    while(cin >> a >> b >> c >> d >> e >> f >> g >> h){
        x=0;
        y=0;
        if (a==e){x=x+1} 
        if (b==f){x=x+1} 
        if (c==g){x=x+1}
        if (d==h){x=x+1}
        if (e==a || e==b || e==c || e==d){y=y+1;}
        if (f==a || f==b || f==c || f==d){y=y+1;}
        if (g==a || g==b || g==c || g==d){y=y+1;}
        if (h==a || h==b || h==c || h==d){y=y+1;}
        cout << x << " " << y << endl;
    }  
return 0 ;
}

C++: #include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int a[4], b;

signed main() {
	while (cin>>a[0]>>a[1]>>a[2]>>a[3]) {
		int x = 0, y = 0;
		rep(i,4) {
			cin >> b;
			rep(j,4) if (a[j]==b) (i==j ? x : y)++;
		}
		cout << x << ' ' << y << endl;
	}
}

C++: 
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <utility>
#include <complex>
#include <stack>
#include <climits>

using namespace std;

double sq(double x){return x*x;}


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,brow = 0;
		for (int i = 0; i < 4; i++)
		{
			if(a[i] == b[i])
				hit++;
			else if(find(a,a+4,b[i]) != a+4)
				brow++;
		}

		printf("%d %d\n",hit,brow);
	}

	return 0;
}

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

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

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

  return j;
}

int blow(char str3[],char str4[]){
  int i, j = 0;
  char str5[2] = "";

  for(i = 0;i < 4;i++){
    strcpy(str5, "");
    strncat(str5, str4+i, 1);
    if(strstr(str3,str5) != NULL){
      j++;
    }
  }

  return j;
}

int main(){
  char str[5], str2[5];

  while(scanf("%c %c %c %c", &str[0], &str[1], &str[2], &str[3]) != EOF){ 

    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<stdio.h>

int main()
{
int p[4]={};
int q[4]={};
int x,H,B;
H=0;B=0;
/*
for(int i=0;i<4;i++)
{scanf("%d",&x);p[i]=x;}
for(int i=0;i<4;i++)
{scanf("%d",&x);q[i]=x;}*/
while(scanf("%d %d %d %d %d %d %d %d",&p[0],&p[1],&p[2],&p[3],&q[0],&q[1],&q[2],&q[3])!=EOF)
{

for(int i=0;i<4;i++)
for(int j=0;j<4;j++)
{if(p[i]==q[j]){
	if(i==j)H++;
    else if(i!=j)B++;
}}
printf("%d %d\n",H,B);
H=0;B=0;
}

return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
	
	int A[4] = {};
	int B[4] = {};
	
	int yes = 0;
	int no = 0;
	
	while( cin >> A[0]) {
	for(int i=1;i<4;i++)
	cin >> A[i];
	
	for(int i=0;i<4;i++)
	cin >> B[i];
	
	for(int i=0;i<4;i++)
	for(int j=0;j<4;j++)
	if( A[i] == B[j] ) {
		
		if( i == j) 
		yes++;
		
		else
		no++;
	}
	cout << yes << " " << no << "\n"; 
}
    return 0;
}

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

using namespace std;

int main (void) {
    while (1) {
        vector<int> a(4), b(4);
        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 hi = 0, bl = 0;
        for (int i = 0; i < 4; i++) {
            if (a[i] == b[i]) {
                hi++;
            } else {
                for (int j = 0; j < 4; j++) {
                    if (b[i] == a[j]) {
                        bl++;
                        break;
                    }
                }
            }
        }
        cout << hi << ' ' << bl << endl;
    }
    return 0;
}

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

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

int main(){
  int hi,bu,a[4],b[4];
    while(cin>>a[0]>>a[1]>>a[2]>>a[3]>>b[0]>>b[1]>>b[2]>>b[3]){
      hi=0;
      bu=0;
      for(int i=0;i<=3;i++){
	for(int j=0;j<=3;j++){
	  if(a[i]==b[j]){
	    if(i==j)hi++;
	    else bu++;
	  }
	}
      }
      cout<<hi<<" "<<bu<<endl;
    }
  return 0;
}