#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 */
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, long *);
float sqrt(float);
int main() {
  long int N;
  scanf("%ld", &N);
  while (N != -1) {
    N--;
    if (N % 6 != 0) {
      printf("N\n");
      scanf("%ld", &N);
      continue;
    }
    N = N / 6;
    int n = (int)((-1.0f + sqrt(1.0f + 8.0f * N)) / 2.0f);
    if ((n * (n + 1) / 2) == N) {
      printf("Y\n");
    } else {
      printf("N\n");
    }
    scanf("%ld", &N);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
cmpq   $0xffffffffffffffff,-0x10(%rbp)
je     1248 <main+0x118>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x6,%ecx
cqto
idiv   %rcx
cmp    $0x0,%rdx
je     119f <main+0x6f>
lea    0xe8f(%rip),%rdi
call   1030 <printf@plt>
lea    0xe7f(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
jmp    114f <main+0x1f>
mov    -0x10(%rbp),%rax
mov    $0x6,%ecx
cqto
idiv   %rcx
mov    %rax,-0x10(%rbp)
cvtsi2ssq -0x10(%rbp),%xmm0
movss  0xe49(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe41(%rip),%xmm1
addss  %xmm1,%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movss  0xe25(%rip),%xmm0
addss  %xmm1,%xmm0
movss  0xe15(%rip),%xmm1
divss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
imul   %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cltq
cmp    -0x10(%rbp),%rax
jne    1227 <main+0xf7>
lea    0xdfa(%rip),%rdi
call   1030 <printf@plt>
jmp    1233 <main+0x103>
lea    0xde6(%rip),%rdi
call   1030 <printf@plt>
lea    0xdd6(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
jmp    114f <main+0x1f>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xed2(%rip),%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
mov    (%rsp),%rcx
cmp    $0xffffffffffffffff,%rcx
je     1246 <main+0x116>
movabs $0x2aaaaaaaaaaaaaab,%rbx
aa aa 2a
movabs $0xaaaaaaaaaaaaaaab,%r12
aa aa aa
movabs $0x2aaaaaaaaaaaaaaa,%r13
aa aa 2a
lea    0xe9d(%rip),%rbp
lea    0xe90(%rip),%r14
mov    %rsp,%r15
jmp    11ae <main+0x7e>
nopl   0x0(%rax)
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    (%rsp),%rcx
cmp    $0xffffffffffffffff,%rcx
je     1246 <main+0x116>
add    $0xffffffffffffffff,%rcx
mov    %rcx,(%rsp)
mov    %rcx,%rax
imul   %rbx
imul   %r12,%rcx
add    %r13,%rcx
ror    %rcx
mov    %rbp,%rdi
cmp    %rbx,%rcx
jae    1190 <main+0x60>
mov    %rdx,%rax
shr    $0x3f,%rax
add    %rdx,%rax
mov    %rax,(%rsp)
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
mulss  0xe14(%rip),%xmm0
addss  0xe10(%rip),%xmm0
ucomiss 0xe15(%rip),%xmm0
jb     1203 <main+0xd3>
sqrtss %xmm0,%xmm0
jmp    1208 <main+0xd8>
call   1050 <sqrt@plt>
addss  0xdf8(%rip),%xmm0
mulss  0xdf4(%rip),%xmm0
cvttss2si %xmm0,%eax
lea    0x1(%rax),%ecx
imul   %eax,%ecx
mov    %ecx,%eax
shr    $0x1f,%eax
add    %ecx,%eax
sar    %eax
cltq
lea    0xde4(%rip),%rdi
cmp    %rax,(%rsp)
je     1190 <main+0x60>
mov    %rbp,%rdi
jmp    1190 <main+0x60>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%ld\00"
@.str.1 = [3 x i8] c"N\0A\00"
@.str.2 = [3 x i8] c"Y\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %2)
br label %5
5: ; preds = %39, %14, %0
%6 = load i64, i64* %2
%7 = icmp ne i64 %6, -1
br i1 %7, label %8, label %41
8: ; preds = %5
%9 = load i64, i64* %2
%10 = add nsw i64 %9, -1
store i64 %10, i64* %2
%11 = load i64, i64* %2
%12 = srem i64 %11, 6
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %8
%15 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %2)
br label %5
17: ; preds = %8
%18 = load i64, i64* %2
%19 = sdiv i64 %18, 6
store i64 %19, i64* %2
%20 = load i64, i64* %2
%21 = sitofp i64 %20 to float
%22 = call float @llvm.fmuladd.f32(float 8.000000e+00, float %21, float 1.000000e+00)
%23 = call float @sqrt(float %22)
%24 = fadd float -1.000000e+00, %23
%25 = fdiv float %24, 2.000000e+00
%26 = fptosi float %25 to i32
store i32 %26, i32* %3
%27 = load i32, i32* %3
%28 = load i32, i32* %3
%29 = add nsw i32 %28, 1
%30 = mul nsw i32 %27, %29
%31 = sdiv i32 %30, 2
%32 = sext i32 %31 to i64
%33 = load i64, i64* %2
%34 = icmp eq i64 %32, %33
br i1 %34, label %35, label %37
35: ; preds = %17
%36 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %39
37: ; preds = %17
%38 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %39
39: ; preds = %37, %35
%40 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %2)
br label %5
41: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%ld\00"
@str.3 = [2 x i8] c"Y\00"
@str.4 = [2 x i8] c"N\00"
define i32 @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %1)
%4 = load i64, i64* %1
%5 = icmp eq i64 %4, -1
br i1 %5, label %32, label %6
6: ; preds = %0, %12
%7 = phi i64 [ %16, %12 ], [ %4, %0 ]
%8 = add nsw i64 %7, -1
store i64 %8, i64* %1
%9 = srem i64 %8, 6
%10 = sdiv i64 %8, 6
%11 = icmp eq i64 %9, 0
br i1 %11, label %18, label %12
12: ; preds = %6, %18
%13 = phi i8* [ %31, %18 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @str.4, i64 0, i64 0), %6 ]
%14 = call i32 @puts(i8* dereferenceable(1) %13)
%15 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %1)
%16 = load i64, i64* %1
%17 = icmp eq i64 %16, -1
br i1 %17, label %32, label %6
18: ; preds = %6
store i64 %10, i64* %1
%19 = sitofp i64 %10 to float
%20 = call float @llvm.fmuladd.f32(float %19, float 8.000000e+00, float 1.000000e+00)
%21 = call float @sqrt(float %20)
%22 = fadd float %21, -1.000000e+00
%23 = fmul float %22, 5.000000e-01
%24 = fptosi float %23 to i32
%25 = add nsw i32 %24, 1
%26 = mul nsw i32 %25, %24
%27 = sdiv i32 %26, 2
%28 = sext i32 %27 to i64
%29 = load i64, i64* %1
%30 = icmp eq i64 %29, %28
%31 = select i1 %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @str.4, i64 0, i64 0)
br label %12
32: ; preds = %12, %0
ret i32 0
}