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 <cstdio>
using namespace std;

int main(void){
  int a[4],b[4],Hit,Blow;


  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]) != EOF ){
    Hit = 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] && i != j ) Blow++;

    }
  }

  cout << Hit <<" "<< Blow << endl;
  }
  return 0;
}

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

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


  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]) != EOF){ 

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

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


}

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

int main(void){
	std::array <int, 4> ansA;
	std::array <int, 4> ansB;

	while(std::cin >> ansA[0] >> ansA[1] >> ansA[2] >> ansA[3] >> ansB[0] >> ansB[1] >> ansB[2] >> ansB[3]){
		int hit = 0; //count hit
		int blow = 0; //count blow

		for(size_t i = 0; i < ansA.size(); ++i){ //judgment hit and blow
			for(size_t j = 0; j < ansB.size(); ++j){
				if(ansA[i] == ansB[j] && i == j){
					++hit;
				}else if(ansA[i] == ansB[j] && i != j){
					++blow;
				}
			}
		}

		std::cout << hit << " " << blow << std::endl; //output result
	}

	return 0;
}

C++: #include <iostream>
#include <set>
using namespace std;
int main() {
	string a, b;
	while (getline(cin, a) && getline(cin, b)) {
		set<int> aa, bb;
		int hit = 0;
		int blow = 0;
		for (int i = 0; i != a.size()+1; i += 2) {
			if (a[i] == b[i]) {
				++hit;
			}
			else {
				aa.insert(a[i]-'0');
				bb.insert(b[i]-'0');
			}
		}
		for (int i =1; i <= 9; ++i) {
			if (aa.count(i) && bb.count(i)) {
				cout << i << endl;
				++blow;
			}
		}
		cout << hit << " " << blow << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
 
int main(){
    std::vector<int> a(4);
     
    while(std::cin >> a[0] >> a[1] >> a[2] >> a[3]){
        int hit = 0, blow = 0;
         
        for(int i = 0; i < 4; ++i){
            int b;
            std::cin >> b;
             
            auto it = std::find(a.begin(), a.end(), b);
            if(it == a.begin() + i) ++hit;
            else if(it != a.end()) ++blow;
        }
         
        std::cout << hit << " " << blow << std::endl;
         
    }
     
    return 0;

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

int main(void){
	std::array <int, 4> ansA;
	std::array <int, 4> ansB;

	while(std::cin >> ansA[0] >> ansA[1] >> ansA[2] >> ansA[3] >> ansB[0] >> ansB[1] >> ansB[2] >> ansB[3]){
		int hit = 0; //count hit
		int blow = 0; //count blow

		for(size_t i = 0; i < ansA.size(); ++i){ //judgment hit and blow
			for(size_t j = 0; j < ansB.size(); ++j){
				if(ansA[i] == ansB[j] && i == j){
					++hit;
				}else if(ansA[i] == ansB[j] && i != j){
					++blow;
				}
			}
		}

		std::cout << hit << " " << blow << std::endl; //output result
	}

	return 0;
}

C++: #include <iostream>
int main(){
    int n;
    while(std::cin>>n){
        if(n==0){
            break;
        }
        else{
            int a[4];
            a[0]=n;
            for(int i=1;i<4;++i){
                std::cin>>a[i];
            }
            int b[4];
            for(int i=0;i<4;++i){
                std::cin>>b[i];
            }
            int c=0,d=0;
            for(int i=0;i<4;++i){
                for(int j=0;j<4;++j){
                    if(a[i]==b[j]){
                        if(i==j){
                            ++c;
                        }
                        else{
                            ++d;
                        }
                    }
                }
            }
            std::cout<<c<<" "<<d<<std::endl;
        }
    }
    return 0;
}

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

				
int main(){
	std::vector<int> a,b;
	a.resize(4);
	b.resize(4);
	while(std::cin >> a[0] >> a[1] >> a[2] >> a[3]){
		std::cin >> b[0] >> b[1] >> b[2] >> b[3];
		int hit = 0;
		int blow = 0;
		for(int i = 0; i <= 3; ++i){
			if(a.at(i) == b.at(i))
				++hit;
		}
		for(int i = 0; i <= 3; ++i){
			for(int j = 0; j <= 3; ++j){
				if(a.at(i) == b.at(j))
					++blow;
			}
		}
		
		std::cout << hit << " " << blow - hit << std::endl;
	}
	
	return 0;
}

C++: #include <stdio.h>
  int main(){ 
	  int a[5],b[5],i,j;
	  int hit=0,blow=0;
	  while(scanf("%d %d %d %d %d %d %d %d",&a[1],&a[2],&a[3],&a[4],&b[1],&b[2],&b[3],&b[4]) != EOF){
		  for(i=1;i<=4;i++){
			  if(a[i]==b[i]){
				  hit++;
			  }
		  }
		  for(i=1;i<=4;i++){
			  for(j=1;j<= 4;j++){
				  if(j != i){
				  if(a[i]==b[j]){
					  blow++;
				  }	  
			  }
			  }
		  }
		  printf("%d %d\n",hit,blow);
		  hit=0; blow=0;
	  }
	  return 0;
  }

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

C++: #include <iostream>

#define SIZE 4

using namespace std;

int main() {
	int a[SIZE], b[SIZE], hit, blo;

	while (cin>>a[0]>>a[1]>>a[2]>>a[3]>>b[0]>>b[1]>>b[2]>>b[3]) {
		hit = 0;
		blo = 0;
		for (int i = 0; i < SIZE; i++) {
			if (a[i] == b[i]) {
				hit++;
				a[i] = -1;
				b[i] = -1;
			}
		}

		for (int i = 0; i < SIZE; i++) {
			for (int j = i + 1; j < SIZE; j++) {
				if (a[i] == -1 || b[j] == -1) {
					continue;
				}

				if (a[i] == b[j]) {
					a[i] = -1;
					b[j] = -1;
					blo++;
				}
			}
		}
		cout << hit << " " << blo << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <climits>
#include <cmath>
#include <cassert>
#include <sstream>
#include <algorithm>
#include <valarray>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>

#define SIZE 300005
#define INF INT_MAX / 3
#define LLINF 10e12 // 1<<31 // 2^31
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,a,n) for(int i=(a);i<=(n);i++)
#define SET(a,c) memset(a,c,sizeof a)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FOREACH(i,c) for(auto (i) : (c))
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique(ALL((o))), (o).end());
#define SQ(x) ((x)*(x))

using namespace std;
typedef long long ll;
typedef valarray<int> array_t;

/////

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // FROM HERE
  int T[8];
  vector<int> a(4);
  vector<int> b(4);
  int i = 0;
  while(cin >> T[i])
  {
    i = (i+1)%8;
    if(i == 0)
    {
      REP(i,4) a[i] = T[i];
      REP(i,4) b[i] = T[i+4];
      int hit = 0, blow = 0;
      REP(i,4) hit += (a[i] == b[i]);
      REP(i,4) blow += (find(ALL(b),a[i])!=b.end());
      cout << hit << " " << blow-hit << endl;
    }
  }

}