Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		h := make([]int, 5)
		h[0], _ = strconv.Atoi(scanner.Text())
		if h[0] == 0 {
			break
		}
		for i := 1; i <= 4; i++ {
			scanner.Scan()
			h[i], _ = strconv.Atoi(scanner.Text())
		}
		tbl := make([]bool, 3)
		aiko := false
		for _, v := range h {
			tbl[v-1] = true
		}
		if tbl[0] && tbl[1] && tbl[2] { // 全ての手があるあいこ
			aiko = true
		}
		if h[0] == h[1] && h[1] == h[2] && h[2] == h[3] && h[3] == h[4] {
			aiko = true
		}
		if aiko {
			fmt.Printf("3\n3\n3\n3\n3\n")
		} else {
			win := 0
			if !tbl[0] {
				win = 2
			}
			if !tbl[1] {
				win = 3
			}
			if !tbl[2] {
				win = 1
			}
			for i := 0; i < 5; i++ {
				if h[i] == win {
					fmt.Println(1)
				} else {
					fmt.Println(2)
				}
			}
		}
	}
}

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

int main() {
	int hand[5];
	while(cin >> hand[0], hand[0]) {
		for(int i = 1; i < 5; i++)
			cin >> hand[i];

		int win[5] = {-1,-1,-1,-1,-1};
		bool flg = true;
		for(int i = 0; i < 5; i++) {
			for(int j = 0; j < 5; j++) {
				if(i != j) {
					int tmp = (hand[j] - hand[i] + 3) % 3;
					if(win[i] == -1 && tmp != 0)
						win[i] = tmp;
					else if(win[i] != tmp && tmp != 0)
						flg = false;
				}
			}
		}

		if(flg) {
			for(int i = 0; i < 5; i++)
				cout << (win[i] == 0 ? 3 : win[i]) << endl;
		}
		else {
			for(int i = 0; i < 5; i++)
				cout << 3 << endl;
		}
	}
}

C++: #include<iostream>
#include<vector>
#include<math.h>
#include<stdlib.h>
#include<algorithm>
using namespace std;


const int END_OF_INPUT = 0;


int main() {
	int a_n;
	
	while (cin >> a_n && a_n != 0){
		vector<int> m_list;
		m_list.push_back(a_n);

		for (int i = 0; i < 4; ++i){
			cin >> a_n;
			m_list.push_back(a_n);
		}

		int is_even = 0;
		bool rps[3];
		for (int i = 1; i <= 3; ++i){
			vector<int>::iterator cIter = find(m_list.begin(), m_list.end(), i);
			rps[i - 1] = false;
			if (cIter != m_list.end()){
				++is_even;
				rps[i - 1] = true;
			}
		}
		if (is_even == 3 || is_even == 1){
			// even 
			for (int i = 1; i <= 5; ++i){
				cout << "3" << endl;
			}
		}
		else{
			int winner = 0;
			if (rps[0] && rps[1]){
				// グー
				winner = 1;
			}
			else if (rps[1] && rps[2]){
				// ちょき
				winner = 2;
			}
			else if (rps[2] && rps[0]){
				// パー
				winner = 3;
			}

			for (int i = 0; i < 5; ++i){
				if (m_list[i] == winner){
					cout << "1" << endl;
				}
				else{
					cout << "2" << endl;
				}
			}
		}


		

	}
	


}

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

int main(){
	int n[5],ans[5];
	while(cin>>n[0],n[0]){
		int rock,paper,scissors;
		rock=paper=scissors=0;
		for(int i=1;i<5;i++){
			cin>>n[i];
		}
		for(int i=0;i<5;i++){
			switch(n[i]){
				case 1:
				rock++;
				break;
				case 2:
				scissors++;
				break;
				case 3:
				paper++;
				break;
			}
		}
		if(rock>0 && paper>0 && scissors>0){
			for(int i=0;i<5;i++)ans[i]=3;
		}else{
			if(rock==0){
				for(int i=0;i<5;i++){
					if(n[i]==2)ans[i]=1;
					else ans[i]=2;
				}
			}else if(paper==0){
				for(int i=0;i<5;i++){
					if(n[i]==1)ans[i]=1;
					else ans[i]=2;
				}
			}else{
				for(int i=0;i<5;i++){
					if(n[i]==3)ans[i]=1;
					else ans[i]=2;
				}
			}
		}
		for(int i=0;i<5;i++)cout<<ans[i]<<endl;
	}
	return 0;
}

C++: #include<stdio.h>

