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<cstdio>
#include<vector>
using namespace std;
#define int long long
signed main(){
	int a1,b1,c1,d1;
	int a2,b2,c2,d2;
	while( scanf("%lld %lld %lld %lld", &a1, &b1, &c1, &d1) != EOF ){
		scanf("%lld %lld %lld %lld", &a2, &b2, &c2, &d2);
		vector<int> listn(10,0);
		listn[a1] = 1;
		listn[b1] = 1;
		listn[c1] = 1;
		listn[d1] = 1;
		int hit=0, blow=0;
		if (a1==a2) hit++;
		else blow += listn[a2];
		if (b1==b2) hit++;
		else blow += listn[b2];
		if (c1==c2) hit++;
		else blow += listn[c2];
		if (d1==d2) hit++;
		else blow += listn[d2];
		cout << hit << " " << blow << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){

  int a[4],b[4],n,m;

  while(cin >> a[0]){
    n = 0;
    m = 0;
    cin >> a[1] >> a[2] >> a[3];
    for(int i=0;i<4;i++){
      cin >> b[i];
      if(a[i] == b[i]) n++;
      for(int j=0;j<4;j++){
	if(b[i] == a[j]) m++;
      }
    }
    
    cout << n << " " << (m-n) << endl;
  }
  return (0);
}

C++: #include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <stdio.h>

using namespace std;

int a[4], b[4];

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

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

using namespace std;

int main() {
	string str_a, str_b;
	int a, b;
	while (getline(cin, str_a)) {
		getline(cin, str_b);
		int hit = 0, blow = 0;
		for (int i = 0; i < str_a.length(); i++) {
			if ('1' <= str_a[i] && str_a[i] <= '9') {
				a = str_a.find(str_a[i]);
				b = str_b.find(str_a[i]);
				if (a != -1 && b != -1) {
					if (a == b) {
						hit += 1;
					}
					else {
						blow += 1;
					}
				}
			}
		}
		cout << hit << " " << blow << endl;

	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main(){

	int A[5];
	int B[5];

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

				if(A[i] ==  B[j] && A[i] != B[i]){
					blow++;
				}
			}
		}

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

	return 0;
}

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

int main() {

  int a[4],b[4];

  while(true) {

    if ( cin.eof() ) break;

    cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3];

    int hit = 0;
    int blow = 0;

    for ( int i = 0; i < 4; i++ ) {

      for ( int j = 0; j < 4; j++ ) {

	int k = (i+j)%4;

	if ( a[k] == b[i] ) {

	  if ( i == k ) {
	    hit++;
	    break;
	  }else {
	    blow++;
	  }

	}

      }

    }

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

  }

}

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

bool CheckArray(const std::vector<int>& v, const int& x)
{
	bool flg=0;

	for(size_t i=0; i<v.size(); ++i)
	{
		if(v[i]==x)
		{
			flg=1;
		}
	}

	return flg;
}

int main()
{
	const int Item =4;//ヒットアンドブローで遊ぶ数字の数

	std::vector<int> a;

	int temp=0, cHit=0, cBlow=0;

	while(1)
	{
		if(std::cin.eof())
		{
			break;
		}

		for(int i=0; i<Item; ++i)
		{
			std::cin >> temp;

			a.push_back(temp);
		}

		for(int i=0; i<Item; ++i)
		{
			std::cin >> temp;

			if(temp==a[i])
			{
				++cHit;//Hitのカウント
			}

			if(CheckArray(a,temp))
			{
				++cBlow;//tempがa[]のどれかと一致（Hit+Blow）
			}
		}

		cBlow -= cHit;

		std::cout << cHit << ' ' << cBlow << '\n';

		a.clear();

		cHit=0, cBlow=0;
	}
}

C++: #include <cstdio>

int main(){
  int a[4],b[4];
  while(~scanf("%d",&a[0])){
    int c=0,d=0;
    for(int i=1; i<4; i++)
      scanf("%d",&a[i]);
    for(int i=0; i<4; i++)
      scanf("%d",&b[i]);
    for(int i=0; i<4; i++)
      for(int j=i; j<4; j++){
	if(a[i]==b[j])
	  if(i==j){
	    c++;
	  }else{
	    d++;
	  }
      }
    printf("%d %d\n",c,d);
  }
  
}

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

int as[4];
int bs[4];

int main() {
  while (1) {
    int hit = 0;
    int blow = 0;
  
    for (int i=0; i<4; i++) {
      if (scanf("%d", &as[i]) != 1) return 0;
    }
  
    for (int i=0; i<4; i++) {
      scanf("%d", &bs[i]);
      if (as[i] == bs[i]) hit++;
      else {
        for (int j=0; j<4; j++) {
          if (as[j] == bs[i]) blow++;
        }
      }
    }
  
    printf("%d %d\n", hit, blow);
  }
}

C++: #include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };

int main() {
	vector<int> a(4);
	vector<int> b(4);
	int hit_count=0;
	int blow_count=0;
	REP(i,4){
		cin>>a[i];
	}
	REP(i, 4){
		cin >> b[i];
	}
	REP(i, 4){
		if (a[i] == b[i]){
			hit_count++;
		}
	}
	REP(i, 4){
		REP(j, 4){
			if (i==j)continue;
			if (a[i] == b[j]){
				blow_count++;
			}
		}
	}
	cout << hit_count << " "<<blow_count<<endl;
}

C++: #include<iostream>
using namespace std;
int main(){
	int a[4]={0},b[4]={0},hi,br;
	while(cin>>a[0]>>a[1]>>a[2]>>a[3]>>b[0]>>b[1]>>b[2]>>b[3]){
		hi=0;
		br=0;
		for(int i=0;i<4;i++){
			if(a[i]==b[i]){
				hi++;
			}
		}
		for(int i;i<4;i++){
			for(int n;n<4;n++){
				if(i!=n&&a[i]==b[n]){
					br++;
				}
			}
		}
		cout<<hi<<" "<<br<<endl;
	}
}

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++;
      blow+=appear[b[i]];
    }

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

  return 0;
}