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 h[5];
  int f[4];
 
  while(1){
    for(int i=0;i<4;i++) f[i]=0;
    for(int i=0;i<5;i++){
      cin>>h[i];
      if(h[i]==0) break;
      f[h[i]]=1;
    }
    if(h[0]==0) break;
 
    int x[2], cnt=0;
    for(int i=1;i<4;i++){
      if(f[i]==1)
    x[cnt++]=i;
      //cout<<i<<" "<<f[i]<<endl;
    }
    //cout<<"    "<<cnt<<" "<<x<<endl;
    if(cnt==2){
      if(x[0]==1&&x[1]==2){
    for(int i=0;i<5;i++){
      if(h[i]==1) cout<<1<<endl;
      else cout<<2<<endl;
    }
      }
      if(x[0]==1&&x[1]==3){
    for(int i=0;i<5;i++){
      if(h[i]==1) cout<<2<<endl;
      else cout<<1<<endl;
    }
      }
      if(x[0]==2&&x[1]==3){
    for(int i=0;i<5;i++){
      if(h[i]==2) cout<<1<<endl;
      else cout<<2<<endl;
    }
      }
    }else{
      for(int i=0;i<5;i++) cout<<3<<endl;
    }
  }
   
  return 0;

C++: #include <iostream>
using namespace std;
int main(void){
  int RPS[5],R,P,S;
  while(1){
    R = P = S = 0;
    for(int i=0;i<5;i++){cin>>RPS[i];if(RPS[0]==0)break;if(RPS[i]==1)R++;else if(RPS[i]==2)S++;else P++;}
    if(RPS[0]==0)break;
    if(R>0&&S>0&&P>0||R==5||S==5||P==5){for(int i=0;i<5;i++)cout<<"3"<<endl;}
    else if(R==0){for(int i=0;i<5;i++){if(RPS[i]==2)cout<<"1"<<endl;else cout<<"2"<<endl;}}
    else if(S==0){for(int i=0;i<5;i++){if(RPS[i]==3)cout<<"1"<<endl;else cout<<"2"<<endl;}}
    else if(P==0){for(int i=0;i<5;i++){if(RPS[i]==1)cout<<"1"<<endl;else cout<<"2"<<endl;}}
  }
  return 0;
}

C++: #include<stdio.h>
using namespace std;

int main(){
  int h[5],count[3],win,lose,drow;
  int i;
  
  while(1){

    count[0]=0; count[1]=0; count[2]=0;
    
    for(i=0;i<5;i++){
      scanf("%d",&h[i]);
      if(h[0]==0) return -1;
      if(h[i]==1) count[0]++;
      if(h[i]==2) count[1]++;      
      if(h[i]==3) count[2]++;
    }
    
    if(count[0] > 0 && count[1] > 0 && count[2] > 0 || h[0] == h[1] && h[1] == h[2] && h[2] == h[3] && h[3] == h[4]){
      for(i=0;i<5;i++) printf("%d\n",3);
    }

    if(count[0]==0 && count[1]!=0 && count[2]!=0){
      win=2; lose=3;
    }

    if(count[0]!=0 && count[1]==0 && count[2]!=0){
      win=3; lose=1;
    }

    if(count[0]!=0 && count[1]!=0 && count[2]==0){
      win=1; lose=2;
    }

    for(i=0;i<5;i++){
      if(win==h[i]) printf("%d\n",1);
      if(lose==h[i]) printf("%d\n",2);
    }
    
  }
  return 0;
}

C++: #include<cstdio>
#include<iostream>
using namespace std;
int main(){
  int a[5];
  while(1){
    cin >> a[0];
    if(a[0]==0)break;
    int b[3]={0};
    b[a[0]-1]++;
    for(int i=1;i<5;i++){
      cin >> a[i];
      b[a[i]-1]++;
    }
    int w;
    if((b[0]!=0&&b[1]!=0&&b[2]!=0)||b[0]==5||b[1]==5||b[2]==5){
      for(int i=0;i<5;i++) cout << 3 << endl;
    }else{
      if(b[0]==0){
	w=1;
      }else if(b[1]==0){
	w=2;
      }else{
	w=0;
      }
      for(int i=0;i<5;i++){
	if(a[i]==w+1){
	  cout << 1 << endl;
	}else {
	  cout << 2 << endl;
	}
      }
    }
  }
}

