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 <cstdio>

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 <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 t[4],u[4],v[4];
bool input(){
  //if(!cin>>t[0])return 0;
  for(int i=1;i<4;i++)cin>>t[i];
  for(int i=0;i<4;i++)cin>>u[i];
  return 1;
}
int main(){
  int h,b;
  while(cin>>t[0]){
    input();
    h=b=0;
    for(int i=0;i<4;i++){
      if(t[i]==u[i])h++;
      else{
	for(int j=0;j<4;j++){
	  if(t[i]==u[j])b++;
	}
      }
    }
    cout<<h<<' '<<b<<endl;
  }
  return 0;
}

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

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
	std::vector<int> a(4);
	std::vector<int> b(4);

#if INPUT_FROM_FILE
	//std::ifstream ifs("test.txt");
	FILE *fp = fopen("test.txt", "r");
#endif

#if INPUT_FROM_FILE
	while(fscanf(fp, "%d %d %d %d", &a[0], &a[1], &a[2], &a[3]) != EOF){
#else
	while(scanf("%d %d %d %d", &a[0], &a[1], &a[2], &a[3]) != EOF){
#endif
		int hit = 0;
		int blow = 0;
		std::vector<int> aa;
		std::vector<int> bb;
#if INPUT_FROM_FILE
		fscanf(fp, "%d %d %d %d", &b[0], &b[1], &b[2], &b[3]);
#else
		scanf("%d %d %d %d", &b[0], &b[1], &b[2], &b[3]);
#endif
		for(int i = 0; i < 4; i++){
			if(a[i] == b[i]){
				hit++;
			}
			else{
				aa.push_back(a[i]);
				bb.push_back(b[i]);
			}
		}

		for(unsigned int i = 0; i < aa.size(); i++){
			for(unsigned int j = 0; j < bb.size(); j++){
				if(aa[i] == bb[j]){
					blow++;
				}
			}
		}
		std::cout << hit << " " << blow << std::endl;
	}
	
	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
using namespace std;

int main(){
	int a[4],b[4];
	while(cin>>a[0]){
		int hit=0,blow=0;
		rep(i,1,4) cin>>a[i];
		rep(i,0,4) cin>>b[i];
		rep(i,0,4){
			rep(j,0,4){
				if(a[i]==b[j]){
					if(i==j) hit++;
					else blow++;
				}
			}
		}
		cout<<hit<<" "<<blow<<endl;
	}
}

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



int main()
{
    int hit[4]={},blow[4]={};
    while(1){
        int ans1=0,ans2=0;
        for(int i=0; i<4; i++){
            cin>>hit[i];
        }
        for(int i=0; i<4; i++){
            cin>>blow[i];
        }
        for(int i=0; i<4; i++){
            for(int j=0; j<4; j++){
                if(hit[i]==blow[j]){
                    (i==j)?ans1++:ans2++;
                }
            }
        }
        cout<<ans1<<" "<<ans2<<endl;
    }
    return 0;
}

C++: /***** ?????¬???????????¬?????? *****/

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

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int const MOD = 1000000007;

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]) {
        set<int>s1, s2;
        rep(i,0,4) s1.insert(a[i]);
        rep(i,0,4) s2.insert(b[i]);

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

        printf("%d %d\n",hit,blow);
    }
    return 0;
}

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

int main(){
  int a[4],c[4];
  while(cin>>a[0]){
    int e=0,b=0;
    for(int i=1;i<4;i++)
      cin>>a[i];
    for(int i=0;i<4;i++){
      cin >> c[i];
      for(int j=0;j<4;j++)
	if(c[i]==a[j]){
	  if(i==j)e++;
	  else b++;
	}
    }
    cout<<e<<' '<<b<<endl;
  }
  return 0;
}