#include <sys/time.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
int main(void) {
fd_set sfds;
int vrad, vtkt, vpoz;
char sbuf[1024];
vtkt = 0;
FD_ZERO(&sfds);
FD_SET(STDIN_FILENO, &sfds);
for ( ; ; ) {
for ( ; ; ) {
if ((vrad = select(STDIN_FILENO + 1, &sfds, NULL, NULL,
&((struct timeval){0,0}))) == -1) {
}
FD_SET(STDIN_FILENO, &sfds);
if (vrad == 0) {
break;
}
if ((vrad = read(STDIN_FILENO, &sbuf[0], 1024)) == -1) {
}
/* чики чик */
for (vpoz = 0; ; ) {
if (sbuf[vpoz] == 10) {
}
if (++vpoz == vrad) {
break;
}
}
}
usleep(100000);
}
}
CiNpbmNsdWRlIDxzeXMvdGltZS5oPgojaW5jbHVkZSA8c3RkaW8uaD4KI2luY2x1ZGUgPHVuaXN0ZC5oPgojaW5jbHVkZSA8c3RkbGliLmg+CgoKaW50IG1haW4odm9pZCkgewoKICBmZF9zZXQgc2ZkczsKICBpbnQgICAgdnJhZCwgdnRrdCwgdnBvejsKICBjaGFyICAgc2J1ZlsxMDI0XTsKCiAgdnRrdCA9IDA7CgogIEZEX1pFUk8oJnNmZHMpOwogIEZEX1NFVChTVERJTl9GSUxFTk8sICZzZmRzKTsKCiAgZm9yICggOyA7ICkgewoKICAgIGZvciAoIDsgOyApIHsKCiAgICAgIGlmICgodnJhZCA9IHNlbGVjdChTVERJTl9GSUxFTk8gKyAxLCAmc2ZkcywgTlVMTCwgTlVMTCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICYoKHN0cnVjdCB0aW1ldmFsKXswLDB9KSkpID09IC0xKSB7CgogICAgICAgIGV4aXQoLTEpOwoKICAgICAgfQoKICAgICAgRkRfU0VUKFNURElOX0ZJTEVOTywgJnNmZHMpOwoKICAgICAgaWYgKHZyYWQgPT0gMCkgewoKICAgICAgICBicmVhazsKICAgICAgfQoKCiAgICAgIGlmICgodnJhZCA9IHJlYWQoU1RESU5fRklMRU5PLCAmc2J1ZlswXSwgMTAyNCkpID09IC0xKSB7CgogICAgICAgIGV4aXQoLTEpOwogICAgICB9CgogICAgICAvKiDRh9C40LrQuCDRh9C40LogKi8KCiAgICAgIGZvciAodnBveiA9IDA7IDsgKSB7CgogICAgICAgIGlmIChzYnVmW3Zwb3pdID09IDEwKSB7CgogICAgICAgICAgcHJpbnRmKCJlbmRcbiIpOwogICAgICAgICAgZXhpdCgwKTsKICAgICAgICB9CiAgICAgICAgaWYgKCsrdnBveiA9PSB2cmFkKSB7CgogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICB9CgogICAgfQoKICAgIHByaW50ZigidHNrdDogJXVcbiIsIHZ0a3QrKyk7CgogICAgdXNsZWVwKDEwMDAwMCk7CiAgfQoKfQo=