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

int main(void)
{
	int A[4], B[4];
	int res[4], hit, blow;

	//ifstream fin("in.txt");
	istream& in=cin;

	while(1)
	{
		for(int i=0; i<4; i++)
			{ if( !(in >> A[i]) )return 0; }
		for(int i=0; i<4; i++)
			{ if( !(in >> B[i]) )return 0; }


		for(int i=0; i<4; i++)
			res[i] = 0;
		for(int i=0; i<4; i++)
		{
			if(A[i] == B[i])
			{
				res[i] = 1;
			}
			else
			{
				for(int j=0; j<4; j++)
					if(A[j] == B[i])res[i] = 2;
			}
		}

		hit=0; blow=0;
		for(int i=0; i<4; i++)
		{
				 if(res[i] == 1)hit++;
			else if(res[i] == 2)blow++;
		}
		cout << hit << ' ' << blow << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <array>
#include <stack>
#include <queue>
#include <chrono>
#include <numeric>
#include <memory.h>
#include <map>
#include <math.h>
#include <utility>
#include <set>

#pragma warning(disable:4996)
using namespace std;
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
typedef long long Int;
const double PI = 3.141592653589793238;
const Int INF = 999999999999;
typedef pair<int, int> P;


int aa[10];
int bb[10];

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

	int n;
	while (cin >> n){
		a[0] = n;
		REP(i, 3){
			cin >> a[i+1];
		}

		REP(i, 4){
			cin >> b[i];
		}

		REP(i, 10){
			aa[i] = bb[i] = -1;
		}


		REP(i, 4){
			aa[a[i]] = i;
			bb[b[i]] = i;
		}

		int blow = 0;
		int hit = 0;

		REP(i, 10){
			if (aa[i] >= 0){
				if (bb[i] >= 0){
					if (aa[i] == bb[i])
						++hit;
					else
						++blow;
				}
			}
		}

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

}

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

int main()
{
	std::vector<int> a(4);

	std::vector<int> b(4);

	int hit,blow;

	for(;;)
	{
		for(int i=0;i<4;++i)
		{
			std::cin >> a[i];
		}

		for(int i=0;i<4;++i)
		{
			std::cin >> b[i];
		}

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

		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 && b[i]==a[j])
				{
					++blow;
				}
			}
		}

		std::cout << hit << ' ' << blow << '\n';
	}
}

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

int main() {
	int a[4],b[4];
	int hit,blow;
	
	while ( cin >> a[0] ){
		for ( int i = 1; i < 4; i++ ) 
			cin >> a[i];
		for ( int i = 0; i < 4; i++ )
			cin >> b[i];
		
		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++;
					}
				}
			}
		}
		cout << hit << " " << blow << endl;
	}
	return 0;
}

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

int main(){
  int a[4],c[4];
  while(1){
    int e=0,b=0,k;
    for(int i=0;i<4;i++)
      k=scanf("%d",&a[i]);
    if(k==-1)break;
    for(int i=0;i<4;i++){
      cin >> c[i];
      for(int j=0;j<4;j++)
	if(c[i]==a[j]){
	  if(i==j)e++;
	  else b++;
	}
    }
    cout<<e<<' '<<b<<endl;
  }
  return 0;
}

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);
	while (cin>>a[0]){
	int hit_count=0;
	int blow_count=0;
	REP(i,3){
		cin>>a[i+1];
	}
	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>
#include <array>

int main(){
	std::array<int, 4> a;
	std::array<int, 4> b;
	int hit = 0;
	int blow = 0;

	while(std::cin >> a[0] >> a[1] >> a[2] >> a[3] && std::cin >> b[0] >> b[1] >> b[2] >> b[3]){
		//std::cin >> a[0] >> a[1] >> a[2] >> a[3];
		//std::cin >> b[0] >> b[1] >> b[2] >> b[3];

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

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

		hit = 0;
		blow = 0;
	}

}

C++: #include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

#define vcitr vector<int>::iterator
#define vcsitr vector<string>::iterator
#define mapcitr map<char, int>::iterator
#define mapsitr map<string, int>::iterator

typedef long long ll;

const int iINF = 2147483647;
const ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }

int main() {
	vci a(4), b(4);
	bool use[10] = { 0 };
	
	while (cin>>a[0]>>a[1]>>a[2]>>a[3]>>b[0]>>b[1]>>b[2]>>b[3]) {		
		for_(i, 0, 4) use[ a[i] ] = 1;
		
		int hit = 0, blow = 0;
		for_(i, 0, 4) {
			if (a[i] == b[i]) hit++;
			else if (use[ b[i] ]) blow++;
		}
		cout << hit << " " << blow << endl;
	}
	
	return 0;
}

C++: #include<iostream>

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

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

int main(){

  std::stack<int> st;

  int N = 0;
  int a;

  while(N <= 100 && std::cin >> a){
    if(a != 0){
      st.push(a);
    }
    else{
      std::cout << st.top() << std::endl;
      st.pop();
	}
    ++N;
  }
}