#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define BUFFSIZE 3 /* >= 2 */
char *mygetline(FILE *fp) {
static char inbuff[BUFFSIZE];
char *outbuff_malloc, *tmpbuff;
char *p, *r;
int fEOL;
if ((outbuff_malloc
= malloc(1)) == NULL
) { return NULL;
}
*outbuff_malloc = '\0';
fEOL = 0;
do {
r
= fgets(inbuff
, BUFFSIZE
, fp
); if (r == NULL)
break;
for (p = inbuff; *p != '\0'; p++)
;
if (*(p - 1) == '\n')
fEOL = 1;
if ((tmpbuff
= realloc(outbuff_malloc
, strlen(outbuff_malloc
) + strlen(inbuff
) + 1)) == NULL
) { return NULL;
}
outbuff_malloc = tmpbuff;
} while (!fEOL);
if (strlen(outbuff_malloc
) > 0) { char c;
for (p = outbuff_malloc; *p != '\0'; p++)
;
while ((c = *(--p)) == '\n' || c == '\r')
*p = '\0';
return outbuff_malloc;
}
return NULL;
}
int main() {
char *p;
while ((p = mygetline(stdin)) != 0) {
}
return 0;
}
/* end */
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPHN0cmluZy5oPgoKI2RlZmluZSBCVUZGU0laRSAzIC8qID49IDIgKi8KY2hhciAqbXlnZXRsaW5lKEZJTEUgKmZwKSB7CiAgc3RhdGljIGNoYXIgaW5idWZmW0JVRkZTSVpFXTsKICBjaGFyICpvdXRidWZmX21hbGxvYywgKnRtcGJ1ZmY7CiAgY2hhciAqcCwgKnI7CiAgaW50IGZFT0w7CiAKICBpZiAoKG91dGJ1ZmZfbWFsbG9jID0gbWFsbG9jKDEpKSA9PSBOVUxMKSB7CiAgICByZXR1cm4gTlVMTDsKICB9CiAgKm91dGJ1ZmZfbWFsbG9jID0gJ1wwJzsKICBmRU9MID0gMDsKICBkbyB7CiAgICByID0gZmdldHMoaW5idWZmLCBCVUZGU0laRSwgZnApOwogICAgaWYgKHIgPT0gTlVMTCkKICAgICAgYnJlYWs7CiAgICBmb3IgKHAg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