C++: #include<iostream>
using namespace std;
int main(){
  int h[5],cnt[3];
  
  while(cin >> h[0],h[0]!=0){
    for(int i=1;i<5;i++) cin >> h[i];
    
    cnt[1] = 0;
    cnt[2] = 0;
    cnt[3] = 0;
    
    for(int i=0;i<5;i++) cnt[ h[i] ]++;
    
    for(int i=0;i<5;i++){
      
      if(cnt[1] == 5 || cnt[2] == 5 || cnt[3] == 5) cout << 3 << endl;
      else if(cnt[1] != 0 && cnt[2] != 0 && cnt[3] != 0) cout << 3 << endl;
      
      else if(cnt[1] == 0){
	if(h[i] == 2) cout << 1 << endl;
	if(h[i] == 3) cout << 2 << endl;
      }
      else if(cnt[2] == 0){
	if(h[i] == 3) cout << 1 << endl;
	if(h[i] == 1) cout << 2 << endl;
      }
      else if(cnt[3] == 0){
	if(h[i] == 1) cout << 1 << endl;
	if(h[i] == 2) cout << 2 << endl;
      }
    }

  }
  return(0);
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iterator>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	for(vi a(5);cin>>a[0],a[0];){
		repi(i,1,5) cin>>a[i];
		int flg=0;
		rep(i,5)
			flg|=1<<(a[i]-1);
		if(flg==7 || __builtin_popcount(flg)==1)
			rep(i,5) cout<<3<<endl;
		else if(flg==3)
			rep(i,5) cout<<(a[i]==1?1:2)<<endl;
		else if(flg==5)
			rep(i,5) cout<<(a[i]==3?1:2)<<endl;
		else if(flg==6)
			rep(i,5) cout<<(a[i]==2?1:2)<<endl;
	}
	
	return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
	int player[5] = {0};
	int cnt = 0;

	while(1){
		int flag = -1;

		cin >> flag;

		if(flag == 0)break;
		cnt++;

		player[0] = flag;

		cin >> player[1] >> player[2] >> player[3] >> player[4];
	}

	for(int i=0;i<cnt-1;i++)
		for(int j=0;j<5;j++)
			cout << '3' << endl;

	bool gu = false,pa = false,ty = false;

	for(int i=0;i<5;i++){
		if(player[i] == 1)gu = true;
		else if(player[i] == 2)ty = true;
		else if(player[i] == 3)pa = true;
	}

	for(int i=0;i<5;i++){
		if(gu && pa){
			if(player[i] == 3)cout << '1' << endl;
			else cout << '2' << endl;
		}
		else if(gu && ty){
			if(player[i] == 1)cout << '1' << endl;
			else cout << '2' << endl;
		}
		else if(ty && pa){
			if(player[i] == 2)cout << '1' << endl;
			else cout << '2' << endl;
		}
	}
	return 0;
}

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

int main(){
	int a[5];
	while( cin >> a[0] , a[0] ){
		for(int i=1 ; i<5 ; ++i ){
			cin >> a[i];
			if( a[i] == 3 ) a[i]++;
		}
		int x=0;
		for(int i=0; i<5 ; ++i ){
			x |= a[i];
		}
		for(int i=0 ; i<5 ; ++i ){
			if( x == 1 || x == 2 || x == 4 || x == 7 ){
				cout << 3 << endl;
			}else{
				int y = x ^ a[i];
				if( (y>>1) == a[i] || (a[i] == 4 && y == 1) ){
					cout << 1 << endl;
				}else{
					cout << 2 << endl;
				}
			}
		}
	}
}