#include <stdio.h>

#define IN_ROCK 1												/* ??\???????????°?????????							*/
#define IN_SCISSORS 2											/* ??\??????????????§?????????						*/
#define IN_PAPER 3												/* ??\?????????????????????							*/
#define OUT_WIN 1												/* ????????????									*/
#define OUT_LOSE 2												/* ????????????									*/
#define OUT_DRAW 3												/* ???????????????								*/
#define ROCK 1													/* ??°??????????????´?????????????????????				*/
#define SCISSORS 2												/* ?????§??????????????´?????????????????????				*/
#define PAPER 3													/* ?????????????????´?????????????????????				*/
#define INIT 0													/* ?????????									*/
#define PEOPLE_MAX 5											/* ?????°?????§???								*/
#define RET_OK 0												/* ??£?????????									*/
#define INF_LOOP 1												/* ???????????????								*/
#define INPUT_END 0												/* ???????????????????????????						*/
#define NO_CNT 0												/* 1????????????								*/
#define ERROR 1													/* ??¨????????\???								*/
#define RET_END 2												/* ??\??????????????\????????????						*/

unsigned char aubG_Dplayer[ PEOPLE_MAX ] = { INIT };			/* ?????°??????									*/
unsigned char ubG_Crock_cnt;									/* ??°????????????????????°							*/
unsigned char ubG_Cscissors_cnt;								/* ?????§????????????????????°						*/
unsigned char ubG_Cpaper_cnt;									/* ???????????????????????°							*/

static unsigned char Data_input( void );						/* ??????????????????????????\????????????				*/
static void Judge( void );										/* ????????¨???????????????????????????					*/
static unsigned char Call_hand( unsigned char ubW_Dno_hand );	/* ?????????????????????????????\?????????				*/
static void Vic_or_def_output( unsigned char ubW_Dwin_hand );	/* ????????????????????????????????????					*/

int main( void )
{
	unsigned char ubW_Finput_error_flag = INIT;					/* ??\?????¨????????????????????°						*/

	/* ???????????????????????????????????? */
	while( INF_LOOP ){
		ubW_Finput_error_flag = Data_input( );					/* ????????\???									*/
		/* ??\??????????????\??????????????´??? */
		if( ubW_Finput_error_flag == RET_END ){
			break;												/* ?????????????????????							*/
		}
		/* ??\?????¨???????????????????????´??? */
		else if( ubW_Finput_error_flag == ERROR ){
			printf("ERROR\n");									/* ??¨??????????????????????????\???					*/
			break;												/* ?????????????????????							*/
		}
		else{
			Judge( );											/* ???????????????								*/
		}
		ubG_Crock_cnt = INIT;									/* ??°??????????????????????????¬????????\				*/
		ubG_Cscissors_cnt = INIT;								/* ?????§??????????????????????????¬????????\				*/
		ubG_Cpaper_cnt = INIT;									/* ?????????????????????????????¬????????\				*/
	}/* ????????????????????????????????????????????? */

	return RET_OK;
}

static unsigned char Data_input( void )
{
	unsigned char ubW_Cinput_cnt;								/* ???????????????????????\??????????????¨?????°			*/

	/* ???????????????????????\???????????? */
	for( ubW_Cinput_cnt = INIT; ubW_Cinput_cnt < PEOPLE_MAX; ubW_Cinput_cnt++ ){
		scanf( "%d", &aubG_Dplayer[ ubW_Cinput_cnt ] );			/* ????????????????????\???							*/
		/* ????????????????????£????????? */
		switch( aubG_Dplayer[ ubW_Cinput_cnt ] ){
		/* ??\??????????????\??????????????´??? */
		case INPUT_END:
			return RET_END;										/* ??\????????????????????????						*/
		/* ??°????????\??????????????´??? */
		case ROCK:
			ubG_Crock_cnt++;									/* ??°???????????????????????????????????????				*/
			break;
		/* ?????§????????\??????????????´??? */
		case SCISSORS:
			ubG_Cscissors_cnt++;								/*?????§???????????????????????????????????????			*/
			break;
		/* ???????????\??????????????´??? */
		case PAPER:
			ubG_Cpaper_cnt++;									/* ??????????????????????????????????????????				*/
			break;
		/* ??\?????¨???????????????????????´??? */
		default:
			return ERROR;										/* ??\?????¨?????????????????????						*/
		}
	}
	return RET_OK;												/* ??£????????????????????????						*/
}

