#include <stdio.h>
#include <ctype.h> /* for isdigit(c), etc. */
#define MAX 10
#define SIZE 15
int getint(int *pn);
int main(void){
int n, k;
int array[SIZE];
for(n = 0; n < SIZE && getint(&array[n]) != EOF; n++)
;
for(k = 0; k < n; k++)
}
void ungetch(int c);
int getint(int *pn){
int c, sign;
if(!isdigit(c
) && c
!= EOF
&& c
!= '+' && c
!= '-') return 0;
sign = (c == '-') ? -1 : 1;
if(c == '-' || c == '+'){
ungetch((sign == 1) ? '+' : '-');
return 0;
}
}
*pn = 10 * (*pn) + (c - '0');
*pn *= sign;
if(c != EOF){
ungetch(c);
}
return c;
}
int bufp = 0;
int buf[MAX];
{
return bufp
> 0 ? buf
[--bufp
] : getchar(); }
void ungetch(int c)
{
if (bufp < MAX)
buf[bufp++] = c;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxjdHlwZS5oPiAvKiBmb3IgaXNkaWdpdChjKSwgZXRjLiAqLwoKI2RlZmluZSBNQVggMTAKI2RlZmluZSBTSVpFIDE1CgppbnQgZ2V0aW50KGludCAqcG4pOwoKaW50IG1haW4odm9pZCl7CglpbnQgbiwgazsKCWludCBhcnJheVtTSVpFXTsKCQoJZm9yKG4gPSAwOyBuIDwgU0laRSAmJiBnZXRpbnQoJmFycmF5W25dKSAhPSBFT0Y7IG4rKykKCQk7Cglmb3IoayA9IDA7IGsgPCBuOyBrKyspCgkJcHJpbnRmKCIlZFxuIiwgYXJyYXlba10pOwoJc2NhbmYoIiVkIiwgJmspOwp9CgppbnQgZ2V0Y2godm9pZCk7CnZvaWQgdW5nZXRjaChpbnQgYyk7CgoKaW50IGdldGludChpbnQgKnBuKXsKCWludCBjLCBzaWduOwoJCgl3aGlsZShpc3NwYWNlKGMgPSBnZXRjaCgpKSk7CglpZighaXNkaWdpdChjKSAmJiBjICE9IEVPRiAmJiBjICE9ICcrJyAmJiBjICE9ICctJykKCQlyZXR1cm4gMDsKCXNpZ24gPSAoYyA9PSAnLScpID8gLTEgO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