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

C++: #include <stdio.h>

bool d[12];

int a[4];
int b[4];

int main()
{
while(1 == scanf("%d",a))
{
for(int i = 1; i < 4; i++)
{
scanf("%d",a + i);
}
for(int i = 0; i < 4; i++)
{
scanf("%d",b + i);
}
for(auto& i : d)
{
i = false;
}
for(auto i : a)
{
d[i] = true;
}
int hi = 0;
int bu = 0;
for(int i = 0; i < 4; i++)
{
if(a[i] == b[i])
{
hi++;
}
else if(d[b[i]])
{
bu++;
}
}
}
}

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

int main(){
	int Hit = 0 , Blow = 0;
	char a[4],b[4];
	while(cin >> a >> b){
		for(int i = 0; i < 4; i++){
			for(int j = 0; j < 4 ; j++){
				if(a[i] == a[j]) Blow++;
			}
		}

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

		cout << Hit << " " << Blow << "\n";
	}

}

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

int main() {
	vector<int> a(4), b(4);
	while (cin >> a[0] >> a[1] >> a[2] >> a[3]) {
		for (int i = 0; i < 4; i++) {
			cin >> b[i];
		}
		int hit = 0, brow = 0;
		for (int i = 0; i < a.size(); i++) {
			if(a[i]==b[i])hit++;
			for (int j = 0; j < b.size(); j++) {
				if (i != j && a[i] == b[j])brow++;
			}
		}
		cout << hit << " " << brow << endl;
	}
	return 0;
}