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)
				}
			}
		}
	}
}

Python: from sys import stdin
readline = stdin.readline


R, S, P = 1, 2, 3
W, L, D = 1, 2, 3

rps = {
    (R, S, P):{R:D, S:D, P:D},
    (R, S)   :{R:W, S:L},
    (S, P)   :{S:W, P:L},
    (R, P)   :{P:W, R:L}
}

while True:
    hand = int(readline())
    if hand == 0:
        break
    hands = [hand] + [int(readline()) for _ in range(4)]
    hand_set = tuple(sorted(set(hands)))
    for h in hands:
        print(rps[hand_set][h])

Python: while True:
    h1 = int(input())
    if h1 == 0:
        break
    h = [h1, *map(int, (input() for _ in [0]*4))]
    s = set(h)
    if len(s) % 2 == 1:
        print(*([3]*5), sep="\n")
    else:
        result = [0, 0, 0, 0]
        if 1 in s and 2 in s:
            result[1], result[2] = 1, 2
        elif 2 in s and 3 in s:
            result[2], result[3] = 1, 2
        else:
            result[1], result[3] = 2, 1
        print(*(result[n] for n in h), sep="\n")

Python: from sys import stdin
readline = stdin.readline


def main():
    R, S, P = 1, 2, 3
    W, L, D = 1, 2, 3

    rps = {
        (R, S, P):{R:D, S:D, P:D},
        (R, S)   :{R:W, S:L},
        (S, P)   :{S:W, P:L},
        (R, P)   :{P:W, R:L}
    }

    while True:
        hand = int(readline())
        if hand == 0:
            break
        hands = [hand] + [int(readline()) for _ in range(4)]
        hand_set = tuple(sorted(set(hands)))
        for h in hands:
            print(rps[hand_set][h])
main()

Python: while True:
    h = int(input())
    if h == 0:
        break
    dataset = [h] + [int(input()) for _ in range(4)]
    if len(set(dataset)) == 3 or len(set(dataset)) == 1:
        print(*[3]*5, sep="\n")
        continue
    
    for data in dataset:
        if data == 1:
            print(2 if 3 in dataset else 1)
        elif data == 2:
            print(2 if 1 in dataset else 1)
        else:
            print(2 if 2 in dataset else 1)

Python: # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0205

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    while True:
        hands = [0] * 5
        hands[0] = int(input())
        if hands[0] == 0:
            break
        hands[1] = int(input())
        hands[2] = int(input())
        hands[3] = int(input())
        hands[4] = int(input())

        # ?????????????????????????????±???????????????
        if 1 in hands and 2 in hands and 3 in hands: #  ??¨????????????????????´???
            for _ in range(5):
                print(3)
        elif hands.count(hands[0]) == 5: #  ??¨????????????????????´???
            for _ in range(5):
                print(3)
        # ??????????????????????????±???????????????
        else:
            for h in hands:
                if (h+1 in hands) or (h==3 and 1 in hands):
                    print(1)
                else:
                    print(2)


if __name__ == '__main__':
    main(sys.argv[1:])

Python: # グー:1,チョキ:2,パー:3
# 勝ち:1,負け:2,あいこ:3
datas = [0] * 5
while(1):
    try:
        lens = [0] * 3
        status = [0] * 3
        for i in range(0,5):
            datas[i] = int(input())
            lens[datas[i] - 1] += 1
        # あいこ
        if (lens[0] > 0 and lens[1] > 0 and lens[2] > 0) or (lens[0] == 5 or lens[1] == 5 or lens[2] == 5):
            for i in range(0,5):
                print(3)
        else:
            # グー
            if lens[0] > 0:
                status[1] = 2
                status[2] = 1
            # チョキ
            if lens[1] > 0:
                status[0] = 1
                status[2] = 2
            # パー
            if lens[2] > 0:
                status[0] = 2
                status[1] = 1
            for i in range(0,5):
                print(status[datas[i] - 1])
    except:
        break

C++: #include <stdio.h>

