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<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string.h>
#include<math.h>
#include<cstring>
using namespace std;

int main(){
	while(1){
		int i,n,h[5],a=0,b=0,c=0;
		cin>>h[0];
		if(h[0]==0)break;
		cin>>h[1]>>h[2]>>h[3]>>h[4];
		for(i=0;i<5;i++){
			if(h[i]==1){
				a++;
			}else if(h[i]==2){
				b++;
			}else{
				c++;
			}
		}
		if(a!=0&&b!=0&&c!=0){
			for(i=0;i<5;i++){
				cout<<'3'<<endl;
			}
		}else if(a==0){
			for(i=0;i<5;i++){
				if(h[i]==2){
					cout<<'1'<<endl;
				}else{
					cout<<'2'<<endl;
				}
			}
		}else if(b==0){
			for(i=0;i<5;i++){
				if(h[i]==3){
					cout<<'1'<<endl;
				}else{
					cout<<'2'<<endl;
				}
			}
		}else{
			for(i=0;i<5;i++){
				if(h[i]==1){
					cout<<'1'<<endl;
				}else{
					cout<<'2'<<endl;
				}
			}
		}
	}
	return 0;
}

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

int main(){
    int data[4],n[5];
    while(1){
        memset(data,0,sizeof(data));
        cin >> n[0];
        if(n[0] == 0) break;
        for(int i=1;i<5;i++){
            cin >> n[i];
            data[n[i]] = 1;
        }
        if((data[1] == 1 && data[2] == 1 && data[3] == 1) || (data[1] == 1 && data[2] == 0 && data[3] == 0) || (data[1] == 0 && data[2] == 1 && data[3] == 0) || (data[1] == 0 && data[2] == 0 && data[3] == 1)){
            for(int i=0;i<5;i++) cout << 3 << endl;
        }
        else if(data[1] == 1 && data[2] == 1){
            for(int i=0;i<5;i++){
                if(n[i] == 1) cout << 1 << endl;
                else cout << 2 << endl;
            }
        }
        else if(data[2] == 1 && data[3] == 1){
            for(int i=0;i<5;i++){
                if(n[i] == 2) cout << 1 <<endl;
                else cout << 2 <<endl;
            }
        }
        else if(data[1] == 1 && data[3] == 1){
            for(int i=0;i<5;i++){
                if(n[i] == 1) cout << 2 << endl;
                else cout << 1 << endl;
            }
        }
    }
}

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<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)flag[i]=true;
        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<stdio.h>

int main(void){
  int a[5],i;
  while(scanf("%d",&a[0]),a[0]!=0){
    int used[3];
    used[0]=used[1]=used[2]=0;
    used[a[0]-1]=1;
    for(i=1;i<5;i++)scanf("%d",&a[i]),used[a[i]-1]=1;
    int sum=used[0]+used[1]+used[2];
    printf("%d\n",sum);
    if(sum!=2){
      for(i=0;i<5;i++)printf("3\n");
      continue;
    }
    for(i=0;i<5;i++){
      switch(a[i]){
      case 1:
	if(used[1])printf("1\n");
	else printf("2\n");
	break;
      case 2:
	if(used[2])printf("1\n");
	else printf("2\n");
	break;
      case 3:
	if(used[0])printf("1\n");
	else printf("2\n");
	break;
      }
    }
  }
}

C++: #include <cstdio>

int main(void)
{
	int hand[5];
	int i;
	int g, c, p;
	
	while (1){
		g = c = p = false;
		
		scanf("%d", &hand[0]);
		if (hand[0] == 0) break;
		g |= (hand[i] == 1);
		c |= (hand[i] == 2);
		p |= (hand[i] == 3);
		
		for (i = 1; i < 5; i++){
			scanf("%d", &hand[i]);
			g |= (hand[i] == 1);
			c |= (hand[i] == 2);
			p |= (hand[i] == 3);
		}
		
		int a = g + c + p;
		if ((a == 3) || (a == 1)){
			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 (c && p){
			for (i = 0; i < 5; i++){
				if (hand[i] == 2) 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");
			}
		}
	}
	
	return (0);
}