#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 long *);
int main() {
  long long int n;
  while (1) {
    scanf("%lld", &n);
    if (n == -1)
      break;
    double an = (n - 1.00) / 3;
    long long int t;
    int flag = 0;
    for (t = 0;; t++) {
      if ((double)(t * (t + 1)) == an) {
        flag = 1;
        break;
      }
      if ((t * (t + 1)) > an)
        break;
    }
    if (flag == 0)
      printf("N\n");
    else
      printf("Y\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
cmpq   $0xffffffffffffffff,-0x10(%rbp)
jne    114f <main+0x2f>
jmp    121a <main+0xfa>
cvtsi2sdq -0x10(%rbp),%xmm0
movsd  0xeab(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xe97(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x20(%rbp),%rcx
add    $0x1,%rcx
imul   %rcx,%rax
cvtsi2sd %rax,%xmm0
ucomisd -0x18(%rbp),%xmm0
jne    11b3 <main+0x93>
jp     11b3 <main+0x93>
movl   $0x1,-0x24(%rbp)
jmp    11ee <main+0xce>
mov    -0x20(%rbp),%rax
mov    -0x20(%rbp),%rcx
add    $0x1,%rcx
imul   %rcx,%rax
cvtsi2sd %rax,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11d8 <main+0xb8>
jmp    11ee <main+0xce>
jmp    11dd <main+0xbd>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1181 <main+0x61>
cmpl   $0x0,-0x24(%rbp)
jne    1209 <main+0xe9>
lea    0xe16(%rip),%rdi
call   1030 <printf@plt>
jmp    1215 <main+0xf5>
lea    0xe08(%rip),%rdi
call   1030 <printf@plt>
jmp    112f <main+0xf>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xee1(%rip),%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
mov    (%rsp),%rax
cmp    $0xffffffffffffffff,%rax
je     11c3 <main+0xa3>
lea    0xecb(%rip),%rbx
lea    0xec2(%rip),%r12
lea    0xeb6(%rip),%r14
mov    %rsp,%r15
nopl   (%rax)
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0xe90(%rip),%xmm0
divsd  0xe90(%rip),%xmm0
mov    $0x1,%eax
nopl   (%rax)
lea    -0x1(%rax),%rcx
imul   %rax,%rcx
xorps  %xmm1,%xmm1
cvtsi2sd %rcx,%xmm1
add    $0x1,%rax
ucomisd %xmm0,%xmm1
jb     1180 <main+0x60>
ucomisd %xmm1,%xmm0
mov    %r12,%rdi
cmovne %rbx,%rdi
cmovp  %rbx,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    (%rsp),%rax
cmp    $0xffffffffffffffff,%rax
jne    1160 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%lld\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 double
%4 = alloca i64
%5 = alloca i32
store i32 0, i32* %1
br label %6
6: ; preds = %0, %45
%7 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %2)
%8 = load i64, i64* %2
%9 = icmp eq i64 %8, -1
br i1 %9, label %10, label %11
10: ; preds = %6
br label %46
11: ; preds = %6
%12 = load i64, i64* %2
%13 = sitofp i64 %12 to double
%14 = fsub double %13, 1.000000e+00
%15 = fdiv double %14, 3.000000e+00
store double %15, double* %3
store i32 0, i32* %5
store i64 0, i64* %4
br label %16
16: ; preds = %35, %11
%17 = load i64, i64* %4
%18 = load i64, i64* %4
%19 = add nsw i64 %18, 1
%20 = mul nsw i64 %17, %19
%21 = sitofp i64 %20 to double
%22 = load double, double* %3
%23 = fcmp oeq double %21, %22
br i1 %23, label %24, label %25
24: ; preds = %16
store i32 1, i32* %5
br label %38
25: ; preds = %16
%26 = load i64, i64* %4
%27 = load i64, i64* %4
%28 = add nsw i64 %27, 1
%29 = mul nsw i64 %26, %28
%30 = sitofp i64 %29 to double
%31 = load double, double* %3
%32 = fcmp ogt double %30, %31
br i1 %32, label %33, label %34
33: ; preds = %25
br label %38
34: ; preds = %25
br label %35
35: ; preds = %34
%36 = load i64, i64* %4
%37 = add nsw i64 %36, 1
store i64 %37, i64* %4
br label %16
38: ; preds = %33, %24
%39 = load i32, i32* %5
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %38
%42 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %45
43: ; preds = %38
%44 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %45
45: ; preds = %43, %41
br label %6
46: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%lld\00"
@str = [2 x i8] c"Y\00"
@str.3 = [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 ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %1)
%4 = load i64, i64* %1
%5 = icmp eq i64 %4, -1
br i1 %5, label %24, label %6
6: ; preds = %0, %17
%7 = phi i64 [ %22, %17 ], [ %4, %0 ]
%8 = sitofp i64 %7 to double
%9 = fadd double %8, -1.000000e+00
%10 = fdiv double %9, 3.000000e+00
br label %11
11: ; preds = %11, %6
%12 = phi i64 [ 0, %6 ], [ %13, %11 ]
%13 = add nuw nsw i64 %12, 1
%14 = mul nsw i64 %13, %12
%15 = sitofp i64 %14 to double
%16 = fcmp ugt double %10, %15
br i1 %16, label %11, label %17
17: ; preds = %11
%18 = fcmp oeq double %10, %15
%19 = select i1 %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @str.3, i64 0, i64 0)
%20 = call i32 @puts(i8* dereferenceable(1) %19)
%21 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %1)
%22 = load i64, i64* %1
%23 = icmp eq i64 %22, -1
br i1 %23, label %24, label %6
24: ; preds = %17, %0
ret i32 0
}