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<stdio.h>
int main(void)
{
	int a[5],s[5],d,f,g,i,j;
	while(scanf("%d %d %d %d %d %d %d %d",&a[1],&a[2],&a[3],&a[4],&s[1],&s[2],&s[3],&s[4])!=EOF){
	d=0;
	f=0;
	for(i=1;i<=4;i++){
		if(a[i]==s[i]){
			d++;
		}
		if(a[i]!=s[i]){
			j=0;
			while(j<=5){
				if(a[i]==s[j]){
					f++;
				}
				j++;
			}
		}
	}
	printf("%d %d\n",d,f);
	}
	return 0;
}

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

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

C++: #include <iostream>

int main() {
	const int size = 4;
	int a[size], b[size];

	while (std::cin
		>> a[0] >> a[1] >> a[2] >> a[3]
		>> b[0] >> b[1] >> b[2]	>> b[3]
	) {
		int hit = 0, blow = 0;
		for (int i = 0; i < size; i++)
			if (a[i] == b[i]) {
				hit++;
			} else {
				for (int j = 1; j < size; j++)
					if (a[i] == b[j])
						blow++;
			}

		std::cout << hit << " " << blow << std::endl;
	}
}

C++: #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int a1, a2, a3, a4, b1, b2, b3, b4;
	while (cin >> a1 >> a2 >> a3 >> a4 >> b1 >> b2 >> b3 >> b4) {
		VI a = { a1,a2,a3,a4 };
		VI b = { b1,b2,b3,b4 };

		int c1 = 0, c2 = 0;
		rep(i, 4) {
			if (a[i] == b[i])c1++;
		}

		VI ca(10), cb(10);
		rep(i, 4)ca[a[i]]++;
		rep(i, 4)cb[b[i]]++;
		rep(i, 10) {
			c2 += min(ca[i], cb[i]);
		}

		cout << c1 << " " << c2 - c1 << endl;
	}
}

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

int main(){
  int a[4],b[4];
  while(1){
  rep(i,4)cin >> a[i];
  rep(i,4)cin >> b[i];

  int blow=0,hit=0;

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

}

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

int main()
{
  vector<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 = 0, blow = 0;

    for (int i = 0; i < a.size(); ++i) {
      for (int j = 0; j < b.size(); ++j) {
	if (a[i] == b[j]) {
	  if (i == j)
	    ++hit;
	  else
	    ++blow;
	}
      }
    }

    cout << hit << " " << blow << endl;

  }
  return 0;
}

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

#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i,n) REP(i,0,n)

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

C++: #include <iostream>
#include <vector>
#include <array>
 
int get_hit(std::vector<u_int> *A, std::vector<u_int> *B)
{
    u_int hit = 0;
    for(u_int i = 0; i < A -> size(); ++i)
        if(A -> at(i) == B -> at(i))
            ++hit;
             
    return hit;
}
 
int get_blow(std::vector<u_int> *A, std::vector<u_int> *B)
{
    u_int blow = 0;
    for(u_int i = 0; i < A -> size(); ++i){
        for(u_int j = 0; j < B -> size(); ++j){
            if(A -> at(i) == B -> at(j)){
                if(i != j)
                    ++blow;
                break;
            }
        }
    }
             
    return blow;
}
 
int main()
{
    const u_int number = 4;
    std::vector<u_int> A;
    std::vector<u_int> B;
    A.reserve(number);
    B.reserve(number);
     
    std::array<u_int, number> array;
    bool flag = true;
    while(std::cin >> array[0] >> array[1] >> array[2] >> array[3]){
        if(flag){
            A.clear();
            B.clear();
            for(u_int i = 0; i < number; ++i)
                A.push_back(array.at(i));
            flag = !flag;
        }else{
            for(u_int i = 0; i < number; ++i)
                B.push_back(array.at(i));
            std::cout << get_hit(&A, &B) << " " << get_blow(&A, &B) << std::endl;
            flag = !flag;
        }
    }
         
    return 0;
}

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

int main(){

	int a1, a2, a3, a4, b1, b2, b3, b4;

	while(std::cin >> a1 >> a2 >> a3 >> a4){
		
		std::cin >> b1 >> b2 >> b3 >> b4;
		
		std::array<int, 4> A = {a1, a2, a3, a4};
		std::array<int, 4> B = {b1, b2, b3, b4};
		
		int hit = 0;
		int blow = 0;

		for(int i = 0; i < 4; ++i){
			
			if(A[i] == B[i])
				++hit;
				
			blow += std::count(A.begin(), A.end(), B[i]);

		}

		std::cout << hit << " " << blow << std::endl;
	}

		return 0;

}

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

bool isin(int n, int x[]){
	for (int i=0; i<4; i++)
		if (n==x[i]) return true;
	return false;
}

int main(void){
	
	while (true){
		int a[4],b[4];
		for (int i=0; i<4; i++)
			cin>>a[i];
		if (cin.eof()) break;
		for (int i=0; i<4; i++)
			cin>>b[i];

		int c1=0, c2=0;
		for (int i=0; i<4; i++)
			if (isin(a[i], b))
				if (a[i]==b[i]) c1++;
				else c2++;
		cout<<c1<<" "<<c2<<endl;
	}
	return 0;
}

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

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

int a[4],b[4];
int main(){
  int i,j,m,n,x;
  for(;~scanf("%d%d%d%d%d%d%d%d",a,a+1,a+2,a+3,b,b+1,b+2,b+3);printf("%d %d\n",x,m-x)){
    for(m=x=i=j=0;i<4;i++)if(a[i]==b[i])x++;
    for(;j++<24;next_permutation(b,b+5),m=n>m?n:m)for(n=i=0;i<4;i++)if(a[i]==b[i])n++;
  }
}

C++: #include <iostream>
#define N 4
using namespace std;
int main()
{
	int a[N][N];
	while(1)
	{
		for (int j=0;j<N;j++)
			for (int k=0;k<N;k++)
				cin>>a[j][k];
		for (int i=0;i<N;i++)
		{
			if (a[0][i]==a[1][i])
				cout<<a[1][i]<<" "<<"1"<<endl;
			if (a[2][i]!=a[3][i])
				cout<<a[3][i]<<" "<<"0"<<endl;
		}
	}
}