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>
#include <set>
using namespace std;
int main() {
	string a, b;
	set<int> aa, bb;
	while (getline(cin, a) && getline(cin, b)) {
		int hit = 0;
		int blow = 0;
		for (int i = 0; i != a.size(); i += 2) {
			if (a[i] == b[i]) {
				++hit;
			}
			else {
				aa.insert(a[i]-'0');
				bb.insert(b[i]-'0');
			}
		}
		for (int i = 1; i <= 9; ++i) {
			if (aa.count(i) && bb.count(i)) {
				++blow;
			}
		}
		cout << hit << " " << blow << endl;
		aa.clear();
		bb.clear();
	}
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int main(){
  int a[4],b[4];
  while(~scanf("%d%d%d%d%d%d%d%d",a,a+1,a+2,a+3,b,b+1,b+2,b+3)){
    int hit = 0;
    REP(i,4)if(a[i]==b[i])++hit;
    sort(a,a+4);
    sort(b,b+4);
    int blow = -hit;
    REP(i,4)if(a[i]==b[i])++blow;
    printf("%d %d\n",hit,blow);
  }
  return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
int main(){
int a[4];
int b[4];
int c;
int d;
int e;
int f;
while(cin >>a[0]>>a[1]>>a[2]>>a[3]>>b[0]>>b[1]>>b[2]>>b[3]){
e=0;
f=0;
c=0;
while(c<4){
d=0;
while(d<4){
if(a[c]==b[d]){if(c==d){e=e+1;} else{f=f+1;}}
d=d+1;}
c=c+1;}
cout <<e<<" "<<f<<endl;
}}

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

C++: import Control.Monad
import Control.Applicative
import Data.List

main = do
  xs <- input $ map read . words :: IO [[Int]]
  mapM_ putStrLn $ solve xs
  
solve :: [[Int]] -> [String]
solve [] = []
solve (xs:ys:yss) = (show h ++ " " ++ show b) : solve yss
  where h = hit xs ys
        b = smn xs ys - h

hit :: [Int] -> [Int] -> Int
hit xs ys = sum $ zipWith (\x y -> if x == y then 1 else 0) xs ys

smn :: [Int] -> [Int] -> Int
smn xs ys = foldl f 0 ys
  where
    f :: Int -> Int -> Int
    f acc z = if z `elem` xs then acc + 1 else acc

input :: (String -> a) -> IO [a]
input f = map f . lines <$> getContents

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

int main(){
    int array[4][2] = {0};
    int hit = 0;
    int blow = 0;
    while (cin>>array[0][0]>>array[1][0]>>array[2][0]>>array[3][0]){
        cin >> array[0][1]>>array[1][1]>>array[2][1]>>array[3][1];
        hit = 0;
        blow = 0;
        for (int i = 0; i < 4; i++){
            if (array[i][0] == array[i][1]) {
                hit++;
            }
        }
        for (int i = 0; i < 4; i++) {
            for (int j = i; j < 4; j++) {
                if (array[i][0] == array[j][1]) {
                    if (array[i][0] != array[i][1]) {
                        blow++;
                    }
                }
            }
        }
        printf("%d %d\n",hit,blow);
    }
    return 0;
}

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

int main(){
	std::array<u_int, 4> a,b;
	int hit,blow;

	while(std::cin >> a[0] >> a[1] >> a[2] >> a[3]){
		std::cin >> b[0] >> b[1] >> b[2] >> b[3];
		hit=0;
		blow=0;
		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]) blow++;
			}
		}
		std::cout << hit << " " << blow-hit << std::endl;
	}

    return 0;
}

C++: #include <iostream>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;

int main(){
    int a[4], b[4];
    while(1){
        if(cin.eof()) break;
        rep(i, 0, 4) cin >> a[i];
        rep(i, 0, 4) cin >> b[i];
        bool f[4];
        rep(i, 0, 4) f[i] = false;
        int hit = 0, blow = 0;
        rep(i, 0, 4){
            if(a[i] == b[i]){
                hit++; f[i] = true;
            }
        }
        rep(i, 0, 4){
            if(f[i]) continue;
            rep(j, 0, 4){
                if(a[i] == b[j]) blow++;
            }
        }
        cout << hit << " " << blow << endl;
    }
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<functional>
#include<queue>
#include<stack>
#include<math.h>
#define INF 1000000000
#define EPS 1.0e-10

using namespace std;

typedef long long ll;

int a[5];
int b[5];

int main()
{
	while (cin >> a[0] >> a[1] >> a[2] >> a[3]) {
		for (int i = 0; i < 4; i++) {
			cin >> b[i];
		}
		int hit = 0;
		int 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++;
				}
			}
		}
		cout << hit << " " << blow << endl;
	}
	return 0;
}

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>
#include <array>
#include <vector>

int main()
{
	std::vector<int> list_a{};
	std::vector<int> list_b{};
	std::array<bool, 10> a;
	
	int a1, a2, a3, a4;
	int b1, b2, b3, b4;
	int hit = 0, brow = 0;
	while (std::cin >> a1 >> a2 >> a3 >> a4 >> b1 >> b2 >> b3 >> b4)
	{
		hit = 0;
		brow = 0;
		for (auto& val : a)
		{
			val = false;
		}
		list_a.clear();
		list_b.clear();

		a[a1 - 1] = true;
		a[a2 - 1] = true;
		a[a3 - 1] = true;
		a[a4 - 1] = true;

		list_a.push_back(a1);
		list_a.push_back(a2);
		list_a.push_back(a3);
		list_a.push_back(a4);

		list_b.push_back(b1);
		list_b.push_back(b2);
		list_b.push_back(b3);
		list_b.push_back(b4);

		for (int i = 0; i < list_a.size(); ++i )
		{
			if (list_a[i] == list_b[i])
			{
				hit++;
			}
			else
			{
				if ( a[ list_b[i] - 1 ] )
				{
					brow++;
				}
			}
		}
		std::cout << hit << " " << brow << std::endl;
	}

	return 0;
}

C++: import java.io.IOException;
import java.util.Scanner;

class Main {

	public static void main(String[] args) throws IOException {

		Scanner sc = null;

		try {

			sc = new Scanner(System.in);
			int countHit=0;
			int countBlow=0;

			while (sc.hasNext()) {
				

				String[] a = sc.nextLine().split(" ");
				String[] b = sc.nextLine().split(" ");

				for (int i = 0; i < a.length; i++) {
					for(int j =0; j<b.length;j++){

						if (a[i] .equals(b[i])) {
							countHit++;
							break;
						}
						else if(a[i].equals(b[j])){

							countBlow++;
						}
					}
				}

				System.out.println(countHit+" "+countBlow);

			}

		} finally {
			sc.close();
		}

	}

}