#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;
*pn = 0;
;
if (!isdigit(c
) && c
!= EOF
&& c
!= '+' && c
!= '-') { /* ungetch(c);*/ /* if returned to input we fill the array */
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;
}
ICAgICNpbmNsdWRlIDxzdGRpby5oPgogICAgI2luY2x1ZGUgPGN0eXBlLmg+IC8qIGZvciBpc2RpZ2l0KGMpLCBldGMuICovCiAgICAgCiAgICAjZGVmaW5lIE1BWCAxMAogICAgI2RlZmluZSBTSVpFIDE1CiAgICAgCiAgICBpbnQgZ2V0aW50KGludCAqcG4pOwogICAgIAogICAgaW50IG1haW4odm9pZCl7CiAgICAJaW50IG4sIGs7CiAgICAJaW50IGFycmF5W1NJWkVdOwogICAgIAogICAgCWZvcihuID0gMDsgbiA8IFNJWkUgJiYgZ2V0aW50KCZhcnJheVtuXSkgIT0gRU9GOyBuKyspCiAgICAJCTsKICAgIAlmb3IoayA9IDA7IGsgPCBuOyBrKyspCiAgICAJCXByaW50ZigiJWRcbiIsIGFycmF5W2tdKTsKICAgIAlzY2FuZigiJWQiLCAmayk7CiAgICB9CiAgICAgCiAgICBpbnQgZ2V0Y2godm9pZCk7CiAgICB2b2lkIHVuZ2V0Y2goaW50IGMpOwogICAgIAogICAgIAogICAgaW50IGdldGludChpbnQgKnBuKQp7CglpbnQgYywgc2lnbjsKCgkqcG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