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>

int hand[3], result[5];

int main(){
	while(scanf("%d", &result[0]),result[0]){
		bool d = 0;
		for(int i = 0; i < 3; i++) hand[i] = 0;
		for(int i = 1; i < 5; i++) scanf("%d", &result[i]);
		for(int i = 0; i < 5; i++) hand[result[i]-1]++;
		if(hand[0]==0&&hand[1]==0) d = 1;
		else if(hand[1]==0&&hand[2]==0) d = 1;
		else if(hand[0]==0&&hand[2]==0) d = 1;
		if((hand[0]>0&&hand[1]>0&&hand[2]>0)||d==1){
			for(int i = 0; i < 5; i++) printf("3\n");
			continue;
		}
		if(hand[0]==0){
			for(int i = 0; i < 5; i++){
				if(result[i]==2) printf("1\n");
				else printf("2\n");
			}
		} else if(hand[1] == 0){
			for(int i = 0; i < 5; i++){
				if(result[i]==3) printf("1\n");
				else printf("2\n");
			}
		} else if(hand[2] == 0){
			for(int i = 0; i < 5; i++){
				if(result[i]==1) printf("1\n");
				else printf("2\n");
			}
		}
	}
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int main() {
	int a[5];
	
	while (cin >> a[0], a[0]) {
		for_(i,1,5) cin >> a[i];
		int ex[4] = {0};
		for_(i,0,5) ex[a[i]] = 1;
		int sum = accumulate(ex, ex + 4, int());
		
		
		if (sum == 1 || sum == 3) {
			for_(i,0,5) cout << 3 << endl;
		} else {
			int win = (ex[1] && ex[2]) ? 1 : (ex[2] && ex[3]) ? 2 : 3;
			for_(i,0,5) cout << (a[i] == win ? 1 : 2) << endl;
		}
	}
}

C++: #include <cstdio>
#include <map>
using namespace std;
int w;

map<int, int> create_map() {
    map<int, int> m;
    m.insert({1, 0});
    m.insert({2, 0});
    m.insert({3, 0});
    return m;
}
map<int, int> m = create_map();
bool isEqual() {
    int idx = 0;
    for (int i = 1; i <= 3; i++) {
        if (m[i] == 5) { return true; }
        if (m[i] > 0) idx++;
    }
    return (idx == 3);
}

void setWinner() {
    if (m[3] == 0) w=1;
    else if (m[2] == 0) w=3;
    else if (m[1] == 0) w=2;
}

int main() {

    int p[5];
    for (; ;) {
        scanf("%d", &p[0]);
        if (p[0] == 0) break;
        m[1] = m[2] = m[3] = 0;
        m[p[0]]++;
        for (int i = 1; i < 5; i++) {
            scanf("%d", &p[i]);
            m[p[i]]++;
        }
        if (isEqual()) {
            for (int i = 0; i < 5; i++) printf("%d\n", 3);
        }
        else {
            setWinner();
            for (int i = 0; i < 5; i++) {
                (p[i] == w) ? printf("%d\n", 1) : printf("%d\n", 2);
            }
        }
    }

    return 0;
}

C++: #include<iostream>

using namespace std;
int main(void){

	int a[5],c[3];

	while(1){
		cin>>a[0];
		if(a[0]==0) break;
		for(int i=1;i<5;i++){
			cin>>a[i];
		}
		for(int i=0;i<5;i++){
			c[0]=0,c[1]=0,c[2]=0;
			for(int j=0;j<5;j++){
				c[a[j]-1]++;
			}
			if(c[a[i]-1]==5) cout<<3<<endl;
			if(c[0]>0&&c[1]>0&&c[2]>0) cout<<3<<endl;
			if(a[i]==1&&c[1]>0&&c[2]==0) cout<<1<<endl;
			if(a[i]==1&&c[1]==0&&c[2]>0) cout<<2<<endl;
			if(a[i]==2&&c[2]>0&&c[0]==0) cout<<1<<endl;
			if(a[i]==2&&c[2]==0&&c[0]>0) cout<<2<<endl;
			if(a[i]==3&&c[0]>0&&c[1]==0) cout<<1<<endl;
			if(a[i]==3&&c[0]==0&&c[1]>0) cout<<2<<endl;
		}

	}
}

C++: #include <cstdio>

int main(){
  int h[5], c[4];

  while(scanf("%d", h) && h){
    c[0] = c[1] = c[2] = c[3] = 0;
    c[h[0]]++;
    for(int i = 1; i < 5; ++i){ scanf("%d", h + i); c[h[i]]++;}

    if(c[1] && c[2] && c[3]) for(int i = 0; i < 5; ++i) puts("3");
    else if(c[1] && c[2]) for(int i = 0; i < 5; ++i) puts(h[i] == 1 ? "1" : "2");
    else if(c[2] && c[3]) for(int i = 0; i < 5; ++i) puts(h[i] == 2 ? "1" : "2");
    else if(c[3] && c[1]) for(int i = 0; i < 5; ++i) puts(h[i] == 3 ? "1" : "2");
  }
  return 0;
}

C++: #include <stdio.h>

#define PEOPLE    5
#define STACK_MAX 200

enum RPS {
  END_SIGN,
  ROCK,
  SCISSORS,
  PAPER,
};

enum RESULT {
  not_used3,
  WIN,
  LOSE,
  DRAW,
};

int array_sum(int *round) {
  int sum = 0;
  for (int i = 0; i < PEOPLE; i++) {
    sum += round[i];
  }
  return sum;
}

void print_result(int *array, int range_start, int range_end) {
  for (int i = range_start; i <= range_end; i++) {
    printf("%d\n", array[i]);
  }
}

void draw_all(int *array, int range_start, int range_end) {
  for (int i = range_start; i <= range_end; i++) {
    array[i] = DRAW;
  }
}

void mark_result(int *array, int range_end, int win) {
  int range_start = range_end - PAPER - 1;
  for (int i = range_start; i < range_end; i++) {
    if ( array[i] == win ) {
      array[i] = WIN;
    } else {
      array[i] = LOSE;
    }
  }
}

int main() {

  int stack[STACK_MAX];

  int tmp;
  int data_num = 0;
  while ( scanf("%d", &tmp) ) {
    if (tmp == END_SIGN) {
      break;
    }
    stack[data_num++] = tmp;
  }

  int round = 0;
  for (int i = 0; i < data_num; i++) {
    if ( i % PEOPLE == 4 ) {

      // テ・ツ?ィテ・ツ督。テ・ツ青古」ツ?佚ヲツ卍?
      int sum = stack[i] + stack[i - 1]
        + stack[i - 2] + stack[i - 3] + stack[i - 4];
      if ( sum % PEOPLE == 0 ) {
        draw_all(stack, i - 4, i);
        print_result(stack, i - 4, i);
        continue;
      }

      // テ」ツ?敕」ツつ古、ツサツ・テ・ツ、ツ?
      int rock_flag     = 0;
      int scissors_flag = 0;
      int paper_flag    = 0;
      for (int j = 0; j < PEOPLE; j++) {
        switch ( stack[i - j] ) {
          case ROCK:
            rock_flag = 1;
            break;
          case SCISSORS:
            scissors_flag = 1;
            break;
          case PAPER:
            paper_flag = 1;
            break;
        }
      }

      // テ・ツ?ィテ・ツ督。テゥツ?陛」ツ??
      if ( rock_flag && scissors_flag && paper_flag ) {
        draw_all(stack, i - 4, i);
      }
      else if ( rock_flag && scissors_flag ) {
        mark_result(stack, i, rock_flag);
      }
      else if ( scissors_flag && paper_flag ) {
        mark_result(stack, i, scissors_flag);
      }
      else if ( paper_flag && rock_flag ) {
        mark_result(stack, i, paper_flag);
      }
      print_result(stack, i - 4, i);
      
      round++;
    }
  }

}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int h[5];
  while (cin >> h[0], h[0]) {
    for (int i = 1; i < 5; i++) {
      cin >> h[i];
    }
    map<int, int> mp;
    for (int i = 0; i < 5; i++) {
      mp[h[i]]++;
    }
    if (mp.size() == 1 || mp.size() == 3) {
      for (int i = 0; i < 5; i++) {
        cout << 3 << endl;
      }
    } else {
      auto it = mp.begin();
      int a = it->first, b = (++it)->first;
      if (a > b) swap(a, b);
      if (a == 1 && b == 3) swap(a, b);
      for (int i = 0; i < 5; i++) {
        cout << (h[i] == a ? 1 : 2) << endl;
      }
    }
  }

  return 0;
}