Go: package main

import "fmt"

func main() {
	var a1, a2, a3, a4, b1, b2, b3, b4 int
	for {
		i, _ := fmt.Scan(&a1, &a2, &a3, &a4)
		if i == 0 {
			break
		}
		fmt.Scan(&b1, &b2, &b3, &b4)
		a := [4]int{a1, a2, a3, a4}
		b := [4]int{b1, b2, b3, b4}
		var hit, blow int

		for j := 0; j < 4; j++ {
			for k := 0; k < 4; k++ {
				if a[j] == b[k] {
					if j == k {
						hit++
					} else {
						blow++
					}
				}
			}
		}
		fmt.Println(hit, blow)
	}
}

C++: #include<iostream>
using namespace std;
main(){
	int a[4],b[4];
	while(cin>>a[0]){
		int hit=0,blow=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){
			if(a[i]==b[i])++hit;
			for(int j=0;j<4;++j){
				if(a[i]==b[j] && i!=j)++blow;
			}
		}
		cout<<hit<<" "<<blow<<endl;
	}
}

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, blow = 0;
            
        for(int i = 0; i < 4; ++i){
            int b;
            std::cin >> b;
                
            auto it = std::find(a.begin(), a.end(), b);
            if(it == a.begin() + i){
                ++hit;
            }else if(it != a.end()){
                ++blow;
            }
        }
        std::cout << hit << " " << blow << std::endl;
    }
       
    return 0;
}

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

int main(void){
    int a[4];
    int 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=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+=1;
                    }
                    else{
                        blow+=1;
                    }
                }
            }
        }
        cout<<hit<<" "<<blow<<endl;
    }
    return 0;
}

C++: 
#include <iostream>
using namespace std;
int main(){
    int a[4],b[4],hcount=0,bcount=0;
    while(cin>>a[0]>>a[1]>>a[2]>>a[3]>>b[0]>>b[1]>>b[2]>>b[3]){
    hcount=0;
    bcount=0;
    for(int k=0;k<4;k++){
        for(int s=0;s<4;s++){
            if(a[k]==b[s]&&k==s)hcount++;
            else if(a[k]==b[s]&&k!=s)bcount++;
        }
    }
    cout<<hcount<<" "<<bcount<<endl;
    }
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <map>

using namespace std;

typedef long long ll;

double xx(double r) {
	return r*r;
}

ll gcd(ll a, ll b) {
	if (a == 0) return b;
	return gcd(b%a, a);
}

int main() {
	int a[4], b[4];
	while ( scanf("%d%d%d%d", &a[0], &a[1], &a[2], &a[3]) != EOF ) {
		for (int i = 0; i < 4; ++i) scanf("%d", &b[i]);

		map<int, bool> m;
		for (int i = 0; i < 4; ++i) m[a[i]] = true;

		int hit = 0, blow = 0;
		for (int i = 0; i < 4; ++i) {
			if (a[i] == b[i]) ++hit;
			else if (m[b[i]]) ++blow;
		}
		cout << hit << " " << blow << endl;
	}
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>

#define f first
#define s second
#define mp make_pair

#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()
#define EPS (1e-10)
using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

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

C++: #include<iostream>
using namespace std;
int main(){
    int a[4][50],b[4][50],hit,blow,n;
    for(int i = 0;i < 50;i++){
        cin >> a[0][i] >> a[1][i] >> a[2][i] >> a[3][i] 
            >> b[0][i] >> b[1][i] >> b[2][i] >> b[3][i] ;
        int t = 0;
        for(int j = 0;j < 4;j++){
            if(a[j][i] != 0){
                t = 1;
                j = 4;
            }
            if(b[j][i] != 0){
                t = 1;
                j = 4;
            }
        }
        if (t = 0){
            n = i + 1;
            i = 50;
        }
    } 
    for(int i = 0;i < 50;i++){
        hit = blow = 0;
        
        for(int j = 0;j < 4;j++){
            for(int k = 0;k < 4;k++){
                if(a[j][i] == b[k][i]){
                    if(j == k){
                        hit++;
                    }
                    else{
                        blow++;
                    }
                }
            }
        }
        cout << hit << " " << blow << endl;
    }
}

C++: #include <iostream>

using namespace std;

int main(){

	int A[5];
	int B[5];
	int k = 1;

	while(1){

		int hit = 0 , blow = 0;

		for(int i = 0; i < 4; i++){
			cin >> A[i];
		}

		for(int i = 0; i < 4; i++){
			cin >> B[i];
		}

		if(A[0] == 0 && A[1] == 0 && A[2] == 0 && A[3] == 0 &&
			B[0] == 0 && B[1] == 0 && B[2] == 0 && B[3] == 0) break;

		for(int i = 0; i < 4; i++){
			if(A[i] == B[i]){
					hit++;
				}
			for(int j = 0; j < 4; j++){

				if(A[i] ==  B[j] && A[i] != B[i]){
					blow++;
				}
			}
		}

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

	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <list>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cfloat>
#include <climits>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <numeric>
#include <functional>
#include <utility>
#include <iomanip>
#include <iterator>
#include <stack>
#include <limits>
#include <sstream>
#include <fstream>
#include <ostream>
#include <bitset>
#include <queue>
#include <ctime>
#include <utility>

#define ms(a,n) (memset(a,n,sizeof(a)))
#define msv(a,v,n) for(int _a;_a<=n;_a++) a[_a]=v;
#define all(res) res.begin(),res.end()
#define mp(a,b) (make_pair(a,b))
#define pb(n) push_back(n)
#define mod 1000000007

using namespace std;

template<class T1> void deb(T1 e){cout<<e<<'\n';}
template<class T1,class T2> void deb(T1 e1,T2 e2){cout<<e1<<" "<<e2<<'\n';}
template<class T1,class T2,class T3> void deb(T1 e1,T2 e2,T3 e3){cout<<e1<<" "<<e2<<" "<<e3<<'\n';}
template<class T1,class T2,class T3,class T4> void deb(T1 e1,T2 e2,T3 e3,T4 e4){cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<'\n';}
template<class T> inline T gcd(T a,T b) {if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<class T> inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}

typedef long long ll;
typedef pair< int, int> PII;
typedef vector< int> VI;
typedef vector< vector<int> > VVI;
typedef map< string, int> MSI;

ostream_iterator<int> screen(cout," ");
//copy(all(res),screen);

const int  sz=2*1000*100+10;
const int inf=INT_MAX>>1;
const ll big=(1LL<<62);
const double pi =acos(-1.0);
int dx[]={0,0,1,-1,1,1,-1,-1},dy[]={1,-1,0,0,1,-1,1,-1};
VI res;

ll powermod(ll n,ll p)
{
    ll x=1,y=n%mod;
    while(p)
    {
        if(p&1LL)
            x=(y*x)%mod;
        y=(y*y)%mod;
        p=p>>1LL;
    }
    return x;
}

int main()
{
    //std::ios_base::sync_with_stdio(false);
    int arr[5],brr[5];
    while(cin>>arr[0])
    {
        int a1=0,a2=0;
        for(int i=1;i<4;i++)
            cin>>arr[i];
        for(int i=0;i<4;i++)
            cin>>brr[i];
        for(int i=0;i<4;i++)
            if(arr[i]==brr[i])
                a1++;
        for(int i=0;i<4;i++)
            for(int j=0;j<4;j++)
                if(i!=j&&arr[i]==brr[j])
                    a2++;
        cout<<a1<<' '<<a2<<endl;
    }

    return 0;
}