#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ printf(char *);
scalar_t__ scanf(char *, char *);
int main() {
  char ch;
  int remain;
  while (1) {
    remain = 0;
    while (scanf("%c", &ch) != EOF && ch != '#') {
      if (ch != '\n') {
        remain = (remain * 2 + ch - '0') % 131071;
      }
    }
    if (ch != '#') {
      break;
    }
    if (remain) {
      printf("NO\n");
    } else {
      printf("YES\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xec3(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1040 <scanf@plt>
mov    %rax,%rcx
xor    %eax,%eax
mov    0x2e96(%rip),%rdx
cmp    (%rdx),%rcx
mov    %al,-0xd(%rbp)
je     116b <main+0x4b>
movsbl -0x5(%rbp),%eax
cmp    $0x23,%eax
setne  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    117b <main+0x5b>
jmp    11a7 <main+0x87>
movsbl -0x5(%rbp),%eax
cmp    $0xa,%eax
je     11a2 <main+0x82>
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
movsbl -0x5(%rbp),%ecx
add    %ecx,%eax
sub    $0x30,%eax
mov    $0x1ffff,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
jmp    1136 <main+0x16>
movsbl -0x5(%rbp),%eax
cmp    $0x23,%eax
je     11b9 <main+0x99>
jmp    11e5 <main+0xc5>
cmpl   $0x0,-0xc(%rbp)
je     11d4 <main+0xb4>
lea    0xe39(%rip),%rdi
call   1030 <printf@plt>
jmp    11e0 <main+0xc0>
lea    0xe2c(%rip),%rdi
call   1030 <printf@plt>
jmp    112f <main+0xf>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xece(%rip),%r14
lea    0x7(%rsp),%rbx
mov    0x2eaa(%rip),%r15
lea    0xec2(%rip),%r12
lea    0xeb7(%rip),%r13
jmp    1161 <main+0x41>
xchg   %ax,%ax
cmp    $0x23,%cl
jne    11e9 <main+0xc9>
mov    %r13,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    0x7(%rsp),%cl
cmp    (%r15),%rax
je     1150 <main+0x30>
cmp    $0x23,%cl
je     1150 <main+0x30>
xor    %ebp,%ebp
nopl   0x0(%rax)
cmp    $0xa,%cl
je     11ba <main+0x9a>
movsbl %cl,%eax
lea    (%rax,%rbp,2),%ecx
lea    (%rax,%rbp,2),%eax
add    $0xffffffd0,%eax
cltq
imul   $0xffffffff80004001,%rax,%rax
shr    $0x20,%rax
add    %ecx,%eax
add    $0xffffffd0,%eax
mov    %eax,%edx
shr    $0x1f,%edx
sar    $0x10,%eax
add    %edx,%eax
mov    %eax,%edx
shl    $0x11,%edx
sub    %edx,%eax
lea    (%rax,%rcx,1),%ebp
add    $0xffffffd0,%ebp
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
movzbl 0x7(%rsp),%ecx
cmp    (%r15),%rax
je     11d4 <main+0xb4>
cmp    $0x23,%cl
jne    1180 <main+0x60>
cmp    $0x23,%cl
jne    11e9 <main+0xc9>
mov    %r12,%rdi
test   %ebp,%ebp
jne    115c <main+0x3c>
jmp    1159 <main+0x39>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@EOF = global i64 0
@.str.1 = [4 x i8] c"NO\0A\00"
@.str.2 = [5 x i8] c"YES\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
store i32 0, i32* %1
br label %4
4: ; preds = %0, %40
store i32 0, i32* %3
br label %5
5: ; preds = %27, %4
%6 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%7 = load i64, i64* @EOF
%8 = icmp ne i64 %6, %7
br i1 %8, label %9, label %13
9: ; preds = %5
%10 = load i8, i8* %2
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 35
br label %13
13: ; preds = %9, %5
%14 = phi i1 [ false, %5 ], [ %12, %9 ]
br i1 %14, label %15, label %28
15: ; preds = %13
%16 = load i8, i8* %2
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 10
br i1 %18, label %19, label %27
19: ; preds = %15
%20 = load i32, i32* %3
%21 = mul nsw i32 %20, 2
%22 = load i8, i8* %2
%23 = sext i8 %22 to i32
%24 = add nsw i32 %21, %23
%25 = sub nsw i32 %24, 48
%26 = srem i32 %25, 131071
store i32 %26, i32* %3
br label %27
27: ; preds = %19, %15
br label %5
28: ; preds = %13
%29 = load i8, i8* %2
%30 = sext i8 %29 to i32
%31 = icmp ne i32 %30, 35
br i1 %31, label %32, label %33
32: ; preds = %28
br label %41
33: ; preds = %28
%34 = load i32, i32* %3
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %33
%37 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %40
38: ; preds = %33
%39 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %40
40: ; preds = %38, %36
br label %4
41: ; preds = %32
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
@EOF = global i64 0
@str = [4 x i8] c"YES\00"
@str.3 = [3 x i8] c"NO\00"
define i32 @main() {
%1 = alloca i8
br label %2
2: ; preds = %32, %0
%3 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %1)
%4 = load i64, i64* @EOF
%5 = icmp ne i64 %3, %4
%6 = load i8, i8* %1
%7 = icmp ne i8 %6, 35
%8 = select i1 %5, i1 %7, i1 false
br i1 %8, label %9, label %28
9: ; preds = %2, %19
%10 = phi i8 [ %24, %19 ], [ %6, %2 ]
%11 = phi i32 [ %20, %19 ], [ 0, %2 ]
%12 = icmp eq i8 %10, 10
br i1 %12, label %19, label %13
13: ; preds = %9
%14 = sext i8 %10 to i32
%15 = shl nsw i32 %11, 1
%16 = add i32 %15, -48
%17 = add i32 %16, %14
%18 = srem i32 %17, 131071
br label %19
19: ; preds = %13, %9
%20 = phi i32 [ %18, %13 ], [ %11, %9 ]
%21 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %1)
%22 = load i64, i64* @EOF
%23 = icmp ne i64 %21, %22
%24 = load i8, i8* %1
%25 = icmp ne i8 %24, 35
%26 = select i1 %23, i1 %25, i1 false
br i1 %26, label %9, label %27
27: ; preds = %19
br i1 %25, label %35, label %29
28: ; preds = %2
br i1 %7, label %35, label %31
29: ; preds = %27
%30 = icmp eq i32 %20, 0
br i1 %30, label %31, label %32
31: ; preds = %28, %29
br label %32
32: ; preds = %29, %31
%33 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0), %31 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @str.3, i64 0, i64 0), %29 ]
%34 = call i32 @puts(i8* dereferenceable(1) %33)
br label %2
35: ; preds = %28, %27
ret i32 0
}