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 X[5];

   while(1){
	int con1=0,con2=0,con3=0;
	
	cin >> X[0];
	if(X[0] == 0) break;

	for(int i=1;i<5;i++){
		cin >> X[i];
	}

	for(int i=0;i<5;i++){
		if(X[i] == 1) con1++;
		if(X[i] == 2) con2++;
		if(X[i] == 3) con3++;
	}

	if((con1 != 0)&&(con2 != 0)&&(con3 != 0)){
		for(int i=0; i<5; i++){
			cout << "3" << "\n";
		}

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

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

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

			cout << endl;
		}
	}
   }

   return 0;
}

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



void solve(vector<int>& a){
  int f[3]={};
  int s[]={0,1,2};
  int t[]={1,2,1};
  for(int i=0;i<a.size();i++){
    f[a[i]-1]=1;
  }
  if( (f[0]+f[1]+f[2])%2 == 1 )
    for(int i=0;i<5;i++) cout << "3\n";

  else
    for(int j=0;j<3;j++){
      if( f[s[j]]==1 && f[t[j]]==1 ){
	for(int i=0;i<5;i++){
	  if(a[i] == s[j]+1) cout << "1\n";
	  if(a[i] == t[j]+1) cout << "2\n";
	}
      }
    }
}

int main(){
  bool f=true;
  while(1){
    vector<int> x;
    for(int i=0;i<5;i++){
      int tmp;
      cin >> tmp;
      if(i==0 && tmp == 0){
	f=0;
	break;
      }
      x.push_back(tmp);
    }
    if(!f) break;
    solve(x);
  }
}

C++: #include <iostream>

#define NMAX (5)

using namespace std;

int hand[NMAX];

int main() {
	int result;
	for(int i; cin >> i && i!= 0;) {
		hand[0] = i;
		cin >> hand[1] >> hand[2] >> hand[3] >> hand[4];
		result = 0;
		for(int j=0; j<5; j++) {
			switch(hand[j]) {
			case 1:
				result |= 1;
				break;
			case 2:
				result |= 2;
				break;
			case 3:
				result |= 4;
			}
		}
		int typenum = 0;
		for(int res = result; res; res >>= 1)
			if(res&1)
				typenum++;
		
		switch(typenum) {
		case 1:
		case 3:
			for(int k=0; k<5; k++)
				cout << 3 << endl;
			break;
		case 2:
			if(!(result & 1)) {
				for(int k=0; k<5; k++)
					if(hand[k] == 2)
						cout << 1 << endl;
					else
						cout << 2 << endl;				
			}else if(!(result & 2)) {
				for(int k=0; k<5; k++)
					if(hand[k] == 3)
						cout << 1 << endl;
					else
						cout << 2 << endl;								
			}else{
				for(int k=0; k<5; k++)
					if(hand[k] == 1)
						cout << 1 << endl;
					else
						cout << 2 << endl;								
			}
			break;
		default:
			cerr << "err" << endl;
		}
	}	
	return 0;
}

