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;

int main()
{

	int a[4],b[4];
	int hit = 0,blow = 0;
	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){
		for(int j=i;j<4;++j){
			if(a[i] == b[j])
				++blow;
		}
	}

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

	blow -= hit;	
	cout << hit << " " << blow << endl;

	return 0;
}

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

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

	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] == b[j])
				{
					if (i == j) hit++;
					else blow++;
				}
			}
		}
		cout << hit << " " << blow << endl;
	}
	return 0;
}

C++: #include <stdio.h>
#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 ht = 0, bl = 0;
		for (int i = 0; i < 4; i++) {
			if (a[i] == b[i])
				ht++;
		}
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				if (i != j && a[i] == b[j])
					bl++;
			}
		}
		printf("%d %d\n", ht, bl);
	}
	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++;
      else blow+=appear[b[i]];
    }

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

  return 0;
}

C++: #include<iostream>

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

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

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

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

return 0;
}

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

int main() {
	array<int, 4> a;
	array<int, 4> b;
	int hit = 0,brow = 0;

	while (cin >> a.at(0)) {
		int hit = 0, brow = 0;

		for (int i = 1; i < 4; i++) {
			cin >> a.at(i);
		}
		for (int j = 0; j < 4; j++) {
			cin >> b.at(j);
		}

		for (int k = 0; k < 4; k++) {
			for (int l = 0; l < 4; l++) {
				if (a.at(k) == b.at(l)) {
					if (k == l) {
						hit++;
					}
					else {
						brow++;
					}
				}
			}
		}

		cout << hit << " " << brow << endl;
	}

	return 0;
}

C++: 
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <algorithm>
#include <cassert>

using namespace std;


bool solve(){
	int a[4], b[4];
	while(cin>>a[0]){
		cin>> a[1]>> a[2]>> a[3]>> b[0]>> b[1]>> b[2]>> b[3];
		int ans1 = 0;
		int ans2 = 0;
		for(int i=0;i<4;i++){
			if(a[i] == b[i]) ans1++;
			for(int j=0;j<4;j++){
				if(a[i] == b[j]) ans2++;
			}
		}
		ans2 -= ans1;
		cout<< ans1<< " "<< ans2<< endl;
	}
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	solve();

	return 0;
}

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

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

int main()
{
    int ans_a[100],ans_b[100];
    int hit=0,brow=0;
    
    while (cin>>ans_a[0]>>ans_a[1]>>ans_a[2]>>ans_a[3]>>ans_b[0]>>ans_b[1]>>ans_b[2]>>ans_b[3]) {
        for (int i=0; i<4; i++) {
            for (int j=0; j<4; j++) {
                if (ans_a[i]==ans_b[j]&&i==j) {
                    hit++;
                }
                else if(ans_a[i]==ans_b[j]) {
                    brow++;
                }
            }
        }
        printf("%d %d\n",hit,brow);
    }
    
    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],!cin.eof()){
        int hit=0,blow=0;
        for(int i=0;i<4;i++){
            for(int j=0;j<4;j++){
                if(b[i]==a[j] && i==j){
                    hit++;
                    break;
                }
                if(b[i]==a[j] && i!=j){
                    blow++;
                    break;
                }
            }
        }
        cout<<hit<<' '<<blow<<endl;
    }

    return 0;
}

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

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

	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<10 ; i++){
			n1[i] = 0;
			n2[i] = 0;
		}

		for(int i=0 ; i<4 ; i++){
			if(a[i]==b[i]) hit++;
			n1[ a[i] ] = 1;
			n2[ b[i] ] = 1;
		}
		for(int i=0 ; i<10 ; i++){
			if( n1[i]==n2[i] && n1[i]==1) blow++;
		}
		cout << hit << " " << blow-hit << endl;
	}
}

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

bool judgeZeroToNine(int n);
bool judgeCorr(int n[]);

int main(){
	int a[4], b[4];
	do{
		cin >> a[0] >> a[1] >> a[2] >> a[3];
		while((!(judgeZeroToNine(a[0])&&judgeZeroToNine(a[1])&&
				judgeZeroToNine(a[2])&&judgeZeroToNine(a[3])))||
				judgeCorr(a)){
			cout << "wrong value\n";
			cin >> a[0] >> a[1] >> a[2] >> a[3];
		}
		cin >> b[0] >> b[1] >> b[2] >> b[3];
		while((!(judgeZeroToNine(b[0])&&judgeZeroToNine(b[1])&&
				judgeZeroToNine(b[2])&&judgeZeroToNine(b[3])))||
				judgeCorr(b)){
			cout << "wrong value\n";
			cin >> 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])
					blow++;
			}
			if(a[i] == b[i]){
				blow--;
				hit++;
			}
		}
		cout << hit << " " << blow << "\n";
	}while(true);
    return 0;
}

bool judgeZeroToNine(int n){
	if((n >= 0)&&(n <= 9))
		return true;
	else
		return false;
}

bool judgeCorr(int n[4]){
	for(int i = 0;i < 3;i++){
		for(int j = i + 1;j < 4;j++){
			if(n[i] == n[j])
				return true;
		}
	return false;
	}
}

C++: // 2011/06/23 Tazoe

#include <iostream>
using namespace std;

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

		int hit = 0;
		int blw = 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
						blw++;

		cout << hit << ' ' << blw << endl;
	}

	return 0;
}

C++: #include <iostream>
using namespace std;
int main() {
  char a[4], b[4];
  int hi, bl, i, j;
  while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) {
    for (i = hi = bl = 0; i < 4; i++) {
      for (j = 0; j < 4; j++) {
        if (b[i] == a[j]) {
          a[i] = -1;
          if (i == j) 
            hi++;
          else
            bl++;
        }
      }
    }
    cout << hi << ' ' << bl << endl;
  }
  return 0;
}