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>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<cstring>
#include<utility>
#include<set>
#include<stack>
#include<complex>
#include<bitset>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PA;
using namespace std;
#define MAX  999999
int main(){
	vi v(5,0);
	vb flag(4,true);
	vvi u(4,vi(4,0));
	u[1][2]=1;u[2][3]=1;u[3][1]=1;
	while(cin>>v[0],v[0]){
		rep(i,4)cin>>v[i+1];
		int cnt=0;
		rep(i,5)if(flag[v[i]]){flag[v[i]]=false; cnt++;}
		if(cnt==1||cnt==3){rep(i,5)cout<<3<<endl;goto L;}
		rep(i,5){
			rep(j,5){
				if(i==j||v[i]==v[j])continue;
				if(u[v[i]][v[j]]){cout<<"1"<<endl; break;}
				else {cout<<"2"<<endl;break;}
			}
		}
		L:;
	}
}

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


int main(){
  int sum[3],raw[5];
  int ta,tb,winnum;
  while (1){
    for (int i=0;i<3;i++) sum[i]=0;
    ta=0;tb=0;winnum=0;
    cin >>raw[0];
    if (raw[0]==0) break;
    cin >> raw[1] >> raw[2] >> raw[3] >> raw[4];
    for (int i=0;i<5;i++)sum[raw[i]-1]++;
    if ((sum[0]!=0&&sum[1]!=0&&sum[2]!=0)||(sum[0]==0&&sum[1]==0)||(sum[1]==0&&sum[2]==0)||(sum[0]==0&&sum[2]==0)){
      cout << "3" << endl << "3" << endl << "3" << endl << "3" << endl << "3" << endl;
    }else{
      for(int i=0;i<3;i++){
	if (sum[i]==0)continue;
	if (ta==0)ta=i+1;
	else tb=i+1;
      }
      if (ta>tb)swap(ta,tb);
      if (ta==1&&tb==2)winnum=1;
      else if (ta==2&&tb==3)winnum=2;
      else if (ta==1&&tb==3)winnum=3;
      for (int i=0;i<5;i++)
	if (winnum == raw[i])cout << "1" << endl;
	else cout << "2" << endl;
    }
  }

  return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<char, int>P;

int main(){
	int b[5];
	while (cin >> b[0], b[0]) {
		int a[4]{};
		a[b[0]] = true;
		for (int i = 1; i < 5; i++) {
			cin >> b[i]; a[b[i]] = true;
		}
		int cnt = 0;
		for (int i = 1; i <= 3; i++)if (a[i])cnt++;
		if (cnt == 1 || cnt == 3) {
			rep(i, 5)puts("3");
			continue;
		}
		rep(i, 4) {
			if (b[i] < b[i + 1] || (b[i] == 3 && b[i + 1] == 1))puts("1");
			else puts("2");
		}
		if (b[4] < b[3] || (b[4] == 3 && b[3] == 1))puts("1");
		else puts("2");
	}
	return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int a[5]={0};
	int guu=0,tyoki=0,paa=0;
	int n=1;
	int i=0;
	while(n!=0)
	{
		for (i=0;i<5;i++)
		{
			scanf("%d",&a[i]);
			
			if (a[i]==0)
			{
				break;
			}
			else if (a[i]==1)
			{
				guu=1;
			}
			else if(a[i]==2)
			{
				tyoki=1;
			}
			else if (a[i]==3)
			{
				paa=1;
			}
		}
		for (i=0;i<5;i++)
		{
			if (guu==1&&tyoki==1&&paa==1)
			{
				printf("3\n");
			}
			else if (guu==1&&tyoki==1&&paa==0)
			{
				if (a[i]==1)
				{
					printf("1\n");
				}
				else
				{
					printf("2\n");
				}
			}
			else if (guu==1&&tyoki==0&&paa==0)
			{
				printf("3\n");
			}
			else if (guu==1&&tyoki==0&&paa==1)
			{
				if (a[i]==1)
				{
					printf("2\n");
				}
				else
				{
					printf("1\n");
				}
			}
			else if (tyoki==1&&paa==1)
			{
				if (a[i]==2)
				{
					printf("1\n");
				}
				else
				{
					printf("2\n");
				}
			}
			else if (tyoki==1&&paa==0)
			{
				printf("3\n");
			}
			else if (paa==1)
			{
				printf("3\n");
			}
			a[i]=0;
		}
			guu=0,tyoki=0,paa=0;
	}
}

C++: #include <iostream>
using namespace std;
int main(void){
    int i, hand[6]={};
    
    while(1){
    int x[4]={0, 0, 0, 0};
    for(i=1; i<=5; i++){
        cin >> hand[i];
        if(hand[i] == 1) x[1]=1;  //グー
        else if(hand[i] == 2) x[2]=1; //チョキ
        else if(hand[i] == 3) x[3]=1; //パー
        else return 0;
    }
    
    if(x[1] == 1){ //グーが出た
        if(x[2] == 1){ //チョキが出た
            if(x[3] == 1){ //パーが出た
                //あいこ
                for(i=1; i<=5; i++){
                    cout << '3' << endl;
                }
            }
            else{   //グーとチョキだけ
                for(i=1; i<=5; i++){
                    if(hand[i] == 1) cout << 1 << endl; //勝ち
                    else cout << '2' << endl; //負け
                    }
            }
        }
        else{ //チョキは出ない
            if(x[3] == 1){ //グーとパーだけ
                for(i=1; i<=5; i++){
                    if(hand[i] == 3) cout << 1 << endl; //勝ち
                    else cout << '2' << endl; //負け
                }
            }
            else{ //パーも出ない＝グーだけ
                for(i=1; i<=5; i++){
                    cout << '3' << endl; //あいこ
                }
            }
        }
    }
    else{ //グーは出ない
        if(x[2] == 1){ //チョキが出た
            if(x[3] == 1){ //パーが出た
                for(i=1; i<=5; i++){
                    if(hand[i] == 2) cout << 1 << endl; //勝ち
                    else cout << '2' << endl; //負け
                }
            }
            else{ // パーが出ない＝チョキだけ
                for(i=1; i<=5; i++){
                    cout << '3' << endl; //あいこ
                }
            }
        }
        else{ //チョキもでない＝パーだけ
            for(i=1; i<=5; i++){
                cout << '3' << endl; //あいこ
            }
        }
    }
    }
    return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define bitcount(b) __builtin_popcount(b)

int main(){
	int hand[5];
	while(1){
		int bit = 0;
		rep(i,5){
			if(cin >> hand[i])bit |= 1 << (--hand[i]) ;
			else  return 0;
		}
		if( bitcount(bit) != 2){
			rep(i,5) cout << 3 << endl;
		}else{
			rep(i,5) cout << 1 + !count( hand , hand+5 , (hand[i]+1)%3 ) << endl;
		}
	}
}