int main(void)
{
  int t[5]={0},t2=0,t3=0,t1=0,k,i;

while(scanf("%d",&k)!=0){

t2=0; t3=0; t1=0;

for(i=0;i<5;i++){
scnaf("%d",&t[i]);
  if(t[i]==1)
       t1++;
else if(t[i]==2)
   t2++;
else if(t[i]==3)
   t3++;
}

if(t1==0){
  if((t2==0) || (t3==0)) for(i=0;i<5;i++) t[i]=3;
else
   for(i=0;i<5;i++){
       if(t[i]==2)  t[i]=1;
      else if(t[i]==3) t[i]=2;
    }
}
else if(t2==0){
  if((t1==0) || (t3==0))   for(i=0;i<5;i++) t[i]=3;
else
   for(i=0;i<5;i++){
       if(t[i]==1)  t[i]=2;
      else if(t[i]==3) t[i]=1;
}
}

else if(t3==0){
  if((t2==0) || (t1==0))  for(i=0;i<5;i++) t[i]=3;
else
   for(i=0;i<5;i++){
       if(t[i]==2)  t[i]=2;
      else if(t[i]==1) t[i]=1;
}
}

else   for(i=0;i<5;i++) t[i]=3;
}
for(i=0;i<5;i++)  printf("%d\n",t[i]);

return 0
}

C++: # define _CRT_SECURE_NO_WARNINGS 1
# define _USE_MATH_DEFINES
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <unordered_set>
# include <unordered_map>
# include <climits>
# include <complex>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;
# define INF ((int)(1<<25))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,n) REP(i,n)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define STR(x) string x;cin>>x;
# define ALL(x) begin(x),end(x)
# define RALL(x) (x).rbegin(),(x).rend()
# define DEBUG(x) cout<<#x<<":"<<x<<endl;
# define EPS 1e-12
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
typedef long long lint;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<lint> vl;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
const int dx[4] = { 0, 1, 0, -1 }, dy[4] = { -1, 0, 1, 0 };
template<class T> void debug(T a) { for (auto i : a)cout << i << endl; }



int main()
{
	while (true)
	{
		int a[5] = {}, x[4] = {};
		FOR(i, 5)
		{
			cin >> a[i];
			x[a[i]]++;
		}
		if (a[0] == 0)break;
		int g, c, p;
		g = x[1]; c = x[2]; p = x[3];
		if ((g&&c&&p) || (g&&!c&&!p) || (!g&&c&&!p) || (!g&&!c&&p))
		{
			FOR(i, 4)x[i] = 3;
		}
		else
		{
			FOR(i, 4)x[i] = 2;
			if (!g)
			{
				x[2] = 1;
			}
			if (!c)
			{
				x[3] = 1;
			}
			if (!p)
			{
				x[1] = 1;
			}
		}
		FOR(i, 5)cout << x[a[i]] << endl;

	}
}

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

using namespace std;

int main(void){
  int a;
  bool fg[4];
  vector<int>v;

  while(true){

    v.clear();
    fill(fg,fg+4,false);

    for(int i=0;i<5;i++){
      cin >> a;
      if(a==0)return 0;
      v.push_back(a);
    }    

    for(int i=0;i<5;i++)fg[v[i]]=true;
    if((fg[1] && fg[2] && fg[3]) ||
       (fg[1] && !fg[2] && !fg[3]) ||
       (!fg[1] && !fg[2] && fg[3]) ||
       (!fg[1] && fg[2] && !fg[3])){
      for(int i=0;i<5;i++)cout << 3 << endl;
    }
    
    if(fg[1] && fg[2] && !fg[3]){
      for(int i=0;i<5;i++){
	if(v[i]==1)cout << 1 << endl;
	else if(v[i]==2)cout << 2 << endl;
      }
    } 
    if(fg[1] && !fg[2] && fg[3]){
      for(int i=0;i<5;i++){
      	if(v[i]==1)cout << 2 << endl;
	else if(v[i]==3)cout << 1 << endl;
      }
    }
    if(!fg[1] && fg[2] && fg[3]){
      for(int i=0;i<5;i++){
	if(v[i]==2)cout << 1 << endl;
	else if(v[i]==3)cout << 2 << endl;
      }
    }
	  
  }

  return 0;
}

C++: #include <cstdio>

#define CH_G(a, g) (a == 1) ? true : g
#define CH_C(a, c) (a == 2) ? true : c
#define CH_P(a, p) (a == 3) ? true : p


int main(void)
{
	int hand[5];
	int i;
	bool g, c, p;
	
	while (1){
		g = c = p = false;
		
		scanf("%d", &hand[0]);
		if (hand[0] == 0) break;
		g = CH_G(hand[i], g);
		c = CH_C(hand[i], c);
		p = CH_P(hand[i], p);
		
		for (i = 1; i < 5; i++){
			scanf("%d", &hand[i]);
			g = CH_G(hand[i], g);
			c = CH_C(hand[i], c);
			p = CH_P(hand[i], p);
		}
		
		if ((g && c && p) || (g && !c && !p) || (!g && c && !p) || (!g && !c && p)){
			for (i = 0; i < 5; i++) printf("3\n");
		}
		else if (g && c){
			for (i = 0; i < 5; i++){
				if (hand[i] == 1) printf("1\n");
				else printf("2\n");
			}
		}
		else if (g && p){
			for (i = 0; i < 5; i++){
				if (hand[i] == 3) printf("1\n");
				else printf("2\n");
			}
		}
		else if (c && p){
			for (i = 0; i < 5; i++){
				if (hand[i] == 2) printf("1\n");
				else printf("2\n");
			}
		}
	}
	
	return (0);
}