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++: ////   template  ///////////////////////////////////////////////////////
#include <stdlib.h>
#include <sys/time.h>
#include <stdio.h>
#include <sys/resource.h>
#include <iostream>
#include <vector>
#include <bitset>
using namespace std;

class timer{
	enum KIND{ REAL, CPU }; // real_time or cpu_time
	double t0; // start
	double t1; // end
	KIND kind_of_time; // default is real_time
	double get_realtime(){struct timeval tv; gettimeofday(&tv, NULL);
		return tv.tv_sec + (double)tv.tv_usec*1e-6;}
	double get_cputime(){struct rusage RU; getrusage(RUSAGE_SELF, &RU); 
		return RU.ru_utime.tv_sec + (double)RU.ru_utime.tv_usec*1e-6;}
public:
	timer(){kind_of_time = REAL;}
	void set(KIND k){kind_of_time = k;}
	void start(){t0 = get_realtime();}
	void stop(){t1 = get_realtime();}
	void print(){printf("TotalTime : %.3fsec\n", t1-t0);}
};
////////////////////////////////////////////////////////////////////////

int main()
{
	int a[4], b[4];
	while(cin>>a[0]>>a[1]>>a[2]>>a[3], cin>>b[0]>>b[1]>>b[2]>>b[3]){
		int hit=0, blow=0;
		bitset<10> fa, fb;
		for(int i=0; i<4; i++){
			if(a[i]==b[i]) hit++;
			fa.set(a[i]), fb.set(b[i]);
		}
		for(int i=0; i<10; i++)
			if(fa[i]&fb[i]) blow++;
		blow -= hit;
		cout << hit << " " << blow << endl;
	}

    return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<math.h>
#include<string>
#include<queue>
#include<algorithm>
#include<utility>
#include<vector>
#include<list>
using namespace std;
int main() {
	int a[8], hit = 0, blow = 0, k = 0, f, cnt=0;
	while (cin >> f) {
		a[k] = f;
		k++;
		if (k % 8 == 0) {
			for (int i = 0; i < 4; ++i) {
				if (a[i] == a[i+4]) {
					hit++;
					a[i] = -1;
					a[i+4] = -1;
					continue;
				}
				for (int j = i+1; j < 4; ++j) {
					if (a[i] == a[j+4] )blow++;
				}
			}
			cout << hit << " " << blow << endl;
			k = 0;
			hit = 0;
			blow = 0;
		}
	}
	return 0;
}

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

int main(){
  int t=1,i,j,h,bu,a[4],b[4];

  while(cin>>a[0]>>a[1]>>a[2]>>a[3]){

  for(i=0;i<4;i++){
      cin>>b[i];
    }
  h=0;bu=0;
  for(i=0;i<4;i++){
    for(j=0;j<4;j++){
      if(a[i]==b[j]&&i==j)h+=1;
      else if(a[i]==b[j])bu+=1;   
    }
  }
  cout<<h<<" "<<bu<<endl;
  }
  return 0;
}

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

int main() {
  int a[5],b[5];
  while ( cin >> a[1] >> a[2] >> a[3] >> a[4]
	  >> b[1] >> b[2] >> b[3] >> b[4] ) {
    int h = 0,bb = 0;
    for ( int i = 1; i < 5; i++ ) {
      if ( a[i] == b[i] ) h++;
    }

    for ( int i = 1; i < 5; i++ ) {
      for ( int j = 1; j < 5; j++ ) {
	if ( i != j && a[i] == b[j] ) bb++;
      }
    }
    cout << h << " " << bb << endl;
  }
  return 0;
}

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

using namespace std;

void Solution()
{
//    int a1, a2, a3, a4;
//    int b1, b2, b3, b4;
//    
//    int a[2][4] = {a1, a2, a3, a4, b1, b2, b3, b4};
    
    int a[4];
    int b[4];
    
    while(cin>>a[0]>>a[1]>>a[2]>>a[3])
    {
        int hit = 0;  // should define hit and below inside the loop, otherwise, it can be accumulated
        int blow = 0;
        
        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])
                {
                    if (i == j)
                    {
                        hit++;
                    }
                    
                    if(i != j)
                    {
                        blow++;
                    }
                }
                else
                    continue;
            }
        }
        
        cout<<hit<<" "<<blow<<endl;
    }
}

