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))||((con1 == 0)&&(con2 == 0))||((con2 == 0)&&(con3 == 0))||((con1 == 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>

using namespace std;

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

C++: #include<stdio.h>
int main()
{
	int a[5],i,g,t,p,r[5];
	while(1){
		g=p=t=0;
		scanf("%d",&a[0]);
		if(a[0]==0){
			break;
		}
		scanf("%d%d%d%d",&a[1],&a[2],&a[3],&a[4]);
		for(i=0;i<5;i++){
			switch(a[i]){
			case 1:
				g++;
				break;
			case 2:
				t++;
				break;
			case 3:
				p++;
				break;
			}
		}
		if((g!=0&&t!=0&&p!=0)||g==5||t==5||p==5){
			for(i=0;i<5;i++){
				r[i]=3;
			}
		}else if(g==0){
			for(i=0;i<5;i++){
				if(a[i]==2){
					r[i]=1;
				}else{
					r[i]=2;
				}
			}
		}else if(t==0){
			for(i=0;i<5;i++){
				if(a[i]==3){
					r[i]=1;
				}else{
					r[i]=2;
				}
			}
		}else{
			for(i=0;i<5;i++){
				if(a[i]==1){
					r[i]=1;
				}else{
					r[i]=2;
				}
			}
		}
		for(i=0;i<5;i++){
			printf("%d\n",r[i]);
		}
	}
	return 0;
}

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

int main() {
	int i,j,k,d[5],f[3];
	while (cin >> d[0]) {
		f[0]=f[1]=f[2]=k=0;
		if (d[0]==0) break;
		f[d[0]-1]=1;
		for (i=1;i<5;i++) { cin >> d[i]; f[d[i]-1]=1;}
		for (i=0;i<3;i++) if (f[i]==1 && f[(i+1) % 3]==1) break;
		if  ((f[0]==1 && f[1]==1 && f[2]==1) || i==3) k=3;
		for (j=0;j<5;j++) {
			if (k!=3) { if (d[j]==i+1) k=1; else k=2;}
			cout << k << endl;
		}
	} 
	return 0;
}

C++: #include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<climits>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reg(i,a,b) for(int i=(a);i<=(b);i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=(b);i>=(a);i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX

int main(void){
	while(1){
		int a[5];
		scanf("%d",a);
		if(a[0]==0)break;
		int is[3]={};
		rep(i,4){
			scanf("%d",&a[i+1]);
		}
		rep(i,5){
			a[i]--;
			is[a[i]]=1;
		}
		rep(i,5){
			int ans;
			int no = a[i];
			int s=0;
			rep(j,2)if(is[(no+j+1)%3]==1)s+=j+1;
			//printf("    %d\n",s);
			if(s==0 || s==3)ans=3;
			else if(s==1)ans=1;
			else ans=2;
			printf("%d\n",ans);
		}
	}
		
	return 0;
}

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

int main() {
	int n[5];
	while(cin >> n[0] && n[0]){
		set<int> kind;
		kind.insert(n[0]);
		for(int i = 1; i < 5; ++i){
			cin >> n[i];
			kind.insert(n[i]);
		}
		int ans[5] = {0};
		if(kind.size() == 1){
			for(int i = 0; i < 5; ++i)
				ans[i] = 3;
		}
		else if(kind.size() == 3){
			for(int i = 0; i < 5; ++i)
				ans[i] = 3;
		}
		else{
			int win = 0;
			if(kind.find(1) != kind.end() && kind.find(2) != kind.end())
				win = 1;
			else if(kind.find(2) != kind.end() && kind.find(3) != kind.end())
				win = 2;
			else
				win = 3;
			
			for(int i = 0; i < 5; ++i){
				if(n[i] == win)
					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},i,R,P,S;

	while(0==0){
		
		R=P=S=0;

		scanf("%d",&t[0]);

		if(t[0]==0) break;
		else if(t[0]==1) R++;
		else if(t[0]==2) S++;
		else P++;
	    

		for(i=1;i<5;i++){
			scanf("%d",&t[i]);
			if(t[i]==1) R++;
		    else if(t[i]==2) S++;
	      	else P++;
		}

		if(R==0){
			if(P!=0 && S!=0)
				for(i=0;i<5;i++){
					if(t[i]==2) t[i]=1;
					else t[i]=2;
				}
		}
	    if(S==0){
			if(P!=0 && R!=0)
				for(i=0;i<5;i++){
					if(t[i]==3) t[i]=1;
					else t[i]=2;
				}
		}
		if(P==0){
			if(S!=0 && R!=0)
				for(i=0;i<5;i++){
					if(t[i]==1) t[i]=1;
					else t[i]=2;
				}
		}
		
		if(R==5 || S==5 || P==5 || (R!=0 && S!=0 && P!=0))
			for(i=0;i<5;i++)
				t[i]=3;

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

	return 0;
}