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 <cstdio>

#define CH_G(a, g) (a == 1) ? true : g
#define CH_C(a, c) (a == 2) ? true : c
#define CH_P(a, p) (a == 3) ? true : p


int main(void)
{
	int hand[5];
	int i;
	bool g, c, p;
	
	while (1){
		g = c = p = false;
		
		scanf("%d", &hand[0]);
		if (hand[0] == 0) break;
		g = CH_G(hand[i], g);
		c = CH_C(hand[i], c);
		p = CH_P(hand[i], p);
		
		for (i = 1; i < 5; i++){
			scanf("%d", &hand[i]);
			g = CH_G(hand[i], g);
			c = CH_C(hand[i], c);
			p = CH_P(hand[i], p);
		}
		
		if ((g && c && p) || (g && !c && !p) || (!g && c && !p) || (!g && !c && p)){
			for (i = 0; i < 5; i++) printf("3\n");
		}
		else if (g && c){
			for (i = 0; i < 5; i++){
				if (hand[i] == 1) printf("1\n");
				else printf("2\n");
			}
		}
		else if (c && p){
			for (i = 0; i < 5; i++){
				if (hand[i] == 2) printf("1\n");
				else printf("2\n");
			}
		}
		else if (g && p){
			for (i = 0; i < 5; i++){
				if (hand[i] == 3) printf("1\n");
				else printf("2\n");
			}
		}
	}
	
	return (0);
}

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

using namespace std;

int main(int argc, char const* argv[])
{
	vector<int> data;
	data.resize( 5 );

	while( cin >> data[0] && data[0] != 0 ){
		for( int i = 1;i < 5;i++ ) cin >> data[i];
		int rock = count( data.begin(), data.end(), 1 );
		int paper = count( data.begin(), data.end(), 3 );
		int scissors = count( data.begin(), data.end(), 2 );

		if( rock && paper && scissors || rock == 5 || paper == 5 || scissors == 5 ){
			for( int i = 0;i < 5;i++ ) cout << 3 << endl;
			continue;
		}

		if( rock == 0 ){
			for( unsigned int i = 0;i < data.size();i++ ){
				if( data[i] == 2 ) cout << 1 << endl;
				else cout << 2 << endl;
			}
			continue;
		}

		if( paper == 0 ){
			for( unsigned int i = 0;i < data.size();i++ ){
				if( data[i] == 1 ) cout << 1 << endl;
				else cout << 2 << endl;
			}
			continue;
		}

		if( scissors == 0 ){
			for( unsigned int i = 0;i < data.size();i++ ){
				if( data[i] == 3 ) cout << 1 << endl;
				else cout << 2 << endl;
			}
			continue;
		}
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
int main() {
	int n[5];
	int type[][2] = {{0,1},{0,2},{1,0},{1,2},{2,0},{2,1}};
	int res[] = {1,2,2,1,1,2};
	while(cin >> n[0], n[0]) {
		int cnt[3] = {};
		cnt[--n[0]]++;
		rep2(i,1,5) {
			cin >> n[i];
			cnt[--n[i]]++;
		}
		int max = 0, min = 9, max_te = -1, min_te = -1;
		rep(i,3) {
			if(max < cnt[i]) max = cnt[i], max_te = i;
			if(min > cnt[i]) min = cnt[i], min_te = i;
		}
		if(max == 5 || min >= 1){
			rep(j,5) {
				cout << 3 << endl;
			}
		} else {
			rep(i,6) {
				if(max_te==type[i][0] && min_te==type[i][1]) {
					rep(j,5) {
						if(type[i][0]==n[j]) cout << res[i] << endl;
						else cout << 3-res[i] << endl;
					}
				}
			}
		}
	}
}

C++: #include <bits/stdc++.h>
using namespace std;

int main() {
    vector<int> v(5);
    while (cin >> v[0], v[0]) {
        bool g = false, c = false, p = false;
        for (int i = 1; i < 5; i++) cin >> v[i];

        for (auto i : v) {
            if (i == 1) g = true;
            if (i == 2) c = true;
            if (i == 3) p = true;
        }

        if (g && c && p) {
            for (int i = 0; i < 5; i++) cout << 3 << endl;
        } else if (g && c && !p) {
            for (auto i : v) {
                if (i == 1) cout << 1 << endl;
                else cout << 2 << endl;
            }
        } else if (g && !c && p) {
            for (auto i : v) {
                if (i == 3) cout << 1 << endl;
                else cout << 2 << endl;
            }
        } else if (!g && c && p) {
            for (auto i : v) {
                if (i == 2) cout << 1 << endl;
                else cout << 2 << 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,0};
  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>
#include <vector>
using namespace std;



void solve(vector<int>& a){
  int f[3]={};
  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 if( f[0]==1 && f[1]==1 ){
    for(int i=0;i<5;i++){
      if(a[i] == 1) cout << "1\n";
      if(a[i] == 2) cout << "2\n";
    }
  }

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

  else if( f[0]==1 && f[2]==1 ){
    for(int i=0;i<5;i++){
      if(a[i] == 3) cout << "1\n";
      if(a[i] == 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++: #define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair<int,string> P;

static const double eps = 1e-8;

int main(){
	int gesture[5];
	while(~scanf("%d",&gesture)){
		if(gesture[0]==0) break;
		for(int i=0;i<4;i++){
			scanf("%d",gesture+i+1);
		}

		for(int i=0;i<5;i++){
			int bit,player;
			bit = player = (1 << (gesture[i]-1));

			for(int j=0;j<5;j++){
				if(i==j) continue;
				bit |= (1 << (gesture[j]-1));
			}

			if(bit == ((1<<3)-1)){
				printf("3\n");
			}

			else if(bit == 1 
				|| bit == (1<<1)
				|| bit == (1<<2)){
					printf("3\n");
			}

			else{
				bit &= ~player;
				if(player == 1 && bit == (1<<1)){
					printf("1\n");
				}
				else if(player == 1 && bit == (1<<2)){
					printf("2\n");
				}

				else if(player == (1<<1) && bit == 1){
					printf("2\n");
				}
				else if(player == (1<<1) && bit == (1<<2)){
					printf("1\n");
				}

				else if(player == (1<<2) && bit == 1){
					printf("1\n");
				}
				else if(player == (1<<2) && bit == (1<<1)){
					printf("2\n");
				}
			}
		}
		
	}

}