int main()
{
    Solution();
    return 0;
}

C++: while gets
	a=$<.split.map(&:to_i)
	b=gets.split.map(&:to_i)
	c,d=0,0;
	4.times do |i|
		if a[i]==b[i] then
			c+=1
		else
			4.times do |j|
				if a[i]==b[j] then
					d+=1;break;
				end
			end
		end
	end
	print c," ",d,"\n"
end

C++: #include<iostream>
#include<sstream>
#include<fstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<string>
using namespace std;

int main(){
	int num1[4],num2[4];
	while(cin>>num1[0]>>num1[1]>>num1[2]>>num1[3]>>num2[0]>>num2[1]>>num2[2]>>num2[3]){
		int h=0,b=0;
		for(int x=0;x<4;++x){
			for(int y=0;y<4;++y){
				if(num1[x]==num2[y])++b;
				if(x==y && num1[x]==num2[y])++h;
			}		
		}
		cout<<h<<" "<<b-h<<endl;
	}	
	return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define INF 1000000
using namespace std;
int main(){
    int tmp = 0;
    while(1){
        if(tmp > 50) break;
        vector<int> a(4);
        vector<int> b(4);
        rep(i,4) cin >> a[i];
        rep(i,4) cin >> b[i];
        int hit = 0,blow = 0;
        rep(i,4){
            if(a[i] == b[i]) hit++;
            else {
                rep(j,4) if(a[j] == b[i]) blow++;
            }
        }
        cout << hit << " " << blow << endl;
        tmp++;
    }
    return 0;
}

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

int main()
{
	int a[4], b[4], A[10] = {0}, B[10] = {0}, h = 0, br = 0;
	while(cin >> a[0] >> a[1] >> a[2] >> a[3] && cin >> b[0] >> b[1] >> b[2] >> b[3]){
		for (int i = 0; i < 4; ++i)
		{
			A[a[i]]++;
			B[b[i]]++;
		}
		for (int i = 0; i < 4; ++i)
		{
			if (a[i] == b[i]){
				h++;
				A[a[i]]--;
				B[b[i]]--;
			}
			cout << a[i]  << b[i] << endl;
		}
		for (int i = 0; i < 10; ++i)
		{
			if(A[i] == 1 && B[i] == 1){
				br++;
			}
		}
		cout << h << ' ' << br << endl;
	}
}

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

int main()
{
	int a[4], b[4];
	while(cin >> a[0] >> a[1] >> a[2] >> a[3] && cin >> b[0] >> b[1] >> b[2] >> b[3]){
		int A[10] = {0}, B[10] = {0}, h = 0, br = 0;
		for (int i = 0; i < 4; ++i)
		{
			A[a[i]]++;
			B[b[i]]++;
		}
		for (int i = 0; i < 4; ++i)
		{
			if (a[i] == b[i]){
				h++;
				A[a[i]]--;
				B[b[i]]--;
			}
			//cout << a[i]  << b[i] << endl;
		}
		for (int i = 0; i < 10; ++i)
		{
			if(A[i] == 1 && B[i] == 1){
				br++;
			}
		}
		cout << h << ' ' << br << endl;
	}
}

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

int main() {
  vector<int> a(4), b(4);
  while (cin >> a[0]) {
    for (int i = 1; i < 4; i++) cin >> a[i];
    for (int i = 0; i < 4; i++) cin >> b[i];
    int hit = 0, blow = 0;
    for (int i = 0; i < 4; i++) {
      if (find(b.begin(), b.end(), a[i]) != b.end()) {
        if (a[i] == b[i]) hit++;
        else blow++;
      }
    }
    cout << hit << " " << blow << endl;
  }
}

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

int main(){
	int Hit , Blow ;
	char a[4],b[4];
	while(cin >> a[0] >> a[1] >> a[2] >> a[3] >> 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] == a[j]) Blow++;
			}
		}

		for(int i = 0; i < 4; i++) {
			if(a[i] == b[i]) {
				Blow--;
				Hit++;
			}
		}

		cout << Hit << " " << Blow << "\n";
	}

}