static void Judge( void )
{
	unsigned char ubW_Cdraw_loop_cnt;							/* ?????????????????????????????????????????¨?????°			*/

	/* ??????????????´??? */
	if( ( ubG_Crock_cnt > NO_CNT )
		&& ( ubG_Cscissors_cnt> NO_CNT ) 
		&& ( ubG_Cpaper_cnt > NO_CNT ) 
		|| ( ubG_Crock_cnt == PEOPLE_MAX ) 
		|| ( ubG_Cscissors_cnt == PEOPLE_MAX ) 
		|| ( ubG_Cpaper_cnt == PEOPLE_MAX ) ){
		/* ??????????????????????????????????????? */
		for( ubW_Cdraw_loop_cnt = INIT; ubW_Cdraw_loop_cnt < PEOPLE_MAX; ubW_Cdraw_loop_cnt++ ){
			printf( "%d\n", OUT_DRAW);							/* ??????????????????*/
		}/* ???????????????????????????????????????????????? */
	}
	else{
		/* ??°????????????????????´??? */
		if( ubG_Crock_cnt == NO_CNT ){
			Vic_or_def_output( ROCK );							/* ??°????????????????????´?????????????????????????????????	*/
		}
		else{
			/* ?????§????????????????????´??? */
			if( ubG_Cscissors_cnt == NO_CNT ){
				Vic_or_def_output( SCISSORS );					/* ?????§????????????????????´?????????????????????????????????	*/
			}
			else{
				/* ???????????????????????´??? */
				if( ubG_Cpaper_cnt == NO_CNT ){
					Vic_or_def_output( PAPER );					/* ???????????????????????´?????????????????????????????????	*/
				}
				else{
					/* else?????????????????????????????\ */
				}
			}
		}
	}
}

static unsigned char Call_hand( unsigned char ubW_Dno_hand )
{
	/* ??????????????????????????§?????? */
	switch( ubW_Dno_hand ){
	/* ??°?????????????????????????????´??? */
	case ROCK:
		return IN_SCISSORS;										/* ?????§????????????????????¨????????????				*/
	/* ?????§?????????????????????????????´??? */
	case SCISSORS:
		return IN_PAPER;										/* ???????????????????????¨????????????					*/
	/* ????????????????????????????????´??? */
	case PAPER:
		return IN_ROCK;											/* ??°????????????????????¨????????????					*/
	default:
		break;
	}
	return RET_OK;
}

static void Vic_or_def_output( unsigned char ubW_Dwin_hand )
{
	unsigned char ubW_Cvic_or_def_loop_cnt;						/* ???????????????????????¨?????°						*/

	ubW_Dwin_hand = Call_hand( ubW_Dwin_hand );					/* ??????????????????								*/
	/* ????????????????????? */
	for( ubW_Cvic_or_def_loop_cnt = INIT; ubW_Cvic_or_def_loop_cnt < PEOPLE_MAX; ubW_Cvic_or_def_loop_cnt++ ){
		/* ??\??????????????????????????? */
		if( aubG_Dplayer[ ubW_Cvic_or_def_loop_cnt ] == ubW_Dwin_hand ){
			printf( "%d\n", OUT_WIN );							/* ???????????????								*/
		}
		else{
			printf( "%d\n", OUT_LOSE );							/* ???????????????								*/
		}
	}
}

Measured memory_bytes: 600