int main(void)
{
	
	int t[5], ja[3];
	int i;
	
	while (1){
		
		for (i = 0; i < 3; i++){
			ja[i] = 0;
		}
		
		for (i = 0; i < 5; i++){
			scanf("%d", &t[i]);
			if (t[i] == 0){
				break;
			}
			ja[t[i] - 1]++;
		}
		
		if (t[i] == 0){
			break;
		}
		
		
		
		if ( (ja[0] == 5 || ja[1] == 5 || ja[2] == 5) || (ja[0] > 0 && ja[1] > 0 && ja[2] > 0) ){
			for (i = 0; i < 5; i++){
				t[i] = 3;
			}
		}
		else if (ja[0] > 0 && ja[1] > 0){
			for (i = 0; i < 5; i++){
				
				if (t[i] == 1) t[i] = 1;
				
				else t[i] = 2;
			}
			
		}
		else if (ja[1] > 0 && ja[2] > 0){
			for (i = 0; i < 5; i++){
				
				if (t[i] == 2) t[i] = 1;
				
				else t[i] = 2;
			}
		}
		else{
			for (i = 0; i < 5; i++){
				
				if (t[i] == 3) t[i] = 1;
				
				else t[i] = 2;
			}
		}
		
		printf("%d\n%d\n%d\n%d\n%d\n", t[0], t[1], t[2], t[3], t[4]);
		
	}
	
	return (0);
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int h[10];
	while (cin >> h[1], h[1]) {
		cin >> h[2] >> h[3] >> h[4] >> h[5];
		int g = 0, c = 0, p = 0;
		for (int i = 1; i <= 5; i++) {
			if (h[i] == 1)g = 1;
			else if (h[i] == 2)c = 1;
			else if (h[i] == 3)p = 1;
		}
		if ((g + c + p) % 2 != 0)for (int i = 0; i < 5; i++)cout << "3\n";
		else {
			int w;
			if (g == 0)w = 2;
			else if (c == 0)w = 3;
			else if (p == 0)w = 1;
			for (int i = 1; i <= 5; i++)if (h[i] == w)cout << 1 << endl; else cout << 2 << endl;
		}
	}return 0;
}

C++: #include<iostream>
#include<set>

int main()
{
	int a[5];
	while( std::cin >> *a, *a )
	{
		std::set<int> s;
		s.insert( *a - 1 );
		for( int i = 1; i != 5; ++i )
		{
			std::cin >> a[i];
			s.insert( a[i] - 1 );
		}

		if( s.size() == 3 )
			for( int i = 0; i != 5; ++i )
				std::cout << 3 << std::endl;
		else
		{
			int win = ( ( *( ++s.begin() ) - *s.begin() + 3 ) % 3 == 1 ? *s.begin() : *( ++s.begin() ) ) + 1;
			for( int i = 0; i != 5; ++i )
				std::cout << ( a[i] == win ? 1 : 2 ) << std::endl;
		}
	}

	return 0;
}

C++: #include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <limits>
#include <sstream>

using namespace std;

int main (void)
{
	int y = 0;
	for (long u = 0; u < 200; u++)
	{
		int a[6],h1 = 0,h2 = 0,h3 = 0;

		for (int i = 0; i < 5; i++)
		{
			a[i] = 0;
		}
		for (int i = 0; i < 5; i++)
		{
			cin >> a[i];
			if (a[i] == 0)
			{
				y = -1;
				break;
			}
		}
		if (y == -1)
		{
			break;
		}

		for (int i = 0; i < 5; i++)
		{
			if (a[i] == 1)
			{
				h1 += 1;
			}
			else if (a[i] == 2)
			{
				h2 += 1;
			}
			else if (a[i] == 3)
			{
				h3 += 1;
			}
		}


		int ke = 0;
		if (h1 != 0 && h2 != 0)
		{
			if (h3 != 0)
			{
				ke += 1;
				for (int gg = 0; gg < 5; gg++)
				{
					cout << '3' << endl;
				}
			}
		}

		if (h1 == 0 && ke == 0)
		{
			for (int j = 0; j < 5; j++)
			{
				if (a[j] == 2)
				{
					cout << '1' << endl;
				}
				else
				{
					cout << '2' << endl;
				}
			}
		}
		else if (h2 == 0 && ke == 0)
		{
			for (int j = 0; j < 5; j++)
			{
				if (a[j] == 1)
				{
					cout << '2' << endl;
				}
				else
				{
					cout << '1' << endl;
				}
			}
		}
		else if (h3 == 0 && ke == 0)
		{
			for (int j = 0; j < 5; j++)
			{
				if (a[j] == 1)
				{
					cout << '1' << endl;
				}
				else
				{
					cout << '2' << endl;
				}
			}
		}
	}
}