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++)
#define shosu(n) setprecision(n)
#define INF 1000000000;
using namespace std;
int main() {
  int a[4], b[4];
  while (cin >> a[0] >> a[1] >> a[2] >> a[3]) {
    int ansb = 0, ansh = 0;
    rep(i, 4) cin >> b[i];
    rep(i, 4) rep(j, 4) {
      if (a[i] == b[j]) {
        if (i == j)
          ansh++;
        else
          ansb++;
      }
    }
    cout << ansh << ' ' << ansb << endl;
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
  int a[4], b[4];
  int blow, hit;
  
  while(cin >> a[0]){
    cin >> a[1] >> a[2] >> a[3];
    cin >> b[0] >> b[1] >> b[2] >> b[3];
    hit = blow = 0;
    for(int i = 0; i < 4; i++){
      if(a[i] == b[i]){
        hit += 1;
      }
    }
    for(int i = 0; i < 4; i++){
      for(int n = 0; n < 4; n++){
        if(a[i] != b[i] && a[i] == b[n]){
          blow++;
        }
      }
    }
    cout << hit << " " << blow << endl;
  }
  return 0;
}

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


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

int main()
{
    int n,m;
    while(~scanf("%d%d%d%d",&a[0],&a[1],&a[2],&a[3]))
    {
        scanf("%d%d%d%d",&b[0],&b[1],&b[2],&b[3]);
        int i;
        n=m=0;
        for(i=0;i<4;i++)
        {
            for(int j=0;j<4;j++)
            {
                if(a[i] == b[j] && i==j)
                {
                    n++;
                }
                if(a[i] == b[j] && i!=j)
                {
                    m++;
                }
            }
        }
        cout<<n<<" "<<m<<endl;
    }
    return 0;
}

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

int main(){
	int a[4],t;
	
	while(cin >> a[0] && a[0] != -1){
		int blow=0,hit=0;
		for(int i=1;i<4;i++)
			cin >> a[i];
		for(int i=0;i<4;i++){
			cin >> t;
			if(a[i] == t)hit++;
			else for(int i=0;i<4;i++)if(a[i]==t)blow++;
		}
		cout << hit << " " << blow << endl;
	}
}

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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int a[4];
  while(cin >> a[0]) {
    REP(i,3)
      cin >> a[i+1];
    int hit = 0;
    int blow = 0;
    REP(i,4) {
      int b;
      cin >> b;
      if (b == a[i])
        hit++;
      else {
        REP(j,4)
          if (b==a[j])
            blow++;
      }
    }
    printf("%d %d\n", hit, blow);
  }
}

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

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

  while (1) {
    if (scanf("%d %d %d %d", &a[0], &a[1], &a[2], &a[3]) != 4) break;
    if (scanf("%d %d %d %d", &b[0], &b[1], &b[2], &b[3]) != 4) break;

    hit = blow = 0;
    for (int i=0; i<4; i++) {
      if (a[i] == b[i]) hit++;
    }
    for (int i=0; i<4; i++) {
      for (int j=0; j<4; j++) {
        if (a[i] == b[j]) blow++;
      }
    }
    blow -= hit;
    printf("%d %d\n", hit, blow);
  }

  return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>

using namespace std;

int main(){
    int a[4],b[4],hit,blow;
    
    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])!=EOF){
        hit=0;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++;
                }
            }
        }
        printf("%d %d\n",hit,blow);
    }
    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_cnt = 0;
		int blow_cnt = 0;
		
		for (int i=0; i<4; i++) {
			if (a[i] == b[i]) { hit_cnt++; a[i] = b[i] = -1; }
		}
		
		for (int i=0; i<4; i++) {
			if (a[i] == -1) continue;
			for (int j=0; j<4; j++) {
				if (a[i] == b[j]) { blow_cnt++; a[i] = b[j] = -1; }
			}
		}
		
		cout << hit_cnt << " " << blow_cnt << endl;
	}	
		
	return 0;
}

C++: #include <stdio.h>
int main() {int A[4],B[4],C[10],i,j;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])!=EOF) {for (i=0,j=0;i<4;i++) if (A[i]==B[i]) j++;for (i=0;i<10;C[i++]=0);for (i=0;i<4;i++) C[A[i]]++;int k=-j;for (i=0;i<4;i++) if (C[B[i]]>0) k++,C[B[i]]--;printf("%d %d\n",j,k);} return 0;}

C++: #include <iostream>

using namespace std;

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

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

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

	}

        return 0;
}

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

int main(){
	std::vector<int> A(4);
	std::vector<int> B(4);
	int a,b,c,d;
	while(std::cin>>a){
		A[0]=a;
		for(int i=1;i<4;++i)std::cin>>A[i];
		for(int i=0;i<4;++i)std::cin>>B[i];
		int hit=0,blow=0;
		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;
	}
	return 0;
}

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

int main(){
  int a[4];
  int b[4];
  int appear[10];
  int i;
  int hit, blow;

  for(i=0; i<10; i++) appear[i]=0;
  while(cin>>a[0]){
    hit=0; blow=0;
    appear[a[0]]=1;
    for(i=1; i<4; i++){
      cin>>a[i];
      appear[a[i]]=1;
    }
    for(i=0; i<4; i++) cin>>b[i];

    for(i=0; i<4; i++){
      if(a[i]==b[i]) hit++;
      blow+=appear[b[i]];
    }

    for(i=1; i<4; i++) appear[a[i]]=0;
    printf("%d %d\n", hit, blow);
  }

  return 0;
}

C++: #include<iostream>

using namespace std;



int main(){
	int d[4][2];
	while(cin>>d[0][0]>>d[1][0]>>d[2][0]>>d[3][0]>>d[0][1]>>d[1][1]>>d[2][1]>>d[3][1]){
		int h=0,b=0;
		
		for(int i=0;i<4;i++){
			if(d[i][0]==d[i][1])h++;
		}
		for(int i=0;i<4;i++){
			for(int j=0;j<4;j++){
				
				if(d[i][0]==d[j][1] && i!=j)b++;
			}
		}
		cout<<h<<" "<<b<<endl;
	}
}