Go: package main

import (
	"bufio"
	"os"
	"strings"
	"strconv"
	"fmt"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	a := make([]int, 4)
	b := make([]int ,4)
	for scanner.Scan() {
		inputa := strings.Split(scanner.Text(), " ")
		for i := range a {
			a[i], _ = strconv.Atoi(inputa[i])
		}
		scanner.Scan()
		inputb := strings.Split(scanner.Text(), " ")
		for i := range b {
			b[i], _ = strconv.Atoi(inputb[i])
		}
		hit := 0
		blow := 0
		if a[0] == b[0] {
			hit++
		}
		if a[1] == b[1] {
			hit++
		}
		if a[2] == b[2] {
			hit++
		}
		if a[3] == b[3] {
			hit++
		}
		if a[0] == b[1] {
			blow++
		}
		if a[1] == b[2] {
			blow++
		}
		if a[2] == b[3] {
			blow++
		}
		if a[1] == b[0] {
			blow++
		}
		if a[2] == b[1] {
			blow++
		}
		if a[2] == b[0] {
			blow++
		}
		if a[3] == b[2] {
			blow++
		}
		if a[3] == b[1] {
			blow++
		}
		if a[3] == b[0] {
			blow++
		}
		if a[0] == b[2] {
			blow++
		}
		if a[1] == b[3] {
			blow++
		}
		if a[0] == b[3] {
			blow++
		}
		fmt.Printf("%d %d\n", hit, blow)
	}
}

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

using namespace std;

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

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

int hit(int x[],int y[]){
	int num=0;
	for(int i=0;i<4;i++){
		if(x[i] == y[i])
			num++;
	}
	return num;
}

int blow(int x[],int y[]){
	int num=0;
	for(int i=0;i<4;i++){
		for(int j=0;j<4;j++){
			if(x[i] == y[j])
				num++;
		}
	}
	return num-hit(x,y);
}

int check(int x[],int y[]){
	for(int i=0;i<4;i++)
		if(x[i] / 10 != 0 || y[i] / 10 != 0) return 0;
	return 1;
}

int check2(int x[]){
	for(int i=0;i<4;i++){
		for(int j=0;j<4;j++){
			if(i != j && x[i] == x[j])
				return 0;
		}
	}
	return 1;
}
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];
		if(check(a,b)){
			if(check2(a)){
				if(check2(b)){
					cout << hit(a,b) << " "<<blow(a,b)<<endl;
				}
			}
		}
	}
	
}

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

int A[4];
int B[4];
int main()
{
  while(scanf("%d %d %d %d\n%d %d %d %d",&A[0],&A[1],&A[2],&A[3],&B[0],&B[1],&B[2],&B[3]) != EOF){
  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++;
      }
    }
  }
    printf("%d %d\n",Hit,Blow);
  }
  return 0;
}

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

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

C++:     #include <iostream>
    using namespace std;
     
    int main() {
    string a,b;
    while(getline(cin,a),getline(cin,b)){
    int hit=0,blow=0;
    for(int i=0;i<a.size();i+=2){
    if(a[i]==b[i]){
    hit++;
    }else if(b.find(a[i],0)!=string::npos){
    blow++;
    }
    }
    cout<<hit<<" "<<blow<<endl;
    }return 0;
    }

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

int main(void){
	int a,b,c,d;
	std::vector<int> num;

	while(std::cin >> a >> b >> c >> d){
		num.push_back(a);
		num.push_back(b);
		num.push_back(c);
		num.push_back(d);
	}
	
	int hit,blow;
	for(int i = 0; i < (int)num.size(); i += 8){
		hit = 0, blow = 0;
		for(int j = 0; j < 4; ++j){
			for(int k = -j; k < -j+4; ++k){
				if(k == 0){
					if(num[i+j+4] == num[i+j+k]){
						++hit;
					}
				}else{
					if(num[i+j+4] == num[i+j+k]){
						++blow;
					}
				}
			}
		}
		std::cout << hit << " " << blow << std::endl;
	}

	return 0;
}

C++: #include <iostream>

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

	while (std::cin
		>> a[0] >> a[1] >> a[2] >> a[3]
		>> b[0] >> b[1] >> b[2]	>> b[3]
	) {
		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++: //ヒットアンドブロー
#include<cstdio>

using namespace std;

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

	while(scanf("%d %d %d %d",&a[0],&a[1],&a[2],&a[3])==4){
		scanf("%d %d %d %d",&b[0],&b[1],&b[2],&b[3]);
		hit=0;
		blow=0;
		for(i=0;i<4;i++){
			for(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 a[4], b[4];
	int hit, blow;

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

		cout << hit << " " << blow << endl;
	}
	
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
int a[4];
int b[4];
int hit=0,blow=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++){
if(a[i]==b[i])hit++;}
for(int i=0;i<4;i++){
for(int j=0;j<4;j++){
if(a[i]==b[j])blow++;}}
blow-=hit;
cout<<hit<<" "<<blow<<endl;}}

C++: #include <iostream>

using namespace std;

int main() {
	int size = 4;
	int ina[size];
	int inb[size];
	int hit=0, blow=0;
	while(true){
		cin>>ina[0]>>ina[1]>>ina[2]>>ina[3];
		cin>>inb[0]>>inb[1]>>inb[2]>>inb[3];
		if(cin.eof()) break;
		for(int i=0; i<size; i++) {
			if(ina[i] == inb[i]) hit++;//cout<<"check a:"<<ina[i]<<" b:"<<inb[i]<<endl;
			for(int j=0; j<size; j++){
				if(i==j) continue;
				//cout<<"check a:"<<ina[i]<<" b:"<<inb[j]<<endl;
				if(ina[i] == inb[j]) blow++;
			}
		}
		cout<<hit<<" "<<blow<<endl;
	}
	return 0;
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

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

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

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

	return 0;
}