#include <errno.h>
#include <inttypes.h>
#include <limits.h>
#include <malloc.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
typedef signed char flex_int8_t;
typedef short int flex_int16_t;
typedef int flex_int32_t;
typedef unsigned char flex_uint8_t;
typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t;
typedef struct yy_buffer_state* YY_BUFFER_STATE;
typedef size_t yy_size_t;
extern int yyleng;
extern FILE *yyin, *yyout;
struct yy_buffer_state {
FILE* yy_input_file;
char* yy_ch_buf;
char* yy_buf_pos;
int yy_buf_size;
int yy_n_chars;
int yy_is_our_buffer;
int yy_is_interactive;
int yy_at_bol;
int yy_bs_lineno;
int yy_bs_column;
int yy_fill_buffer;
int yy_buffer_status;
};
static size_t yy_buffer_stack_top = 0;
static size_t yy_buffer_stack_max = 0;
static YY_BUFFER_STATE* yy_buffer_stack = NULL;
static char yy_hold_char;
static int yy_n_chars;
int yyleng;
static char* yy_c_buf_p = NULL;
static int yy_init = 0;
static int yy_start = 0;
static int yy_did_buffer_switch_on_eof;
void yyrestart(FILE* input_file);
void yy_switch_to_buffer(YY_BUFFER_STATE new_buffer);
YY_BUFFER_STATE yy_create_buffer(FILE* file, int size);
void yy_delete_buffer(YY_BUFFER_STATE b);
void yy_flush_buffer(YY_BUFFER_STATE b);
void yypush_buffer_state(YY_BUFFER_STATE new_buffer);
void yypop_buffer_state(void);
static void yyensure_buffer_stack(void);
static void yy_load_buffer_state(void);
static void yy_init_buffer(YY_BUFFER_STATE b, FILE* file);
YY_BUFFER_STATE yy_scan_buffer(char* base, yy_size_t size);
YY_BUFFER_STATE yy_scan_string(const char* yy_str);
YY_BUFFER_STATE yy_scan_bytes(const char* bytes, int len);
void* yyalloc(yy_size_t);
void* yyrealloc(void*, yy_size_t);
void yyfree(void*);
typedef flex_uint8_t YY_CHAR;
FILE *yyin = NULL, *yyout = NULL;
typedef int yy_state_type;
extern int yylineno;
int yylineno = 1;
extern char* yytext;
static yy_state_type yy_get_previous_state(void);
static yy_state_type yy_try_NUL_trans(yy_state_type current_state);
static int yy_get_next_buffer(void);
static void yy_fatal_error(const char* msg);
struct yy_trans_info {
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
static const flex_int16_t yy_accept[11] = {0, 0, 0, 6, 5, 4, 1, 2, 5, 3, 0};
static const YY_CHAR yy_ec[256] = {
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 4, 1, 1, 1, 5, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
static const YY_CHAR yy_meta[7] = {0, 1, 1, 1, 1, 1, 2};
static const flex_int16_t yy_base[12] = {0, 0, 0, 8, 9, 9, 9, 9, 0, 9, 9, 5};
static const flex_int16_t yy_def[12] = {0, 10, 1, 10, 10, 10,
10, 10, 11, 10, 0, 10};
static const flex_int16_t yy_nxt[16] = {0, 4, 5, 6, 7, 8, 4, 9,
10, 3, 10, 10, 10, 10, 10, 10};
static const flex_int16_t yy_chk[16] = {0, 1, 1, 1, 1, 1, 1, 11,
3, 10, 10, 10, 10, 10, 10, 10};
static yy_state_type yy_last_accepting_state;
static char* yy_last_accepting_cpos;
extern int yy_flex_debug;
int yy_flex_debug = 0;
char* yytext;
void yyerror(char*);
extern int yydebug;
enum yytokentype {
YYEMPTY = -2,
YYEOF = 0,
YYerror = 256,
YYUNDEF = 257,
NEWLINE = 258,
ARROW = 259
};
typedef enum yytokentype yytoken_kind_t;
typedef int YYSTYPE;
extern YYSTYPE yylval;
int yyparse(void);
static int yy_init_globals(void);
int yylex_destroy(void);
int yyget_debug(void);
void yyset_debug(int debug_flag);
void* yyget_extra(void);
void yyset_extra(void* user_defined);
FILE* yyget_in(void);
void yyset_in(FILE* _in_str);
FILE* yyget_out(void);
void yyset_out(FILE* _out_str);
int yyget_leng(void);
char* yyget_text(void);
int yyget_lineno(void);
void yyset_lineno(int _line_number);
extern int yywrap(void);
static void yyunput(int c, char* buf_ptr);
static int input(void);
extern int yylex(void);
int yylex(void) {
yy_state_type yy_current_state;
char *yy_cp, *yy_bp;
int yy_act;
if (!(yy_init)) {
(yy_init) = 1;
if (!(yy_start)) (yy_start) = 1;
if (!yyin) yyin = stdin;
if (!yyout) yyout = stdout;
if (!((yy_buffer_stack) ? (yy_buffer_stack)[(yy_buffer_stack_top)]
: NULL)) {
yyensure_buffer_stack();
(yy_buffer_stack)[(yy_buffer_stack_top)] =
yy_create_buffer(yyin, 16384);
}
yy_load_buffer_state();
}
{
while (1) {
yy_cp = (yy_c_buf_p);
*yy_cp = (yy_hold_char);
yy_bp = yy_cp;
yy_current_state = (yy_start);
yy_match:
do {
YY_CHAR yy_c = yy_ec[((YY_CHAR)(*yy_cp))];
if (yy_accept[yy_current_state]) {
(yy_last_accepting_state) = yy_current_state;
(yy_last_accepting_cpos) = yy_cp;
}
while (yy_chk[yy_base[yy_current_state] + yy_c] !=
yy_current_state) {
yy_current_state = (int)yy_def[yy_current_state];
if (yy_current_state >= 11) yy_c = yy_meta[yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
++yy_cp;
} while (yy_base[yy_current_state] != 9);
yy_find_action:
yy_act = yy_accept[yy_current_state];
if (yy_act == 0) {
yy_cp = (yy_last_accepting_cpos);
yy_current_state = (yy_last_accepting_state);
yy_act = yy_accept[yy_current_state];
}
(yytext) = yy_bp;
yyleng = (int)(yy_cp - yy_bp);
(yy_hold_char) = *yy_cp;
*yy_cp = '\0';
(yy_c_buf_p) = yy_cp;
;
do_action:
switch (yy_act) {
case 0:
*yy_cp = (yy_hold_char);
yy_cp = (yy_last_accepting_cpos);
yy_current_state = (yy_last_accepting_state);
goto yy_find_action;
case 1:
return '(';
break;
case 2:
return ')';
break;
case 3: {
return 259;
} break;
case 4:
return 258;
break;
case 5:
do {
if (fwrite(yytext
, (size_t)yyleng
, 1, yyout
)) { }
} while (0);
break;
case (6 + 0 + 1):
return 0;
case 6: {
int yy_amount_of_matched_text = (int)(yy_cp - (yytext)) - 1;
*yy_cp = (yy_hold_char);
if ((yy_buffer_stack)[(yy_buffer_stack_top)]
->yy_buffer_status == 0) {
(yy_n_chars) = (yy_buffer_stack)[(yy_buffer_stack_top)]
->yy_n_chars;
(yy_buffer_stack)[(yy_buffer_stack_top)]
->yy_input_file = yyin;
(yy_buffer_stack)[(yy_buffer_stack_top)]
->yy_buffer_status = 1;
}
if ((yy_c_buf_p) <=
&(yy_buffer_stack)[(yy_buffer_stack_top)]
->yy_ch_buf[(yy_n_chars)]) {
yy_state_type yy_next_state;
(yy_c_buf_p) = (yytext) + yy_amount_of_matched_text;
yy_current_state = yy_get_previous_state();
yy_next_state = yy_try_NUL_trans(yy_current_state);
yy_bp = (yytext) + 0;
if (yy_next_state) {
yy_cp = ++(yy_c_buf_p);
yy_current_state = yy_next_state;
goto yy_match;
} else {
yy_cp = (yy_c_buf_p);
goto yy_find_action;
}
} else
switch (yy_get_next_buffer()) {
case 1: {
(yy_did_buffer_switch_on_eof) = 0;
if (yywrap()) {
(yy_c_buf_p) = (yytext) + 0;
yy_act = (6 + (((yy_start)-1) / 2) + 1);
goto do_action;
} else {
if (!(yy_did_buffer_switch_on_eof))
yyrestart(yyin);
}
break;
}
case 0:
(yy_c_buf_p) =
(yytext) + yy_amount_of_matched_text;
yy_current_state = yy_get_previous_state();
yy_cp = (yy_c_buf_p);
yy_bp = (yytext) + 0;
goto yy_match;
case 2:
(yy_c_buf_p) =
&(yy_buffer_stack)[(yy_buffer_stack_top)]
->yy_ch_buf[(yy_n_chars)];
yy_current_state = yy_get_previous_state();
yy_cp = (yy_c_buf_p);
yy_bp = (yytext) + 0;
goto yy_find_action;
}
break;
}
default:
yy_fatal_error(
"fatal flex scanner internal error--no action found");
}
}
}
}
static int yy_get_next_buffer(void) {
char* dest = (yy_buffer_stack)[(yy_buffer_stack_top)]->yy_ch_buf;
char* source = (yytext);
int number_to_move, i;
int ret_val;
if ((yy_c_buf_p) >
&(yy_buffer_stack)[(yy_buffer_stack_top)]->yy_ch_buf[(yy_n_chars) + 1])
yy_fatal_error(
"fatal flex scanner internal error--end of buffer missed");
if ((yy_buffer_stack)[(yy_buffer_stack_top)]->yy_fill_buffer == 0) {
if ((yy_c_buf_p) - (yytext)-0 == 1) {
return 1;
} else {
return 2;
}
}
number_to_move = (int)((yy_c_buf_p) - (yytext)-1);
for (i = 0; i < number_to_move; ++i) *(dest++) = *(source++);
if ((yy_buffer_stack)[(yy_buffer_stack_top)]->yy_buffer_status == 2)
(yy_buffer_stack)[(yy_buffer_stack_top)]->yy_n_chars = (yy_n_chars) = 0;
else {
int num_to_read =
(yy_buffer_stack)[(yy_buffer_stack_top)]->yy_buf_size -
number_to_move - 1;
while (num_to_read <= 0) {
YY_BUFFER_STATE b = (yy_buffer_stack)[(yy_buffer_stack_top)];
int yy_c_buf_p_offset = (int)((yy_c_buf_p)-b->yy_ch_buf);
if (b->yy_is_our_buffer) {
int new_size = b->yy_buf_size * 2;
if (new_size <= 0)
b->yy_buf_size += b->yy_buf_size / 8;
else
b->yy_buf_size *= 2;
b->yy_ch_buf = (char*)yyrealloc(
(void*)b->yy_ch_buf, (yy_size_t)(b->yy_buf_size + 2));
} else
b->yy_ch_buf = NULL;
if (!b->yy_ch_buf)
yy_fatal_error("fatal error - scanner input buffer overflow");
(yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
num_to_read =
(yy_buffer_stack)[(yy_buffer_stack_top)]->yy_buf_size -
number_to_move - 1;
}
if (num_to_read > 8192) num_to_read = 8192;
if ((yy_buffer_stack)[(yy_buffer_stack_top)]->yy_is_interactive) {
int c = '*';
int n;
for (n
= 0; n
< num_to_read
&& (c
= getc(yyin
)) != EOF
&& c
!= '\n'; ++n)
(&(yy_buffer_stack)[(yy_buffer_stack_top)]
->yy_ch_buf[number_to_move])[n] = (char)c;
if (c == '\n')
(&(yy_buffer_stack)[(yy_buffer_stack_top)]
->yy_ch_buf[number_to_move])[n++] = (char)c;
yy_fatal_error("input in flex scanner failed");
(yy_n_chars) = n;
} else {
errno = 0;
while (((yy_n_chars) =
(int)fread((&(yy_buffer_stack
)[(yy_buffer_stack_top
)] ->yy_ch_buf[number_to_move]),
1, (yy_size_t)num_to_read, yyin)) == 0 &&
if (errno != EINTR) {
yy_fatal_error("input in flex scanner failed");
break;
}
errno = 0;
}
};
(yy_buffer_stack)[(yy_buffer_stack_top)]->yy_n_chars = (yy_n_chars);
}
if ((yy_n_chars) == 0) {
if (number_to_move == 0) {
ret_val = 1;
yyrestart(yyin);
} else {
ret_val = 2;
(yy_buffer_stack)[(yy_buffer_stack_top)]->yy_buffer_status = 2;
}
} else
ret_val = 0;
if (((yy_n_chars) + number_to_move) >
(yy_buffer_stack)[(yy_buffer_stack_top)]->yy_buf_size) {
int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
(yy_buffer_stack)[(yy_buffer_stack_top)]->yy_ch_buf = (char*)yyrealloc(
(void*)(yy_buffer_stack)[(yy_buffer_stack_top)]->yy_ch_buf,
(yy_size_t)new_size);
if (!(yy_buffer_stack)[(yy_buffer_stack_top)]->yy_ch_buf)
yy_fatal_error("out of dynamic memory in yy_get_next_buffer()");
(yy_buffer_stack)[(yy_buffer_stack_top)]->yy_buf_size =
(int)(new_size - 2);
}
(yy_n_chars) += number_to_move;
(yy_buffer_stack)[(yy_buffer_stack_top)]->yy_ch_buf[(yy_n_chars)] = 0;
(yy_buffer_stack)[(yy_buffer_stack_top)]->yy_ch_buf[(yy_n_chars) + 1] = 0;
(yytext) = &(yy_buffer_stack)[(yy_buffer_stack_top)]->yy_ch_buf[0];
return ret_val;
}
static yy_state_type yy_get_previous_state(void) {
yy_state_type yy_current_state;
char* yy_cp;
yy_current_state = (yy_start);
for (yy_cp = (yytext) + 0; yy_cp < (yy_c_buf_p); ++yy_cp) {
YY_CHAR yy_c = (*yy_cp ? yy_ec[((YY_CHAR)(*yy_cp))] : 1);
if (yy_accept[yy_current_state]) {
(yy_last_accepting_state) = yy_current_state;
(yy_last_accepting_cpos) = yy_cp;
}
while (yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state) {
yy_current_state = (int)yy_def[yy_current_state];
if (yy_current_state >= 11) yy_c = yy_meta[yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
}
return yy_current_state;
}
static yy_state_type yy_try_NUL_trans(yy_state_type yy_current_state) {
int yy_is_jam;
char* yy_cp = (yy_c_buf_p);
YY_CHAR yy_c = 1;
if (yy_accept[yy_current_state]) {
(yy_last_accepting_state) = yy_current_state;
(yy_last_accepting_cpos) = yy_cp;
}
while (yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state) {
yy_current_state = (int)yy_def[yy_current_state];
if (yy_current_state >= 11) yy_c = yy_meta[yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
yy_is_jam = (yy_current_state == 10);
return yy_is_jam ? 0 : yy_current_state;
}
static void yyunput(int c, char* yy_bp) {
char* yy_cp;
yy_cp = (yy_c_buf_p);
*yy_cp = (yy_hold_char);
if (yy_cp < (yy_buffer_stack)[(yy_buffer_stack_top)]->yy_ch_buf + 2) {
int number_to_move = (yy_n_chars) + 2;
char* dest =
&(yy_buffer_stack)[(yy_buffer_stack_top)]->yy_ch_buf
[(yy_buffer_stack)[(yy_buffer_stack_top)]->yy_buf_size + 2];
char* source = &(yy_buffer_stack)[(yy_buffer_stack_top)]
->yy_ch_buf[number_to_move];
while (source > (yy_buffer_stack)[(yy_buffer_stack_top)]->yy_ch_buf)
*--dest = *--source;
yy_cp += (int)(dest - source);
yy_bp += (int)(dest - source);
(yy_buffer_stack)[(yy_buffer_stack_top)]->yy_n_chars = (yy_n_chars) =
(int)(yy_buffer_stack)[(yy_buffer_stack_top)]->yy_buf_size;
if (yy_cp < (yy_buffer_stack)[(yy_buffer_stack_top)]->yy_ch_buf + 2)
yy_fatal_error("flex scanner push-back overflow");
}
*--yy_cp = (char)c;
(yytext) = yy_bp;
(yy_hold_char) = *yy_cp;
(yy_c_buf_p) = yy_cp;
}
static int input(void) {
int c;
*(yy_c_buf_p) = (yy_hold_char);
if (*(yy_c_buf_p) == 0) {
if ((yy_c_buf_p) <
&(yy_buffer_stack)[(yy_buffer_stack_top)]->yy_ch_buf[(yy_n_chars)])
*(yy_c_buf_p) = '\0';
else {
int offset = (int)((yy_c_buf_p) - (yytext));
++(yy_c_buf_p);
switch (yy_get_next_buffer()) {
case 2:
yyrestart(yyin);
case 1: {
if (yywrap()) return 0;
if (!(yy_did_buffer_switch_on_eof)) yyrestart(yyin);
return input();
}
case 0:
(yy_c_buf_p) = (yytext) + offset;
break;
}
}
}
c = *(unsigned char*)(yy_c_buf_p);
*(yy_c_buf_p) = '\0';
(yy_hold_char) = *++(yy_c_buf_p);
return c;
}
void yyrestart(FILE* input_file) {
if (!((yy_buffer_stack) ? (yy_buffer_stack)[(yy_buffer_stack_top)]
: NULL)) {
yyensure_buffer_stack();
(yy_buffer_stack)[(yy_buffer_stack_top)] =
yy_create_buffer(yyin, 16384);
}
yy_init_buffer(
((yy_buffer_stack) ? (yy_buffer_stack)[(yy_buffer_stack_top)] : NULL),
input_file);
yy_load_buffer_state();
}
void yy_switch_to_buffer(YY_BUFFER_STATE new_buffer) {
yyensure_buffer_stack();
if (((yy_buffer_stack) ? (yy_buffer_stack)[(yy_buffer_stack_top)] : NULL) ==
new_buffer)
return;
if (((yy_buffer_stack) ? (yy_buffer_stack)[(yy_buffer_stack_top)] : NULL)) {
*(yy_c_buf_p) = (yy_hold_char);
(yy_buffer_stack)[(yy_buffer_stack_top)]->yy_buf_pos = (yy_c_buf_p);
(yy_buffer_stack)[(yy_buffer_stack_top)]->yy_n_chars = (yy_n_chars);
}
(yy_buffer_stack)[(yy_buffer_stack_top)] = new_buffer;
yy_load_buffer_state();
(yy_did_buffer_switch_on_eof) = 1;
}
static void yy_load_buffer_state(void) {
(yy_n_chars) = (yy_buffer_stack)[(yy_buffer_stack_top)]->yy_n_chars;
(yytext) = (yy_c_buf_p) =
(yy_buffer_stack)[(yy_buffer_stack_top)]->yy_buf_pos;
yyin = (yy_buffer_stack)[(yy_buffer_stack_top)]->yy_input_file;
(yy_hold_char) = *(yy_c_buf_p);
}
YY_BUFFER_STATE yy_create_buffer(FILE* file, int size) {
YY_BUFFER_STATE b;
b = (YY_BUFFER_STATE)yyalloc(sizeof(struct yy_buffer_state));
if (!b) yy_fatal_error("out of dynamic memory in yy_create_buffer()");
b->yy_buf_size = size;
b->yy_ch_buf = (char*)yyalloc((yy_size_t)(b->yy_buf_size + 2));
if (!b->yy_ch_buf)
yy_fatal_error("out of dynamic memory in yy_create_buffer()");
b->yy_is_our_buffer = 1;
yy_init_buffer(b, file);
return b;
}
void yy_delete_buffer(YY_BUFFER_STATE b) {
if (!b) return;
if (b ==
((yy_buffer_stack) ? (yy_buffer_stack)[(yy_buffer_stack_top)] : NULL))
(yy_buffer_stack)[(yy_buffer_stack_top)] = (YY_BUFFER_STATE)0;
if (b->yy_is_our_buffer) yyfree((void*)b->yy_ch_buf);
yyfree((void*)b);
}
static void yy_init_buffer(YY_BUFFER_STATE b, FILE* file) {
int oerrno = errno;
yy_flush_buffer(b);
b->yy_input_file = file;
b->yy_fill_buffer = 1;
if (b !=
((yy_buffer_stack) ? (yy_buffer_stack)[(yy_buffer_stack_top)] : NULL)) {
b->yy_bs_lineno = 1;
b->yy_bs_column = 0;
}
b->yy_is_interactive = file ? (isatty(fileno(file)) > 0) : 0;
errno = oerrno;
}
void yy_flush_buffer(YY_BUFFER_STATE b) {
if (!b) return;
b->yy_n_chars = 0;
b->yy_ch_buf[0] = 0;
b->yy_ch_buf[1] = 0;
b->yy_buf_pos = &b->yy_ch_buf[0];
b->yy_at_bol = 1;
b->yy_buffer_status = 0;
if (b ==
((yy_buffer_stack) ? (yy_buffer_stack)[(yy_buffer_stack_top)] : NULL))
yy_load_buffer_state();
}
void yypush_buffer_state(YY_BUFFER_STATE new_buffer) {
if (new_buffer == NULL) return;
yyensure_buffer_stack();
if (((yy_buffer_stack) ? (yy_buffer_stack)[(yy_buffer_stack_top)] : NULL)) {
*(yy_c_buf_p) = (yy_hold_char);
(yy_buffer_stack)[(yy_buffer_stack_top)]->yy_buf_pos = (yy_c_buf_p);
(yy_buffer_stack)[(yy_buffer_stack_top)]->yy_n_chars = (yy_n_chars);
}
if (((yy_buffer_stack) ? (yy_buffer_stack)[(yy_buffer_stack_top)] : NULL))
(yy_buffer_stack_top)++;
(yy_buffer_stack)[(yy_buffer_stack_top)] = new_buffer;
yy_load_buffer_state();
(yy_did_buffer_switch_on_eof) = 1;
}
void yypop_buffer_state(void) {
if (!((yy_buffer_stack) ? (yy_buffer_stack)[(yy_buffer_stack_top)] : NULL))
return;
yy_delete_buffer(
((yy_buffer_stack) ? (yy_buffer_stack)[(yy_buffer_stack_top)] : NULL));
(yy_buffer_stack)[(yy_buffer_stack_top)] = NULL;
if ((yy_buffer_stack_top) > 0) --(yy_buffer_stack_top);
if (((yy_buffer_stack) ? (yy_buffer_stack)[(yy_buffer_stack_top)] : NULL)) {
yy_load_buffer_state();
(yy_did_buffer_switch_on_eof) = 1;
}
}
static void yyensure_buffer_stack(void) {
yy_size_t num_to_alloc;
if (!(yy_buffer_stack)) {
num_to_alloc = 1;
(yy_buffer_stack) = (struct yy_buffer_state**)yyalloc(
num_to_alloc * sizeof(struct yy_buffer_state*));
if (!(yy_buffer_stack))
yy_fatal_error("out of dynamic memory in yyensure_buffer_stack()");
num_to_alloc * sizeof(struct yy_buffer_state*));
(yy_buffer_stack_max) = num_to_alloc;
(yy_buffer_stack_top) = 0;
return;
}
if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1) {
yy_size_t grow_size = 8;
num_to_alloc = (yy_buffer_stack_max) + grow_size;
(yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc(
(yy_buffer_stack), num_to_alloc * sizeof(struct yy_buffer_state*));
if (!(yy_buffer_stack))
yy_fatal_error("out of dynamic memory in yyensure_buffer_stack()");
memset((yy_buffer_stack
) + (yy_buffer_stack_max
), 0, grow_size * sizeof(struct yy_buffer_state*));
(yy_buffer_stack_max) = num_to_alloc;
}
}
YY_BUFFER_STATE yy_scan_buffer(char* base, yy_size_t size) {
YY_BUFFER_STATE b;
if (size < 2 || base[size - 2] != 0 || base[size - 1] != 0) return NULL;
b = (YY_BUFFER_STATE)yyalloc(sizeof(struct yy_buffer_state));
if (!b) yy_fatal_error("out of dynamic memory in yy_scan_buffer()");
b->yy_buf_size = (int)(size - 2);
b->yy_buf_pos = b->yy_ch_buf = base;
b->yy_is_our_buffer = 0;
b->yy_input_file = NULL;
b->yy_n_chars = b->yy_buf_size;
b->yy_is_interactive = 0;
b->yy_at_bol = 1;
b->yy_fill_buffer = 0;
b->yy_buffer_status = 0;
yy_switch_to_buffer(b);
return b;
}
YY_BUFFER_STATE yy_scan_string(const char* yystr) {
return yy_scan_bytes
(yystr
, (int)strlen(yystr
)); }
YY_BUFFER_STATE yy_scan_bytes(const char* yybytes, int _yybytes_len) {
YY_BUFFER_STATE b;
char* buf;
yy_size_t n;
int i;
n = (yy_size_t)(_yybytes_len + 2);
buf = (char*)yyalloc(n);
if (!buf) yy_fatal_error("out of dynamic memory in yy_scan_bytes()");
for (i = 0; i < _yybytes_len; ++i) buf[i] = yybytes[i];
buf[_yybytes_len] = buf[_yybytes_len + 1] = 0;
b = yy_scan_buffer(buf, n);
if (!b) yy_fatal_error("bad buffer in yy_scan_bytes()");
b->yy_is_our_buffer = 1;
return b;
}
static void yy_fatal_error(const char* msg) {
}
int yyget_lineno(void) {
return yylineno;
}
FILE* yyget_in(void) {
return yyin;
}
FILE* yyget_out(void) {
return yyout;
}
int yyget_leng(void) {
return yyleng;
}
char* yyget_text(void) {
return yytext;
}
void yyset_lineno(int _line_number) {
yylineno = _line_number;
}
void yyset_in(FILE* _in_str) {
yyin = _in_str;
}
void yyset_out(FILE* _out_str) {
yyout = _out_str;
}
int yyget_debug(void) {
return yy_flex_debug;
}
void yyset_debug(int _bdebug) {
yy_flex_debug = _bdebug;
}
static int yy_init_globals(void) {
(yy_buffer_stack) = NULL;
(yy_buffer_stack_top) = 0;
(yy_buffer_stack_max) = 0;
(yy_c_buf_p) = NULL;
(yy_init) = 0;
(yy_start) = 0;
yyin = NULL;
yyout = NULL;
return 0;
}
int yylex_destroy(void) {
while (
((yy_buffer_stack) ? (yy_buffer_stack)[(yy_buffer_stack_top)] : NULL)) {
yy_delete_buffer(((yy_buffer_stack)
? (yy_buffer_stack)[(yy_buffer_stack_top)]
: NULL));
(yy_buffer_stack)[(yy_buffer_stack_top)] = NULL;
yypop_buffer_state();
}
yyfree((yy_buffer_stack));
(yy_buffer_stack) = NULL;
yy_init_globals();
return 0;
}
void* yyalloc(yy_size_t size) {
}
void* yyrealloc(void* ptr, yy_size_t size) {
}
void yyfree(void* ptr) {
}
int yywrap(void) {
return 1;
}
int yylex(void);
void yyerror(char*);
int MAX(int a, int b) {
if (a < b) return b;
return a;
}
enum yysymbol_kind_t {
YYSYMBOL_YYEMPTY = -2,
YYSYMBOL_YYEOF = 0,
YYSYMBOL_YYerror = 1,
YYSYMBOL_YYUNDEF = 2,
YYSYMBOL_NEWLINE = 3,
YYSYMBOL_ARROW = 4,
YYSYMBOL_5_ = 5,
YYSYMBOL_6_ = 6,
YYSYMBOL_YYACCEPT = 7,
YYSYMBOL_program = 8,
YYSYMBOL_expr = 9
};
typedef enum yysymbol_kind_t yysymbol_kind_t;
typedef signed char yytype_int8;
typedef short yytype_int16;
typedef unsigned char yytype_uint8;
typedef unsigned short yytype_uint16;
typedef yytype_int8 yy_state_t;
typedef int yy_state_fast_t;
union yyalloc {
yy_state_t yyss_alloc;
YYSTYPE yyvs_alloc;
};
static const yytype_int8 yytranslate[] = {
0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 5, 6, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4};
static const yytype_int8 yyrline[] = {0, 16, 16, 21, 25, 29};
static const char* yysymbol_name(yysymbol_kind_t yysymbol);
static const char* const yytname[] = {"\"end of file\"",
"error",
"\"invalid token\"",
"NEWLINE",
"ARROW",
"'('",
"')'",
"$accept",
"program",
"expr",
((void*)0)};
static const char* yysymbol_name(yysymbol_kind_t yysymbol) {
return yytname[yysymbol];
}
static const yytype_int8 yypact[] = {6, 0, 2, 5, -4, -3, -4, -4, 6, -4, 8};
static const yytype_int8 yydefact[] = {0, 0, 0, 0, 3, 0, 1, 2, 0, 4, 5};
static const yytype_int8 yypgoto[] = {-4, -4, -1};
static const yytype_int8 yydefgoto[] = {0, 2, 3};
static const yytype_int8 yytable[] = {5, 8, 6, 9, 0, 1, 4, 10, 7, 8, 0, 1, 8};
static const yytype_int8 yycheck[] = {1, 4, 0, 6, -1, 5, 6, 8, 3, 4, -1, 5, 4};
static const yytype_int8 yystos[] = {0, 5, 8, 9, 6, 9, 0, 3, 4, 6, 9};
static const yytype_int8 yyr1[] = {0, 7, 8, 9, 9, 9};
static const yytype_int8 yyr2[] = {0, 2, 2, 2, 3, 3};
enum { YYENOMEM = -2 };
static void yy_symbol_value_print(FILE* yyo, yysymbol_kind_t yykind,
YYSTYPE const* const yyvaluep) {
FILE* yyoutput = yyo;
((void)(yyoutput));
if (!yyvaluep) return;
((void)(yykind));
}
static void yy_symbol_print(FILE* yyo, yysymbol_kind_t yykind,
YYSTYPE const* const yyvaluep) {
fprintf(yyo
, "%s %s (", yykind
< 7 ? "token" : "nterm", yysymbol_name(yykind));
yy_symbol_value_print(yyo, yykind, yyvaluep);
}
static void yy_stack_print(yy_state_t* yybottom, yy_state_t* yytop) {
for (; yybottom <= yytop; yybottom++) {
int yybot = *yybottom;
}
}
static void yy_reduce_print(yy_state_t* yyssp, YYSTYPE* yyvsp, int yyrule) {
int yylno = yyrline[yyrule];
int yynrhs = yyr2[yyrule];
int yyi;
fprintf(stderr
, "Reducing stack by rule %d (line %d):\n", yyrule
- 1, yylno);
for (yyi = 0; yyi < yynrhs; yyi++) {
fprintf(stderr
, " $%d = ", yyi
+ 1); yy_symbol_print(stderr,
((yysymbol_kind_t)(yystos[+yyssp[yyi + 1 - yynrhs]])),
&yyvsp[(yyi + 1) - (yynrhs)]);
}
}
int yydebug;
static void yydestruct(const char* yymsg, yysymbol_kind_t yykind,
YYSTYPE* yyvaluep) {
((void)(yyvaluep));
if (!yymsg) yymsg = "Deleting";
do {
if (yydebug) {
yy_symbol_print(stderr, yykind, yyvaluep);
}
} while (0);
((void)(yykind));
}
int yychar;
YYSTYPE yylval;
int yynerrs;
int yyparse(void) {
yy_state_fast_t yystate = 0;
int yyerrstatus = 0;
long yystacksize = 200;
yy_state_t yyssa[200];
yy_state_t* yyss = yyssa;
yy_state_t* yyssp = yyss;
YYSTYPE yyvsa[200];
YYSTYPE* yyvs = yyvsa;
YYSTYPE* yyvsp = yyvs;
int yyn;
int yyresult;
yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY;
YYSTYPE yyval;
int yylen = 0;
do {
if (yydebug
) fprintf(stderr
, "Starting parse\n"); } while (0);
yychar = -2;
goto yysetstate;
yynewstate:
yyssp++;
yysetstate:
do {
if (yydebug
) fprintf(stderr
, "Entering state %d\n", yystate
); } while (0);
((void)(0 && (0 <= yystate && yystate < 11)));
*yyssp = ((yy_state_t)(yystate));
do {
if (yydebug) yy_stack_print((yyss), (yyssp));
} while (0);
if (yyss + yystacksize - 1 <= yyssp) {
long yysize = yyssp - yyss + 1;
if (10000 <= yystacksize) goto yyexhaustedlab;
yystacksize *= 2;
if (10000 < yystacksize) yystacksize = 10000;
{
yy_state_t* yyss1 = yyss;
union yyalloc
* yyptr
= ((union yyalloc
*)(malloc( ((unsigned)(((yystacksize) * (((long)(sizeof(yy_state_t))) +
((long)(sizeof(YYSTYPE)))) +
(((long)(sizeof(union yyalloc))) - 1)))))));
if (!yyptr) goto yyexhaustedlab;
do {
long yynewbytes;
do {
long yyi;
for (yyi = 0; yyi < (yysize); yyi++)
(&yyptr->yyss_alloc)[yyi] = (yyss)[yyi];
} while (0);
yyss = &yyptr->yyss_alloc;
yynewbytes = yystacksize * ((long)(sizeof(*yyss))) +
(((long)(sizeof(union yyalloc))) - 1);
yyptr += yynewbytes / ((long)(sizeof(*yyptr)));
} while (0);
do {
long yynewbytes;
do {
long yyi;
for (yyi = 0; yyi < (yysize); yyi++)
(&yyptr->yyvs_alloc)[yyi] = (yyvs)[yyi];
} while (0);
yyvs = &yyptr->yyvs_alloc;
yynewbytes = yystacksize * ((long)(sizeof(*yyvs))) +
(((long)(sizeof(union yyalloc))) - 1);
yyptr += yynewbytes / ((long)(sizeof(*yyptr)));
} while (0);
if (yyss1
!= yyssa
) free(yyss1
); }
yyssp = yyss + yysize - 1;
yyvsp = yyvs + yysize - 1;
do {
if (yydebug)
fprintf(stderr
, "Stack size increased to %ld\n", ((long)(yystacksize)));
} while (0);
if (yyss + yystacksize - 1 <= yyssp) goto yyabortlab;
}
if (yystate == 6) goto yyacceptlab;
goto yybackup;
yybackup:
yyn = yypact[yystate];
if (((yyn) == (-4))) goto yydefault;
if (yychar == -2) {
do {
if (yydebug
) fprintf(stderr
, "Reading a token\n"); } while (0);
yychar = yylex();
}
if (yychar <= 0) {
yychar = 0;
yytoken = YYSYMBOL_YYEOF;
do {
if (yydebug
) fprintf(stderr
, "Now at end of input.\n"); } while (0);
} else if (yychar == 256) {
yychar = 257;
yytoken = YYSYMBOL_YYerror;
goto yyerrlab1;
} else {
yytoken = (0 <= (yychar) && (yychar) <= 259
? ((yysymbol_kind_t)(yytranslate[yychar]))
: YYSYMBOL_YYUNDEF);
do {
if (yydebug) {
fprintf(stderr
, "%s ", "Next token is"); yy_symbol_print(stderr, yytoken, &yylval);
}
} while (0);
}
yyn += yytoken;
if (yyn < 0 || 12 < yyn || yycheck[yyn] != yytoken) goto yydefault;
yyn = yytable[yyn];
if (yyn <= 0) {
if (0) goto yyerrlab;
yyn = -yyn;
goto yyreduce;
}
if (yyerrstatus) yyerrstatus--;
do {
if (yydebug) {
fprintf(stderr
, "%s ", "Shifting"); yy_symbol_print(stderr, yytoken, &yylval);
}
} while (0);
yystate = yyn;
*++yyvsp = yylval;
yychar = -2;
goto yynewstate;
yydefault:
yyn = yydefact[yystate];
if (yyn == 0) goto yyerrlab;
goto yyreduce;
yyreduce:
yylen = yyr2[yyn];
yyval = yyvsp[1 - yylen];
do {
if (yydebug) yy_reduce_print(yyssp, yyvsp, yyn);
} while (0);
switch (yyn) {
case 2: {
return yyval;
} break;
case 3: {
yyval = 0;
} break;
case 4: {
yyval = yyvsp[-1];
} break;
case 5: {
yyval = MAX(yyvsp[-2] + 1, yyvsp[0]);
} break;
default:
break;
}
do {
if (yydebug) {
yy_symbol_print(stderr, ((yysymbol_kind_t)(yyr1[yyn])), &yyval);
}
} while (0);
(yyvsp -= (yylen), yyssp -= (yylen));
yylen = 0;
*++yyvsp = yyval;
{
const int yylhs = yyr1[yyn] - 7;
const int yyi = yypgoto[yylhs] + *yyssp;
yystate = (0 <= yyi && yyi <= 12 && yycheck[yyi] == *yyssp
? yytable[yyi]
: yydefgoto[yylhs]);
}
goto yynewstate;
yyerrlab:
yytoken = yychar == -2 ? YYSYMBOL_YYEMPTY
: (0 <= (yychar) && (yychar) <= 259
? ((yysymbol_kind_t)(yytranslate[yychar]))
: YYSYMBOL_YYUNDEF);
if (!yyerrstatus) {
++yynerrs;
yyerror("syntax error");
}
if (yyerrstatus == 3) {
if (yychar <= 0) {
if (yychar == 0) goto yyabortlab;
} else {
yydestruct("Error: discarding", yytoken, &yylval);
yychar = -2;
}
}
goto yyerrlab1;
yyerrorlab:
if (0) goto yyerrorlab;
++yynerrs;
(yyvsp -= (yylen), yyssp -= (yylen));
yylen = 0;
do {
if (yydebug) yy_stack_print((yyss), (yyssp));
} while (0);
yystate = *yyssp;
goto yyerrlab1;
yyerrlab1:
yyerrstatus = 3;
for (;;) {
yyn = yypact[yystate];
if (!((yyn) == (-4))) {
yyn += YYSYMBOL_YYerror;
if (0 <= yyn && yyn <= 12 && yycheck[yyn] == YYSYMBOL_YYerror) {
yyn = yytable[yyn];
if (0 < yyn) break;
}
}
if (yyssp == yyss) goto yyabortlab;
yydestruct("Error: popping", ((yysymbol_kind_t)(yystos[yystate])),
yyvsp);
(yyvsp -= (1), yyssp -= (1));
yystate = *yyssp;
do {
if (yydebug) yy_stack_print((yyss), (yyssp));
} while (0);
}
*++yyvsp = yylval;
do {
if (yydebug) {
fprintf(stderr
, "%s ", "Shifting"); yy_symbol_print(stderr, ((yysymbol_kind_t)(yystos[yyn])), yyvsp);
}
} while (0);
yystate = yyn;
goto yynewstate;
yyacceptlab:
yyresult = 0;
goto yyreturnlab;
yyabortlab:
yyresult = 1;
goto yyreturnlab;
yyexhaustedlab:
yyerror("memory exhausted");
yyresult = 2;
goto yyreturnlab;
yyreturnlab:
if (yychar != -2) {
yytoken = (0 <= (yychar) && (yychar) <= 259
? ((yysymbol_kind_t)(yytranslate[yychar]))
: YYSYMBOL_YYUNDEF);
yydestruct("Cleanup: discarding lookahead", yytoken, &yylval);
}
(yyvsp -= (yylen), yyssp -= (yylen));
do {
if (yydebug) yy_stack_print((yyss), (yyssp));
} while (0);
while (yyssp != yyss) {
yydestruct("Cleanup: popping", ((yysymbol_kind_t)(yystos[+*yyssp])),
yyvsp);
(yyvsp -= (1), yyssp -= (1));
}
if (yyss
!= yyssa
) free(yyss
); return yyresult;
}
void yyerror(char* s) {
}
int main(void)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AxOwogICAgICAgIGlmICghKHl5X3N0YXJ0KSkgKHl5X3N0YXJ0KSA9IDE7CiAgICAgICAgaWYgKCF5eWluKSB5eWluID0gc3RkaW47CiAgICAgICAgaWYgKCF5eW91dCkgeXlvdXQgPSBzdGRvdXQ7CiAgICAgICAgaWYgKCEoKHl5X2J1ZmZlcl9zdGFjaykgPyAoeXlfYnVmZmVyX3N0YWNrKVsoeXlfYnVmZmVyX3N0YWNrX3RvcCldCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOiBOVUxMKSkgewogICAgICAgICAgICB5eWVuc3VyZV9idWZmZXJfc3RhY2soKTsKICAgICAgICAgICAgKHl5X2J1ZmZlcl9zdGFjaylbKHl5X2J1ZmZlcl9zdGFja190b3ApXSA9CiAgICAgICAgICAgICAgICB5eV9jcmVhdGVfYnVmZmVyKHl5aW4sIDE2Mzg0KTsKICAgICAgICB9CiAgICAgICAgeXlfbG9hZF9idWZmZXJfc3RhdGUoKTsKICAgIH0KICAgIHsKICAgICAgICB3aGlsZSAoMSkgewogICAgICAgICAgICB5eV9jcCA9ICh5eV9jX2J1Zl9wKTsKICAgICAgICAgICAgKnl5X2NwID0gKHl5X2hvbGRfY2hhcik7CiAgICAgICAgICAgIHl5X2JwID0geXlfY3A7CiAgICAgICAgICAgIHl5X2N1cnJlbnRfc3RhdGUgPSAoeXlfc3RhcnQpOwogICAgICAgIHl5X21hdGNoOgogICAgICAgICAgICBkbyB7CiAgICAgICAgICAgICAgICBZWV9DSEFSIHl5X2MgPSB5eV9lY1soKFlZX0NIQVIpKCp5eV9jcCkpXTsKICAgICAgICAgICAgICAgIGlmICh5eV9hY2NlcHRbeXlfY3VycmVudF9zdGF0ZV0pIHsKICAgICAgICAgICAgICAgICAgICAoeXlfbGFzdF9hY2NlcHRpbmdfc3RhdGUpID0geXlfY3VycmVudF9zdGF0ZTsKICAgICAgICAgICAgICAgICAgICAoeXlfbGFzdF9hY2NlcHRpbmdfY3BvcykgPSB5eV9jcDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHdoaWxlICh5eV9jaGtbeXlfYmFzZVt5eV9jdXJyZW50X3N0YXRlXSArIHl5X2NdICE9CiAgICAgICAgICAgICAgICAgICAgICAgeXlfY3VycmVudF9zdGF0ZSkgewogICAgICAgICAgICAgICAgICAgIHl5X2N1cnJlbnRfc3RhdGUgPSAoaW50KXl5X2RlZlt5eV9jdXJyZW50X3N0YXRlXTsKICAgICAgICAgICAgICAgICAgICBpZiAoeXlfY3VycmVudF9zdGF0ZSA+PSAxMSkgeXlfYyA9IHl5X21ldGFbeXlfY107CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB5eV9jdXJyZW50X3N0YXRlID0geXlfbnh0W3l5X2Jhc2VbeXlfY3VycmVudF9zdGF0ZV0gKyB5eV9jXTsKICAgICAgICAgICAgICAgICsreXlfY3A7CiAgICAgICAgICAgIH0gd2hpbGUgKHl5X2Jhc2VbeXlfY3VycmVudF9zdGF0ZV0gIT0gOSk7CiAgICAgICAgeXlfZmluZF9hY3Rpb246CiAgICAgICAgICAgIHl5X2FjdCA9IHl5X2FjY2VwdFt5eV9jdXJyZW50X3N0YXRlXTsKICAgICAgICAgICAgaWYgKHl5X2FjdCA9PSAwKSB7CiAgICAgICAgICAgICAgICB5eV9jcCA9ICh5eV9sYXN0X2FjY2VwdGluZ19jcG9zKTsKICAgICAgICAgICAgICAgIHl5X2N1cnJlbnRfc3RhdGUgPSAoeXlfbGFzdF9hY2NlcHRpbmdfc3RhdGUpOwogICAgICAgICAgICAgICAgeXlfYWN0ID0geXlfYWNjZXB0W3l5X2N1cnJlbnRfc3RhdGVdOwogICAgICAgICAgICB9CiAgICAgICAgICAgICh5eXRleHQpID0geXlfYnA7CiAgICAgICAgICAgIHl5bGVuZyA9IChpbnQpKHl5X2NwIC0geXlfYnApOwogICAgICAgICAgICAoeXlfaG9sZF9jaGFyKSA9ICp5eV9jcDsKICAgICAgICAgICAgKnl5X2NwID0gJ1wwJzsKICAgICAgICAgICAgKHl5X2NfYnVmX3ApID0geXlfY3A7CiAgICAgICAgICAgIDsKICAgICAgICBkb19hY3Rpb246CiAgICAgICAgICAgIHN3aXRjaCAoeXlfYWN0KSB7CiAgICAgICAgICAgICAgICBjYXNlIDA6CiAgICAgICAgICAgICAgICAgICAgKnl5X2NwID0gKHl5X2hvbGRfY2hhcik7CiAgICAgICAgICAgICAgICAgICAgeXlfY3AgPSAoeXlfbGFzdF9hY2NlcHRpbmdfY3Bvcyk7CiAgICAgICAgICAgICAgICAgICAgeXlfY3VycmVudF9zdGF0ZSA9ICh5eV9sYXN0X2FjY2VwdGluZ19zdGF0ZSk7CiAgICAgICAgICAgICAgICAgICAgZ290byB5eV9maW5kX2FjdGlvbjsKICAgICAgICAgICAgICAgIGNhc2UgMToKICAgICAgICAgICAgICAgICAgICByZXR1cm4gJygnOwogICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICAgICAgICAgIHJldHVybiAnKSc7CiAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICBjYXNlIDM6IHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gMjU5OwogICAgICAgICAgICAgICAgfSBicmVhazsKICAgICAgICAgICAgICAgIGNhc2UgNDoKICAgICAgICAgICAgICAgICAgICByZXR1cm4gMjU4OwogICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgY2FzZSA1OgogICAgICAgICAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZ3cml0ZSh5eXRleHQsIChzaXplX3QpeXlsZW5nLCAxLCB5eW91dCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0gd2hpbGUgKDApOwogICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgY2FzZSAoNiArIDAgKyAxKToKICAgICAgICAgICAgICAgICAgICByZXR1cm4gMDsKICAgICAgICAgICAgICAgIGNhc2UgNjogewogICAgICAgICAgICAgICAgICAgIGludCB5eV9hbW91bnRfb2ZfbWF0Y2hlZF90ZXh0ID0gKGludCkoeXlfY3AgLSAoeXl0ZXh0KSkgLSAxOwogICAgICAgICAgICAgICAgICAgICp5eV9jcCA9ICh5eV9ob2xkX2NoYXIpOwogICAgICAgICAgICAgICAgICAgIGlmICgoeXlfYnVmZmVyX3N0YWNrKVsoeXlfYnVmZmVyX3N0YWNrX3RvcCldCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAtPnl5X2J1ZmZlcl9zdGF0dXMgPT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAoeXlfbl9jaGFycykgPSAoeXlfYnVmZmVyX3N0YWNrKVsoeXlfYnVmZmVyX3N0YWNrX3RvcCldCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAtPnl5X25fY2hhcnM7CiAgICAgICAgICAgICAgICAgICAgICAgICh5eV9idWZmZXJfc3RhY2spWyh5eV9idWZmZXJfc3RhY2tfdG9wKV0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0+eXlfaW5wdXRfZmlsZSA9IHl5aW47CiAgICAgICAgICAgICAgICAgICAgICAgICh5eV9idWZmZXJfc3RhY2spWyh5eV9idWZmZXJfc3RhY2tfdG9wKV0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0+eXlfYnVmZmVyX3N0YXR1cyA9IDE7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICgoeXlfY19idWZfcCkgPD0KICAgICAgICAgICAgICAgICAgICAgICAgJih5eV9idWZmZXJfc3RhY2spWyh5eV9idWZmZXJfc3RhY2tfdG9wKV0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAtPnl5X2NoX2J1ZlsoeXlfbl9jaGFycyldKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHl5X3N0YXRlX3R5cGUgeXlfbmV4dF9zdGF0ZTsKICAgICAgICAgICAgICAgICAgICAgICAgKHl5X2NfYnVmX3ApID0gKHl5dGV4dCkgKyB5eV9hbW91bnRfb2ZfbWF0Y2hlZF90ZXh0OwogICAgICAgICAgICAgICAgICAgICAgICB5eV9jdXJyZW50X3N0YXRlID0geXlfZ2V0X3ByZXZpb3VzX3N0YXRlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHl5X25leHRfc3RhdGUgPSB5eV90cnlfTlVMX3RyYW5zKHl5X2N1cnJlbnRfc3RhdGUpOwogICAgICAgICAgICAgICAgICAgICAgICB5eV9icCA9ICh5eXRleHQpICsgMDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHl5X25leHRfc3RhdGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHl5X2NwID0gKysoeXlfY19idWZfcCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB5eV9jdXJyZW50X3N0YXRlID0geXlfbmV4dF9zdGF0ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdvdG8geXlfbWF0Y2g7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB5eV9jcCA9ICh5eV9jX2J1Zl9wKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdvdG8geXlfZmluZF9hY3Rpb247CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9IGVsc2UKICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoICh5eV9nZXRfbmV4dF9idWZmZXIoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAxOiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKHl5X2RpZF9idWZmZXJfc3dpdGNoX29uX2VvZikgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh5eXdyYXAoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoeXlfY19idWZfcCkgPSAoeXl0ZXh0KSArIDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHl5X2FjdCA9ICg2ICsgKCgoeXlfc3RhcnQpLTEpIC8gMikgKyAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ290byBkb19hY3Rpb247CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCEoeXlfZGlkX2J1ZmZlcl9zd2l0Y2hfb25fZW9mKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHl5cmVzdGFydCh5eWluKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKHl5X2NfYnVmX3ApID0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKHl5dGV4dCkgKyB5eV9hbW91bnRfb2ZfbWF0Y2hlZF90ZXh0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHl5X2N1cnJlbnRfc3RhdGUgPSB5eV9nZXRfcHJldmlvdXNfc3RhdGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB5eV9jcCA9ICh5eV9jX2J1Zl9wKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB5eV9icCA9ICh5eXRleHQpICsgMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBnb3RvIHl5X21hdGNoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICh5eV9jX2J1Zl9wKSA9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICYoeXlfYnVmZmVyX3N0YWNrKVsoeXlfYnVmZmVyX3N0YWNrX3RvcCldCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLT55eV9jaF9idWZbKHl5X25fY2hhcnMpXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB5eV9jdXJyZW50X3N0YXRlID0geXlfZ2V0X3ByZXZpb3VzX3N0YXRlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeXlfY3AgPSAoeXlfY19idWZfcCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeXlfYnAgPSAoeXl0ZXh0KSArIDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ290byB5eV9maW5kX2FjdGlvbjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICB5eV9mYXRhbF9lcnJvcigKICAgICAgICAgICAgICAgICAgICAgICAgImZhdGFsIGZsZXggc2Nhbm5lciBpbnRlcm5hbCBlcnJvci0tbm8gYWN0aW9uIGZvdW5kIik7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9Cn0Kc3RhdGljIGludCB5eV9nZXRfbmV4dF9idWZmZXIodm9pZCkgewogICAgY2hhciogZGVzdCA9ICh5eV9idWZmZXJfc3RhY2spWyh5eV9idWZmZXJfc3RhY2tfdG9wKV0tPnl5X2NoX2J1ZjsKICAgIGNoYXIqIHNvdXJjZSA9ICh5eXRleHQpOwogICAgaW50IG51bWJlcl90b19tb3ZlLCBpOwogICAgaW50IHJldF92YWw7CiAgICBpZiAoKHl5X2NfYnVmX3ApID4KICAgICAgICAmKHl5X2J1ZmZlcl9zdGFjaylbKHl5X2J1ZmZlcl9zdGFja190b3ApXS0+eXlfY2hfYnVmWyh5eV9uX2NoYXJzKSArIDFdKQogICAgICAgIHl5X2ZhdGFsX2Vycm9yKAogICAgICAgICAgICAiZmF0YWwgZmxleCBzY2FubmVyIGludGVybmFsIGVycm9yLS1lbmQgb2YgYnVmZmVyIG1pc3NlZCIpOwogICAgaWYgKCh5eV9idWZmZXJfc3RhY2spWyh5eV9idWZmZXJfc3RhY2tfdG9wKV0tPnl5X2ZpbGxfYnVmZmVyID09IDApIHsKICAgICAgICBpZiAoKHl5X2NfYnVmX3ApIC0gKHl5dGV4dCktMCA9PSAxKSB7CiAgICAgICAgICAgIHJldHVybiAxOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHJldHVybiAyOwogICAgICAgIH0KICAgIH0KICAgIG51bWJlcl90b19tb3ZlID0gKGludCkoKHl5X2NfYnVmX3ApIC0gKHl5dGV4dCktMSk7CiAgICBmb3IgKGkgPSAwOyBpIDwgbnVtYmVyX3RvX21vdmU7ICsraSkgKihkZXN0KyspID0gKihzb3VyY2UrKyk7CiAgICBpZiAoKHl5X2J1ZmZlcl9zdGFjaylbKHl5X2J1ZmZlcl9zdGFja190b3ApXS0+eXlfYnVmZmVyX3N0YXR1cyA9PSAyKQogICAgICAgICh5eV9idWZmZXJfc3RhY2spWyh5eV9idWZmZXJfc3RhY2tfdG9wKV0tPnl5X25fY2hhcnMgPSAoeXlfbl9jaGFycykgPSAwOwogICAgZWxzZSB7CiAgICAgICAgaW50IG51bV90b19yZWFkID0KICAgICAgICAgICAgKHl5X2J1ZmZlcl9zdGFjaylbKHl5X2J1ZmZlcl9zdGFja190b3ApXS0+eXlfYnVmX3NpemUgLQogICAgICAgICAgICBudW1iZXJfdG9fbW92ZSAtIDE7CiAgICAgICAgd2hpbGUgKG51bV90b19yZWFkIDw9IDApIHsKICAgICAgICAgICAgWVlfQlVGRkVSX1NUQVRFIGIgPSAoeXlfYnVmZmVyX3N0YWNrKVsoeXlfYnVmZmVyX3N0YWNrX3RvcCldOwogICAgICAgICAgICBpbnQgeXlfY19idWZfcF9vZmZzZXQgPSAoaW50KSgoeXlfY19idWZfcCktYi0+eXlfY2hfYnVmKTsKICAgICAgICAgICAgaWYgKGItPnl5X2lzX291cl9idWZmZXIpIHsKICAgICAgICAgICAgICAgIGludCBuZXdfc2l6ZSA9IGItPnl5X2J1Zl9zaXplICogMjsKICAgICAgICAgICAgICAgIGlmIChuZXdfc2l6ZSA8PSAwKQogICAgICAgICAgICAgICAgICAgIGItPnl5X2J1Zl9zaXplICs9IGItPnl5X2J1Zl9zaXplIC8gODsKICAgICAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgICAgICAgICBiLT55eV9idWZfc2l6ZSAqPSAyOwogICAgICAgICAgICAgICAgYi0+eXlfY2hfYnVmID0gKGNoYXIqKXl5cmVhbGxvYygKICAgICAgICAgICAgICAgICAgICAodm9pZCopYi0+eXlfY2hfYnVmLCAoeXlfc2l6ZV90KShiLT55eV9idWZfc2l6ZSArIDIpKTsKICAgICAgICAgICAgfSBlbHNlCiAgICAgICAgICAgICAgICBiLT55eV9jaF9idWYgPSBOVUxMOwogICAgICAgICAgICBpZiAoIWItPnl5X2NoX2J1ZikKICAgICAgICAgICAgICAgIHl5X2ZhdGFsX2Vycm9yKCJmYXRhbCBlcnJvciAtIHNjYW5uZXIgaW5wdXQgYnVmZmVyIG92ZXJmbG93Iik7CiAgICAgICAgICAgICh5eV9jX2J1Zl9wKSA9ICZiLT55eV9jaF9idWZbeXlfY19idWZfcF9vZmZzZXRdOwogICAgICAgICAgICBudW1fdG9fcmVhZCA9CiAgICAgICAgICAgICAgICAoeXlfYnVmZmVyX3N0YWNrKVsoeXlfYnVmZmVyX3N0YWNrX3RvcCldLT55eV9idWZfc2l6ZSAtCiAgICAgICAgICAgICAgICBudW1iZXJfdG9fbW92ZSAtIDE7CiAgICAgICAgfQogICAgICAgIGlmIChudW1fdG9fcmVhZCA+IDgxOTIpIG51bV90b19yZWFkID0gODE5MjsKICAgICAgICBpZiAoKHl5X2J1ZmZlcl9zdGFjaylbKHl5X2J1ZmZlcl9zdGFja190b3ApXS0+eXlfaXNfaW50ZXJhY3RpdmUpIHsKICAgICAgICAgICAgaW50IGMgPSAnKic7CiAgICAgICAgICAgIGludCBuOwogICAgICAgICAgICBmb3IgKG4gPSAwOyBuIDwgbnVtX3RvX3JlYWQgJiYgKGMgPSBnZXRjKHl5aW4pKSAhPSBFT0YgJiYgYyAhPSAnXG4nOwogICAgICAgICAgICAgICAgICsrbikKICAgICAgICAgICAgICAgICgmKHl5X2J1ZmZlcl9zdGFjaylbKHl5X2J1ZmZlcl9zdGFja190b3ApXQogICAgICAgICAgICAgICAgICAgICAgLT55eV9jaF9idWZbbnVtYmVyX3RvX21vdmVdKVtuXSA9IChjaGFyKWM7CiAgICAgICAgICAgIGlmIChjID09ICdcbicpCiAgICAgICAgICAgICAgICAoJih5eV9idWZmZXJfc3RhY2spWyh5eV9idWZmZXJfc3RhY2tfdG9wKV0KICAgICAgICAgICAgICAgICAgICAgIC0+eXlfY2hfYnVmW251bWJlcl90b19tb3ZlXSlbbisrXSA9IChjaGFyKWM7CiAgICAgICAgICAgIGlmIChjID09IEVPRiAmJiBmZXJyb3IoeXlpbikpCiAgICAgICAgICAgICAgICB5eV9mYXRhbF9lcnJvcigiaW5wdXQgaW4gZmxleCBzY2FubmVyIGZhaWxlZCIpOwogICAgICAgICAgICAoeXlfbl9jaGFycykgPSBuOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGVycm5vID0gMDsKICAgICAgICAgICAgd2hpbGUgKCgoeXlfbl9jaGFycykgPQogICAgICAgICAgICAgICAgICAgICAgICAoaW50KWZyZWFkKCgmKHl5X2J1ZmZlcl9zdGFjaylbKHl5X2J1ZmZlcl9zdGFja190b3ApXQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0+eXlfY2hfYnVmW251bWJlcl90b19tb3ZlXSksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgMSwgKHl5X3NpemVfdCludW1fdG9fcmVhZCwgeXlpbikpID09IDAgJiYKICAgICAgICAgICAgICAgICAgIGZlcnJvcih5eWluKSkgewogICAgICAgICAgICAgICAgaWYgKGVycm5vICE9IEVJTlRSKSB7CiAgICAgICAgICAgICAgICAgICAgeXlfZmF0YWxfZXJyb3IoImlucHV0IGluIGZsZXggc2Nhbm5lciBmYWlsZWQiKTsKICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGVycm5vID0gMDsKICAgICAgICAgICAgICAgIGNsZWFyZXJyKHl5aW4pOwogICAgICAgICAgICB9CiAgICAgICAgfTsKICAgICAgICAoeXlfYnVmZmVyX3N0YWNrKVsoeXlfYnVmZmVyX3N0YWNrX3RvcCldLT55eV9uX2NoYXJzID0gKHl5X25fY2hhcnMpOwogICAgfQogICAgaWYgKCh5eV9uX2NoYXJzKSA9PSAwKSB7CiAgICAgICAgaWYgKG51bWJlcl90b19tb3ZlID09IDApIHsKICAgICAgICAgICAgcmV0X3ZhbCA9IDE7CiAgICAgICAgICAgIHl5cmVzdGFydCh5eWluKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgICByZXRfdmFsID0gMjsKICAgICAgICAgICAgKHl5X2J1ZmZlcl9zdGFjaylbKHl5X2J1ZmZlcl9zdGFja190b3ApXS0+eXlfYnVmZmVyX3N0YXR1cyA9IDI7CiAgICAgICAgfQogICAgfSBlbHNlCiAgICAgICAgcmV0X3ZhbCA9IDA7CiAgICBpZiAoKCh5eV9uX2NoYXJzKSArIG51bWJlcl90b19tb3ZlKSA+CiAgICAgICAgKHl5X2J1ZmZlcl9zdGFjaylbKHl5X2J1ZmZlcl9zdGFja190b3ApXS0+eXlfYnVmX3NpemUpIHsKICAgICAgICBpbnQgbmV3X3NpemUgPSAoeXlfbl9jaGFycykgKyBudW1iZXJfdG9fbW92ZSArICgoeXlfbl9jaGFycykgPj4gMSk7CiAgICAgICAgKHl5X2J1ZmZlcl9zdGFjaylbKHl5X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9wKSA8CiAgICAgICAgICAgICYoeXlfYnVmZmVyX3N0YWNrKVsoeXlfYnVmZmVyX3N0YWNrX3RvcCldLT55eV9jaF9idWZbKHl5X25fY2hhcnMpXSkKICAgICAgICAgICAgKih5eV9jX2J1Zl9wKSA9ICdcMCc7CiAgICAgICAgZWxzZSB7CiAgICAgICAgICAgIGludCBvZmZzZXQgPSAoaW50KSgoeXlfY19idWZfcCkgLSAoeXl0ZXh0KSk7CiAgICAgICAgICAgICsrKHl5X2NfYnVmX3ApOwogICAgICAgICAgICBzd2l0Y2ggKHl5X2dldF9uZXh0X2J1ZmZlcigpKSB7CiAgICAgICAgICAgICAgICBjYXNlIDI6CiAgICAgICAgICAgICAgICAgICAgeXlyZXN0YXJ0KHl5aW4pOwogICAgICAgICAgICAgICAgY2FzZSAxOiB7CiAgICAgICAgICAgICAgICAgICAgaWYgKHl5d3JhcCgpKSByZXR1cm4gMDsKICAgICAgICAgICAgICAgICAgICBpZiAoISh5eV9kaWRfYnVmZmVyX3N3aXRjaF9vbl9lb2YpKSB5eXJlc3RhcnQoeXlpbik7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGlucHV0KCk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjYXNlIDA6CiAgICAgICAgICAgICAgICAgICAgKHl5X2NfYnVmX3ApID0gKHl5dGV4dCkgKyBvZmZzZXQ7CiAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9CiAgICBjID0gKih1bnNpZ25lZCBjaGFyKikoeXlfY19idWZfcCk7CiAgICAqKHl5X2NfYnVmX3ApID0gJ1wwJzsKICAgICh5eV9ob2xkX2NoYXIpID0gKisrKHl5X2NfYnVmX3ApOwogICAgcmV0dXJuIGM7Cn0Kdm9pZCB5eXJlc3RhcnQoRklMRSogaW5wdXRfZmlsZSkgewogICAgaWYgKCEoKHl5X2J1ZmZlcl9zdGFjaykgPyAoeXlfYnVmZmVyX3N0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gICAgICAgICAgICAgICAgICAgICAiTkVXTElORSIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIkFSUk9XIiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiJygnIiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiJyknIiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiJGFjY2VwdCIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgInByb2dyYW0iLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJleHByIiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoKHZvaWQqKTApfTsKc3RhdGljIGNvbnN0IGNoYXIqIHl5c3ltYm9sX25hbWUoeXlzeW1ib2xfa2luZF90IHl5c3ltYm9sKSB7CiAgICByZXR1cm4geXl0bmFtZVt5eXN5bWJvbF07Cn0Kc3RhdGljIGNvbnN0IHl5dHlwZV9pbnQ4IHl5cGFjdFtdID0gezYsIDAsIDIsIDUsIC00LCAtMywgLTQsIC00LCA2LCAtNCwgOH07CnN0YXRpYyBjb25zdCB5eXR5cGVfaW50OCB5eWRlZmFjdFtdID0gezAsIDAsIDAsIDAsIDMsIDAsIDEsIDIsIDAsIDQsIDV9OwpzdGF0aWMgY29uc3QgeXl0eXBlX2ludDggeXlwZ290b1tdID0gey00LCAtNCwgLTF9OwpzdGF0aWMgY29uc3QgeXl0eXBlX2ludDggeXlkZWZnb3RvW10gPSB7MCwgMiwgM307CnN0YXRpYyBjb25zdCB5eXR5cGVfaW50OCB5eXRhYmxlW10gPSB7NSwgOCwgNiwgOSwgMCwgMSwgNCwgMTAsIDcsIDgsIDAsIDEsIDh9OwpzdGF0aWMgY29uc3QgeXl0eXBlX2ludDggeXljaGVja1tdID0gezEsIDQsIDAsIDYsIC0xLCA1LCA2LCA4LCAzLCA0LCAtMSwgNSwgNH07CnN0YXRpYyBjb25zdC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eXlzZXRzdGF0ZToKICAgIGRvIHsKICAgICAgICBpZiAoeXlkZWJ1ZykgZnByaW50ZihzdGRlcnIsICJFbnRlcmluZyBzdGF0ZSAlZFxuIiwgeXlzdGF0ZSk7CiAgICB9IHdoaWxlICgwKTsKICAgICgodm9pZCkoMCAmJiAoMCA8PSB5eXN0YXRlICYmIHl5c3RhdGUgPCAxMSkpKTsKICAgICp5eXNzcCA9ICgoeXlfc3RhdGVfdCkoeXlzdGF0ZSkpOwogICAgZG8gewogICAgICAgIGlmICh5eWRlYnVnKSB5eV9zdGFja19wcmludCgoeXlzcyksICh5eXNzcCkpOwogICAgfSB3aGlsZSAoMCk7CiAgICBpZiAoeXlzcyArIHl5c3RhY2tzaXplIC0gMSA8PSB5eXNzcCkgewogICAgICAgIGxvbmcgeXlzaXplID0geXlzc3AgLSB5eXNzICsgMTsKICAgICAgICBpZiAoMTAwMDAgPD0geXlzdGFja3NpemUpIGdvdG8geXlleGhhdXN0ZWRsYWI7CiAgICAgICAgeXlzdGFja3NpemUgKj0gMjsKICAgICAgICBpZiAoMTAwMDAgPCB5eXN0YWNrc2l6ZSkgeXlzdGFja3NpemUgPSAxMDAwMDsKICAgICAgICB7CiAgICAgICAgICAgIHl5X3N0YXRlX3QqIHl5c3MxID0geXlzczsKICAgICAgICAgICAgdW5pb24geXlhbGxvYyogeXlwdHIgPSAoKHVuaW9uIHl5YWxsb2MqKShtYWxsb2MoCiAgICAgICAgICAgICAgICAoKHVuc2lnbmVkKSgoKHl5c3RhY2tzaXplKSAqICgoKGxvbmcpKHNpemVvZih5eV9zdGF0ZV90KSkpICsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgobG9uZykoc2l6ZW9mKFlZU1RZUEUpKSkpICsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoKChsb25nKShzaXplb2YodW5pb24geXlhbGxvYykpKSAtIDEpKSkpKSkpOwogICAgICAgICAgICBpZiAoIXl5cHRyKSBnb3RvIHl5ZXhoYXVzdGVkbGFiOwogICAgICAgICAgICBkbyB7CiAgICAgICAgICAgICAgICBsb25nIHl5bmV3Ynl0ZXM7CiAgICAgICAgICAgICAgICBkbyB7CiAgICAgICAgICAgICAgICAgICAgbG9uZyB5eWk7CiAgICAgICAgICAgICAgICAgICAgZm9yICh5eWkgPSAwOyB5eWkgPCAoeXlzaXplKTsgeXlpKyspCiAgICAgICAgICAgICAgICAgICAgICAgICgmeXlwdHItPnl5c3NfYWxsb2MpW3l5aV0gPSAoeXlzcylbeXlpXTsKICAgICAgICAgICAgICAgIH0gd2hpbGUgKDApOwogICAgICAgICAgICAgICAgeXlzcyA9ICZ5eXB0ci0+eXlzc19hbGxvYzsKICAgICAgICAgICAgICAgIHl5bmV3Ynl0ZXMgPSB5eXN0YWNrc2l6ZSAqICgobG9uZykoc2l6ZW9mKCp5eXNzKSkpICsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoKChsb25nKShzaXplb2YodW5pb24geXlhbGxvYykpKSAtIDEpOwogICAgICAgICAgICAgICAgeXlwdHIgKz0geXluZXdieXRlcyAvICgobG9uZykoc2l6ZW9mKCp5eXB0cikpKTsKICAgICAgICAgICAgfSB3aGlsZSAoMCk7CiAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICAgIGxvbmcgeXluZXdieXRlczsKICAgICAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICAgICAgICBsb25nIHl5aTsKICAgICAgICAgICAgICAgICAgICBmb3IgKHl5aSA9IDA7IHl5aSA8ICh5eXNpemUpOyB5eWkrKykKICAgICAgICAgICAgICAgICAgICAgICAgKCZ5eXB0ci0+eXl2c19hbGxvYylbeXlpXSA9ICh5eXZzKVt5eWldOwogICAgICAgICAgICAgICAgfSB3aGlsZSAoMCk7CiAgICAgICAgICAgICAgICB5eXZzID0gJnl5cHRyLT55eXZzX2FsbG9jOwogICAgICAgICAgICAgICAgeXluZXdieXRlcyA9IHl5c3RhY2tzaXplICogKChsb25nKShzaXplb2YoKnl5dnMpKSkgKwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICgoKGxvbmcpKHNpemVvZih1bmlvbiB5eWFsbG9jKSkpIC0gMSk7CiAgICAgICAgICAgICAgICB5eXB0ciArPSB5eW5ld2J5dGVzIC8gKChsb25nKShzaXplb2YoKnl5cHRyKSkpOwogICAgICAgICAgICB9IHdoaWxlICgwKTsKICAgICAgICAgICAgaWYgKHl5c3MxICE9IHl5c3NhKSBmcmVlKHl5c3MxKTsKICAgICAgICB9CiAgICAgICAgeXlzc3AgPSB5eXNzICsgeXlzaXplIC0gMTsKICAgICAgICB5eXZzcCA9IHl5dnMgKyB5eXNpemUgLSAxOwogICAgICAgIGRvIHsKICAgICAgICAgICAgaWYgKHl5ZGVidWcpCiAgICAgICAgICAgICAgICBmcHJpbnRmKHN0ZGVyciwgIlN0YWNrIHNpemUgaW5jcmVhc2VkIHRvICVsZFxuIiwKICAgICAgICAgICAgICAgICAgICAgICAgKChsb25nKSh5eXN0YWNrc2l6ZSkpKTsKICAgICAgICB9IHdoaWxlICgwKTsKICAgICAgICBpZiAoeXlzcyArIHl5c3RhY2tzaXplIC0gMSA8PSB5eXNzcCkgZ290byB5eWFib3J0bGFiOwogICAgfQogICAgaWYgKHl5c3RhdGUgPT0gNikgZ290byB5eWFjY2VwdGxhYjsKICAgIGdvdG8geXliYWNrdXA7Cnl5YmFja3VwOgogICAgeXluID0geXlwYWN0W3l5c3RhdGVdOwogICAgaWYgKCgoeXluKSA9PSAoLTQpKSkgZ290byB5eWRlZmF1bHQ7CiAgICBpZiAoeXljaGFyID09IC0yKSB7CiAgICAgICAgZG8gewogICAgICAgICAgICBpZiAoeXlkZWJ1ZykgZnByaW50ZihzdGRlcnIsICJSZWFkaW5nIGEgdG9rZW5cbiIpOwogICAgICAgIH0gd2hpbGUgKDApOwogICAgICAgIHl5Y2hhciA9IHl5bGV4KCk7CiAgICB9CiAgICBpZiAoeXljaGFyIDw9IDApIHsKICAgICAgICB5eWNoYXIgPSAwOwogICAgICAgIHl5dG9rZW4gPSBZWVNZTUJPTF9ZWUVPRjsKICAgICAgICBkbyB7CiAgICAgICAgICAgIGlmICh5eWRlYnVnKSBmcHJpbnRmKHN0ZGVyciwgIk5vdyBhdCBlbmQgb2YgaW5wdXQuXG4iKTsKICAgICAgICB9IHdoaWxlICgwKTsKICAgIH0gZWxzZSBpZiAoeXljaGFyID09IDI1NikgewogICAgICAgIHl5Y2hhciA9IDI1NzsKICAgICAgICB5eXRva2VuID0gWVlTWU1CT0xfWVllcnJvcjsKICAgICAgICBnb3RvIHl5ZXJybGFiMTsKICAgIH0gZWxzZSB7CiAgICAgICAgeXl0b2tlbiA9ICgwIDw9ICh5eWNoYXIpICYmICh5eWNoYXIpIDw9IDI1OQogICAgICAgICAgICAgICAgICAgICAgID8gKCh5eXN5bWJvbF9raW5kX3QpKHl5dHJhbnNsYXRlW3l5Y2hhcl0pKQogICAgICAgICAgICAgICAgICAgICAgIDogWVlTWU1CT0xfWVlVTkRFRik7CiAgICAgICAgZG8gewogICAgICAgICAgICBpZiAoeXlkZWJ1ZykgewogICAgICAgICAgICAgICAgZnByaW50ZihzdGRlcnIsICIlcyAiLCAiTmV4dCB0b2tlbiBpcyIpOwogICAgICAgICAgICAgICAgeXlfc3ltYm9sX3ByaW50KHN0ZGVyciwgeXl0b2tlbiwgJnl5bHZhbCk7CiAgICAgICAgICAgICAgICBmcHJpbnRmKHN0ZGVyciwgIlxuIik7CiAgICAgICAgICAgIH0KICAgICAgICB9IHdoaWxlICgwKTsKICAgIH0KICAgIHl5biArPSB5eXRva2VuOwogICAgaWYgKHl5biA8IDAgfHwgMTIgPCB5eW4gfHwgeXljaGVja1t5eW5dICE9IHl5dG9rZW4pIGdvdG8geXlkZWZhdWx0OwogICAgeXluID0geXl0YWJsZVt5eW5dOwogICAgaWYgKHl5biA8PSAwKSB7CiAgICAgICAgaWYgKDApIGdvdG8geXllcnJsYWI7CiAgICAgICAgeXluID0gLXl5bjsKICAgICAgICBnb3RvIHl5cmVkdWNlOwogICAgfQogICAgaWYgKHl5ZXJyc3RhdHVzKSB5eWVycnN0YXR1cy0tOwogICAgZG8gewogICAgICAgIGlmICh5eWRlYnVnKSB7CiAgICAgICAgICAgIGZwcmludGYoc3RkZXJyLCAiJXMgIiwgIlNoaWZ0aW5nIik7CiAgICAgICAgICAgIHl5X3N5bWJvbF9wcmludChzdGRlcnIsIHl5dG9rZW4sICZ5eWx2YWwpOwogICAgICAgICAgICBmcHJpbnRmKHN0ZGVyciwgIlxuIik7CiAgICAgICAgfQogICAgfSB3aGlsZSAoMCk7CiAgICB5eXN0YXRlID0geXluOwogICAgKisreXl2c3AgPSB5eWx2YWw7CiAgICB5eWNoYXIgPSAtMjsKICAgIGdvdG8geXluZXdzdGF0ZTsKeXlkZWZhdWx0OgogICAgeXluID0geXlkZWZhY3RbeXlzdGF0ZV07CiAgICBpZiAoeXluID09IDApIGdvdG8geXllcnJsYWI7CiAgICBnb3RvIHl5cmVkdWNlOwp5eXJlZHVjZToKICAgIHl5bGVuID0geXlyMlt5eW5dOwogICAgeXl2YWwgPSB5eXZzcFsxIC0geXlsZW5dOwogICAgZG8gewogICAgICAgIGlmICh5eWRlYnVnKSB5eV9yZWR1Y2VfcHJpbnQoeXlzc3AsIHl5dnNwLCB5eW4pOwogICAgfSB3aGlsZSAoMCk7CiAgICBzd2l0Y2ggKHl5bikgewogICAgICAgIGNhc2UgMjogewogICAgICAgICAgICByZXR1cm4geXl2YWw7CiAgICAgICAgfSBicmVhazsKICAgICAgICBjYXNlIDM6IHsKICAgICAgICAgICAgeXl2YWwgPSAwOwogICAgICAgIH0gYnJlYWs7CiAgICAgICAgY2FzZSA0OiB7CiAgICAgICAgICAgIHl5dmFsID0geXl2c3BbLTFdOwogICAgICAgIH0gYnJlYWs7CiAgICAgICAgY2FzZSA1OiB7CiAgICAgICAgICAgIHl5dmFsID0gTUFYKHl5dnNwWy0yXSArIDEsIHl5dnNwWzBdKTsKICAgICAgICB9IGJyZWFrOwogICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgIGJyZWFrOwogICAgfQogICAgZG8gewogICAgICAgIGlmICh5eWRlYnVnKSB7CiAgICAgICAgICAgIGZwcmludGYoc3RkZXJyLCAiJXMgIiwgIi0+ICQkID0iKTsKICAgICAgICAgICAgeXlfc3ltYm9sX3ByaW50KHN0ZGVyciwgKCh5eXN5bWJvbF9raW5kX3QpKHl5cjFbeXluXSkpLCAmeXl2YWwpOwogICAgICAgICAgICBmcHJpbnRmKHN0ZGVyciwgIlxuIik7CiAgICAgICAgfQogICAgfSB3aGlsZSAoMCk7CiAgICAoeXl2c3AgLT0gKHl5bGVuKSwgeXlzc3AgLT0gKHl5bGVuKSk7CiAgICB5eWxlbiA9IDA7CiAgICAqKyt5eXZzcCA9IHl5dmFsOwogICAgewogICAgICAgIGNvbnN0IGludCB5eWxocyA9IHl5cjFbeXluXSAtIDc7CiAgICAgICAgY29uc3QgaW50IHl5aSA9IHl5cGdvdG9beXlsaHNdICsgKnl5c3NwOwogICAgICAgIHl5c3RhdGUgPSAoMCA8PSB5eWkgJiYgeXlpIDw9IDEyICYmIHl5Y2hlY2tbeXlpXSA9PSAqeXlzc3AKICAgICAgICAgICAgICAgICAgICAgICA/IHl5dGFibGVbeXlpXQogICAgICAgICAgICAgICAgICAgICAgIDogeXlkZWZnb3RvW3l5bGhzXSk7CiAgICB9CiAgICBnb3RvIHl5bmV3c3RhdGU7Cnl5ZXJybGFiOgogICAgeXl0b2tlbiA9IHl5Y2hhciA9PSAtMiA/IFlZU1lNQk9MX1lZRU1QVFkKICAgICAgICAgICAgICAgICAgICAgICAgICAgOiAoMCA8PSAoeXljaGFyKSAmJiAoeXljaGFyKSA8PSAyNTkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgID8gKCh5eXN5bWJvbF9raW5kX3QpKHl5dHJhbnNsYXRlW3l5Y2hhcl0pKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOiBZWVNZTUJPTF9ZWVVOREVGKTsKICAgIGlmICgheXllcnJzdGF0dXMpIHsKICAgICAgICArK3l5bmVycnM7CiAgICAgICAgeXllcnJvcigic3ludGF4IGVycm9yIik7CiAgICB9CiAgICBpZiAoeXllcnJzdGF0dXMgPT0gMykgewogICAgICAgIGlmICh5eWNoYXIgPD0gMCkgewogICAgICAgICAgICBpZiAoeXljaGFyID09IDApIGdvdG8geXlhYm9ydGxhYjsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgICB5eWRlc3RydWN0KCJFcnJvcjogZGlzY2FyZGluZyIsIHl5dG9rZW4sICZ5eWx2YWwpOwogICAgICAgICAgICB5eWNoYXIgPSAtMjsKICAgICAgICB9CiAgICB9CiAgICBnb3RvIHl5ZXJybGFiMTsKeXllcnJvcmxhYjoKICAgIGlmICgwKSBnb3RvIHl5ZXJyb3JsYWI7CiAgICArK3l5bmVycnM7CiAgICAoeXl2c3AgLT0gKHl5bGVuKSwgeXlzc3AgLT0gKHl5bGVuKSk7CiAgICB5eWxlbiA9IDA7CiAgICBkbyB7CiAgICAgICAgaWYgKHl5ZGVidWcpIHl5X3N0YWNrX3ByaW50KCh5eXNzKSwgKHl5c3NwKSk7CiAgICB9IHdoaWxlICgwKTsKICAgIHl5c3RhdGUgPSAqeXlzc3A7CiAgICBnb3RvIHl5ZXJybGFiMTsKeXllcnJsYWIxOgogICAgeXllcnJzdGF0dXMgPSAzOwogICAgZm9yICg7OykgewogICAgICAgIHl5biA9IHl5cGFjdFt5eXN0YXRlXTsKICAgICAgICBpZiAoISgoeXluKSA9PSAoLTQpKSkgewogICAgICAgICAgICB5eW4gKz0gWVlTWU1CT0xfWVllcnJvcjsKICAgICAgICAgICAgaWYgKDAgPD0geXluICYmIHl5biA8PSAxMiAmJiB5eWNoZWNrW3l5bl0gPT0gWVlTWU1CT0xfWVllcnJvcikgewogICAgICAgICAgICAgICAgeXluID0geXl0YWJsZVt5eW5dOwogICAgICAgICAgICAgICAgaWYgKDAgPCB5eW4pIGJyZWF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