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 <cstdio>

using namespace std;

int main()
{
	int a[4],b[4];
	while(scanf("%d",&a[0])!=EOF){
		scanf("%d %d %d",&a[1],&a[2],&a[3]);
		scanf("%d %d %d %d",&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]){
					if(i==j)hit++;
					else blow++;
				}
			}
		}
		printf("%d %d\n",hit,blow);
	}
	return 0;
}

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

int main()
{
	int i,j;
	int a[4];
	int b[4];
	while(1){

		int hit =  0;
		int blow = 0;
		if(cin.eof())return 0;
		for(i=0;i<4;++i)cin>>a[i];
		for(i=0;i<4;++i)cin>>b[i];

		for(i=0;i<4;++i){
			for(j=0;j<4;++j){
				if(b[i] == a[j]){
					(j == i) ? ++hit : ++blow;
				}
			}
		}
		cout << hit << ' ' << blow << endl;
	}
}

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

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

int main(){
	int a[4], b[4];
	while(cin >> a[0] >> a[1] >> a[2] >> a[3]){
		while(!(judgeZeroToNine(a[0])&&judgeZeroToNine(a[1])&&
				judgeZeroToNine(a[2])&&judgeZeroToNine(a[3]))){
			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]))){
			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";
	}
    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++: #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] ;
        cin >> 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 <iostream>

using namespace std;

int main() {
	int a[4], b[4];
	while (1) {
		for (int i=0; i<4; ++i) cin >> a[i];
		for (int i=0; i<4; ++i) cin >> b[i];

		if (cin.eof()) break;

		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;
	}
}

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

int main(){
	std::vector<int> a(4);
	std::vector<int> b(4);
	int hit_num;
	int blow_num;
	
	while(std::cin >> a[0] >> a[1] >> a[2] >> a[3]){
		std::cin >> b[0] >> b[1] >> b[2] >> b[3];
		hit_num = 0;
		blow_num = 0;
		for(int i = 0; i < 4; ++i){
			if(a[i] == b[i]) ++hit_num;
			for(int j = 0; j < 4; ++j){
				if(i != j && a[i] == b[j]) ++blow_num;
			}
		}
		std::cout << hit_num << " " << blow_num << std::endl;
	}
}

C++: #include<vector>
#include<iostream>
using namespace std;
int main() {
	int code[4], line, hit, bro;
	while (true) {
		hit = 0;
		bro = 0;
		for (int i = 0; i < 4; ++i) {
			cin >> code[i];
		}
		for (int i = 0; i < 4; ++i) {
			cin >> line;
			if (code[i] == line) {
				++hit;
			}
			else {
				for (int i2 = 0; i2 < 4; ++i2) {
					if (code[i2] == line) {
						++bro;
					}
				}
			}
		}
		cout << hit << " " << bro << endl;
	}
	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> A_num = {a1, a2, a3, a4};
		std::array<int> B_num = {b1, b2, b3, b4};
		
		int hit = 0;
		int blow = 0;

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

		}

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

		return 0;

}

C++: #include <stdio.h>
#include <iostream>

using namespace std;

int main() {
	int a[4];
	int b[4];

	int B,H;

	while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) {
		B = 0;
		H = 0;

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

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

		cout << H << " " << B << endl;
	}

	return 0;
}

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

int main(){

	std::array<int, 4> A;
	while(std::cin >> A[0] >> A[1] >> A[2] >> A[3]){
		std::array<int, 4> B;
		std::cin >> B[0] >> B[1] >> B[2] >> B[3];
		
		int hit = 0;
		int blow = 0;
		for(int i=0; i<4; ++i){
			if( A[i] == B[i] )
				++hit;
			for(int j=i+1; j<4; ++j)
				if( A[i] == B[j] )
					++blow;
		}
		std::cout << hit << " " << blow << std::endl;
	}
	return 0;
}

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

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

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

int main() {
    int a1, a2, a3, a4, b1, b2, b3, b4;
    set<int> setA, setB;
    while (cin >> a1 >> a2 >> a3 >> a4 >> b1 >> b2 >> b3 >> b4) {
        int hit = 0, blow = 0;
        if (a1 == b1) {
            hit++;
        }
        else {
            setA.insert(a1);
            setB.insert(b1);
        }
        if (a2 == b2) {
            hit++;
        }
        else {
            setA.insert(a2);
            setB.insert(b2);
        }
        if (a3 == b3) {
            hit++;
        }
        else {
            setA.insert(a3);
            setB.insert(b3);
        }
        if (a4 == b4) {
            hit++;
        }
        else {
            setA.insert(a4);
            setB.insert(b4);
        }

        for (int i = 1; i <= 9; ++i) {
            if (setA.count(i) && setB.count(i)) {
                ++blow;
            }
        }

        cout << hit << " " << blow << endl;
        setA.clear();
        setB.clear();
    }
}

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

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

    while (std::cin >> a[0] >> a[1] >> a[2] >> a[3]
                    >> b[0] >> b[1] >> b[2] >> b[3])
    {
        int hit = 0;
        for (u_int i = 0; i < 4; ++i) {
            if (a[i] == b[i]) ++hit;
        }

        int blow = -hit;  // ヒットを除く
        std::sort(a.begin(), a.end());
        for (auto& v : b) {
            if ( std::binary_search(a.begin(), a.end(), v) ) ++blow;
        }

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

    return 0;
}