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>

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];
    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<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int arr[5];
 int arr_2[5];
 
 int main()
 {
   int n;
   while(1)
   {
     cin>>n;
     if(n==0) break;
     else arr[0]=n;
     for(int i=1;i<5;i++) cin>>arr[i];
     int min=4;
     int max=0;
     for(int i=0;i<5;i++) arr_2[i]=arr[i];
     sort(arr_2,arr_2+5);
     int count=0;
     for(int i=0;i<4;i++)
     {
       if((arr_2[i+1]-arr_2[i])==1) count++;          
     }
     if(count==2)
     {
       int count2=5;
       while(count2--) cout<<"3"<<endl;          
     }
   else
   {
     for(int i=0;i<5;i++)
     {
       if(arr[i]>max) max=arr[i];
       if(arr[i]<min) min=arr[i];        
     }  
     if(min==1&&max==2)
     {
       for(int i=0;i<5;i++)
       {
         if(arr[i]==1) cout<<"1"<<endl;
         else cout<<"2"<<endl;        
       }                  
     }
     else if(min==2&&max==3)
     {
       for(int i=0;i<5;i++)
       {
         if(arr[i]==2) cout<<"1"<<endl;
         else cout<<"2"<<endl;        
       }                  
     }
     else if(min==1&&max==3)
     {
       for(int i=0;i<5;i++)
       {
         if(arr[i]==1) cout<<"2"<<endl;
         else cout<<"1"<<endl;        
       }                  
     }
     else if(min==max)
     {
       int count3=5;
       while(count3--) cout<<"3"<<endl;     
     }
   }
   }
   //while(1);
   return 0;
 }

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,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)||(a==5||b==5||c==5)){
			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>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

const int INF = 10000000;
using namespace std;
typedef long long  ll;

/** Problem0205 : Rock, Paper, Scissors **/
int main()
{
	int pl[5];
	while (cin>>pl[0], pl[0]!=0) {
		REP(i, 1, 5) cin >> pl[i];
		int r=0, p=0, c=0;
		rep(i, 5) {
			switch (pl[i]) {
				case 1: r++; break;
				case 2: c++; break;
				case 3: p++; break;
			}
		}
		if (r>0 && c>0 && p>0) {
			rep(i, 5) cout << 3 << endl;
		} else {
			if (r==0) {
				rep(i, 5)
				if (pl[i]==2) cout << 1 << endl;
				else		  cout << 2 << endl;
			} else if (c==0) {
				rep(i, 5)
				if (pl[i]==3) cout << 1 << endl;
				else		  cout << 2 << endl;
			} else {
				rep(i, 5)
				if (pl[i]==1) cout << 1 << endl;
				else		  cout << 2 << endl;
			}
		}
	}
	return 0;
}

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

int main(){
	int hand[5];
	int d[3]={2,3,1};
	while(1){
		cin >> hand[0];
		if(hand[0] == 0) break;
		int cou[4] = {0};
		cou[hand[0]]++;
		for(int i=1;i<=4;i++){
			cin >> hand[i];
			cou[hand[i]]++;
		}
		int tmp=0,temp=0;
		for(int i=1;i<4;i++){
			cout << cou[i] << " ";
		}
		cout << endl;
		for(int i=1;i<=3;i++){
			if(cou[i] == 5){
				tmp = 1;
				break;
			}
			else if(cou[i] == 0){
				temp = i;
			}
		}
		for(int i=0;i<5;i++){
			if(tmp == 1 || temp == 0) cout << "3" << endl;
			else {
				if(hand[i] == d[temp-1]) cout << "1" << endl;
				else cout << "2" << endl;
			}
		}
	}
}

C++: #include<iostream>
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){
      for(i=0;i<5;i++) printf("%d\n",3);
    }
    
    if(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){
      win=2; lose=3;
    }

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

    if(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 <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
  int T[5];
  while(cin >> T[0] >> T[1] >> T[2] >> T[3] >> T[4]){
    if(T[0] == 0) break;
    bool f[3];
    memset(f, false, sizeof(f));
    for(int i = 0 ; i < 5 ; i++) f[T[i]-1] = true;
    if(f[0] && f[1] && f[2]){
      for(int i = 0 ; i < 5 ; i++) T[i] = 3;
    }
    else if(f[0] && f[1] && !f[2]){
      for(int i = 0 ; i < 5 ; i++){
	if(T[i] == 1) T[i] = 1;
	else if(T[i] == 2) T[i] = 2;
      }
    }
    else if(f[1] && f[2] && !f[0]){
      for(int i = 0 ; i < 5 ; i++){
	if(T[i] == 2) T[i] = 1;
	else if(T[i] == 3) T[i] = 2;
      }
    }
    else if(f[0] && f[2] && !f[1]){
      for(int i = 0 ; i < 5 ; i++){
	if(T[i] == 3) T[i] = 1;
	else if(T[i] == 1) T[i] = 2;
      }
    }
    else{
      for(int i = 0 ; i < 5 ; i++){
	T[i] = 3;
      }
    }
    for(int i = 0 ; i < 5 ; i++){
      cout << T[i] << endl;
    }
  }
  return 0;
}