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<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[1000001];//動的計画法
int prime[1000001];
int main(){
    int hand[5];
    int gcnt,ccnt,pcnt;
    int ans[5];
    while(cin>>hand[0],hand[0]){
        gcnt=ccnt=pcnt=0;
        for(int i=1;i<5;i++){
            cin>>hand[i];
        }
        for(int i=0;i<5;i++){
            if(hand[i]==1) gcnt++;
            else if(hand[i]==2) ccnt++;
            else pcnt++;
        }
        if(gcnt>0&&ccnt>0&&pcnt>0){
            for(int i=0;i<5;i++){
                ans[i]=3;
                cout<<ans[i]<<endl;
            }
            continue;
        }else if(gcnt==5||ccnt==5||pcnt==5){
             for(int i=0;i<5;i++){
                ans[i]=3;
                cout<<ans[i]<<endl;
            }
            continue;
        }else{
            if(pcnt==0){
                for(int i=0;i<5;i++){
                    if(hand[i]==1) ans[i]=1;
                    else ans[i]=2;
                }
            }else if(gcnt==0){
                for(int i=0;i<5;i++){
                    if(hand[i]==2) ans[i]=1;
                    else ans[i]=2;
                }
            }else{
                for(int i=0;i<5;i++){
                    if(hand[i]==3) ans[i]=1;
                    else ans[i]=2;
                }
            }
            for(int i=0;i<5;i++){
                cout<<ans[i]<<endl;
            }
        }
    }
    return 0;
}

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

using namespace std;

int main(){
  for(;;){
    int h[5];
    vector<int> k(4);
    for(int i=0;i<5;i++){
      cin>>h[i];
      if(h[i]==0)return 0;
      k[h[i]]=1;
    }
    if(count(k.begin(),k.end(),1)!=2){
      for(int i=0;i<5;i++){
	cout<<3<<endl;
      }
    }else{
      int n=*find(k.rbegin(),k.rend(),0);
      for(int i=0;i<5;i++){
	cout<<((n%3+1==h[i])?1:2)<<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) or (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) or (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) or (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++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int a;
	while(cin>>a,a){
		vector<int>in(5);
		in[0]=a;
		rep(i,4)cin>>in[i+1];
		bool h[3]={0};
		rep(i,5)in[i]--;
		rep(i,5)h[in[i]]=true;
		if(h[0]&&h[1]&&h[2]){
			rep(i,5)cout<<3<<endl;
			continue;
		}
		if(!h[0]){
			rep(i,5)if(in[i]==1)cout<<1<<endl;
			else cout<<2<<endl;
		}else if(!h[1]){
			rep(i,5)if(in[i]==2)cout<<1<<endl;
			else cout<<2<<endl;
		}else if(!h[2]){
			rep(i,5)if(in[i]==0)cout<<1<<endl;
			else cout<<2<<endl;
		}
	}
}

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<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int c[5];
    while(cin >> c[0], c[0]){
        range(i,1,5)
            cin >> c[i];
        bool rock, paper, scissors;
        rock = paper = scissors = false;
        rep(i,5){
            if(c[i] == 1){
                rock = true;
            }else if(c[i] == 2){
                scissors = true;
            }else{
                paper = true;
            }
        }
        int r, p ,s;
        if(rock && paper && scissors){
            r = p = s = 3;
        }else if(rock && paper && !scissors){
            p = 1;
            r = 2;
        }else if(rock && scissors && !paper){
            r = 1;
            s = 2;
        }else if(paper && scissors && !rock){
            s = 1;
            p = 2;
        }else if(rock){
            r = 3;
        }else if(paper){
            p = 3;
        }else if(scissors){
            s = 3;
        }
        rep(i,5){
            if(c[i] == 1)
                cout << r << endl;
            else if(c[i] == 2)
                cout << s << endl;
            else if(c[i] == 3)
                cout << p << 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 && !paper) || (!rock && !scissors) || (!paper && !scissors)){
			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;
}