C++: #include<stdio.h>
int main()
{
	for(;;)
	{
		int i,a[5],b[3]={0},w;
		for(i=0;i<5;++i)
		{
			if(scanf("%d",&a[i])-1)return 0;
			b[a[i]-1]++;
		}
		if((b[0]&&b[1]&&b[2])||(b[0]==5||b[1]==5||b[2]==5))puts("3\n3\n3\n3\n3");
		else
		{
			w=(!b[0]?2:(!b[1]?3:1));
			for(i=0;i<5;++i)printf("%d\n",(a[i]!=w)+1);
		}
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
int main()
{
    int num[5];
    while(cin>>num[0],num[0]){
        bool hand[4]={};
        hand[num[0]]=1;
        for(int i=1;i<5;i++){
            cin>>num[i];
            hand[num[i]]=1;
        }
        if(hand[1]&&hand[2]&&hand[3])for(int i=0;i<5;i++)cout<<"3\n";
        else {
            int win;
            if(!hand[3])win=1;
            else if(!hand[1])win=2;
            else win=3;
            for(int i=0;i<5;i++){
                if(win==num[i])cout<<"1\n";
                else cout<<"2\n";
            }
        }
    }
}

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

int main(){
	int human[5];
	while(cin>>human[0],human[0]){
		if(human[0]==1) hand[0]++;
		else if(human[0]==2) hand[1]++;
		else hand[2]++;
		bool hand[3]={0,0,0};
		for(int i=1;i<5;i++){
			cin>>human[i];
			if(human[i]==1) hand[0]++;
			else if(human[i]==2) hand[1]++;
			else hand[2]++;
		}
		if((hand[0]==true&&hand[0]==hand[1]&&hand[0]==hand[2])||(hand[0]==false&&hand[0]==hand[1])||(hand[0]==false&&hand[0]==hand[2])||(hand[1]==false&&hand[1]==hand[2])){
			for(int i=0;i<5;i++)cout<<'3'<<endl;
		}
		else if(hand[0]==true&&hand[0]==hand[1]){
			for(int i=0;i<5;i++){
				if(human[i]==1)cout<<'1'<<endl;
				else cout<<'2'<<endl;
			}
		}
		else if(hand[0]==true&&hand[0]==hand[2]){
			for(int i=0;i<5;i++){
				if(human[i]==3)cout<<'1'<<endl;
				else cout<<'2'<<endl;
			}
		}
		else if(hand[1]==true&&hand[1]==hand[2]){
			for(int i=0;i<5;i++){
				if(human[i]==2)cout<<'1'<<endl;
				else cout<<'2'<<endl;
			}
		}
	}
	return 0;
}

C++: #include <stdio.h>
int main(void){
    int i, hand[6]={};
    
    while(1){
    int x[4]={0, 0, 0, 0};
    for(i=1; i<=5; i++){
        scanf("%d", &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++){
                    printf("3\n");
                }
            }
            else{   //グーとチョキだけ
                for(i=1; i<=5; i++){
                    if(hand[i] == 1) printf("1\n"); //勝ち
                    else printf("2\n"); //負け
                    }
            }
        }
        else{ //チョキは出ない
            if(x[3] == 1){ //グーとパーだけ
                for(i=1; i<=5; i++){
                    if(hand[i] == 3) printf("1\n"); //勝ち
                    else printf("2\n"); //負け
                }
            }
            else{ //パーも出ない＝グーだけ
                for(i=1; i<=5; i++){
                    printf("3\n"); //あいこ
                }
            }
        }
    }
    else{ //グーは出ない
        if(x[2] == 1){ //チョキが出た
            if(x[3] == 1){ //パーが出た
                for(i=1; i<=5; i++){
                    if(hand[i] == 2) printf("1\n"); //勝ち
                    else printf("2\n"); //負け
                }
            }
            else{ // パーが出ない＝チョキだけ
                for(i=1; i<=5; i++){
                     printf("3\n"); //あいこ
                }
            }
        }
        else{ //チョキもでない＝パーだけ
            for(i=1; i<=5; i++){
                 printf("3\n"); //あいこ
            }
        }
    }
    }
    return 0;
}

C++: 
#include <cstdio>

using namespace std;

int main( void )
{

	int hand_list[5];
	int hands = 0;
	while( 1 )
	{
		for( int i = 0; i < 5; ++i )
		{
			scanf( "%d", &hand_list[i] );
			if( hand_list[0] == 0 )
				goto end_0205;
			hands |= 1 << (hand_list[i] - 1);
		}

		for( int i = 0; i < 5; ++i )
		{
			if( hands == 0x0001 || hands == 0x0002 || hands == 0x0004 || hands == 0x0007 )
			{
				puts( "3" );
			}
			else
			{
				if( hands == 0x0003 )
				{
					if( hand_list[i] == 2 ) puts( "2" );
					else puts( "1" );
				}
				else if( hands == 0x0006 )
				{
					if( hand_list[i] == 3 ) puts( "2" );
					else puts( "1" );
				}
				else if( hands == 0x0005 )
				{
					if( hand_list[i] == 1 ) puts( "2" );
					else puts( "1" );
				}
			}
		}
	}

end_0205:
	return 0;

}