%{
#include <stdio.h>
void hexToDecimal(char*);
%}
%%
[0-9A-Fa-f]+ {hexToDecimal(yytext);}
%%
void hexToDecimal(char *yytext){
int value = 0;
int i = 0;
while (yytext[i] != '\0') {
value = value * 16;
if (yytext[i] >= '0' && yytext[i] <= '9') {
value = value + (yytext[i] - '0');
} else if (yytext[i] >= 'A' && yytext[i] <= 'F') {
value = value + (yytext[i] - 'A' + 10);
} else if (yytext[i] >= 'a' && yytext[i] <= 'f') {
value = value + (yytext[i] - 'a' + 10);
}
i++;
}
printf("%d\n", value);
}
int yywrap() {
return 1;
}
int main() {
yylex();
return 0;
}
JXsKI2luY2x1ZGUgPHN0ZGlvLmg+CnZvaWQgaGV4VG9EZWNpbWFsKGNoYXIqKTsKJX0KIAolJQpbMC05QS1GYS1mXSsge2hleFRvRGVjaW1hbCh5eXRleHQpO30KJSUKIAp2b2lkIGhleFRvRGVjaW1hbChjaGFyICp5eXRleHQpewogICAgaW50IHZhbHVlID0gMDsKICAgIGludCBpID0gMDsKIAogICAgd2hpbGUgKHl5dGV4dFtpXSAhPSAnXDAnKSB7CiAgICAgICAgdmFsdWUgPSB2YWx1ZSAqIDE2OwogICAgICAgIGlmICh5eXRleHRbaV0gPj0gJzAnICYmIHl5dGV4dFtpXSA8PSAnOScpIHsKICAgICAgICAgICAgdmFsdWUgPSB2YWx1ZSArICh5eXRleHRbaV0gLSAnMCcpOwogICAgICAgIH0gZWxzZSBpZiAoeXl0ZXh0W2ldID49ICdBJyAmJiB5eXRleHRbaV0gPD0gJ0YnKSB7CiAgICAgICAgICAgIHZhbHVlID0gdmFsdWUgKyAoeXl0ZXh0W2ldIC0gJ0EnICsgMTApOwogICAgICAgIH0gZWxzZSBpZiAoeXl0ZXh0W2ldID49ICdhJyAmJiB5eXRleHRbaV0gPD0gJ2YnKSB7CiAgICAgICAgICAgIHZhbHVlID0gdmFsdWUgKyAoeXl0ZXh0W2ldIC0gJ2EnICsgMTApOwogICAgICAgIH0KICAgICAgICBpKys7CiAgICB9CiAgICBwcmludGYoIiVkXG4iLCB2YWx1ZSk7Cn0KIAppbnQgeXl3cmFwKCkgewogICAgcmV0dXJuIDE7Cn0KIAppbnQgbWFpbigpIHsKICAgIHl5bGV4KCk7CiAgICByZXR1cm4gMDsKfQ==