#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 *, int *, int *);
int main() {
  int N, C, S, E, exe, cap_at = 0;
  scanf(" %d %d", &N, &C);
  exe = 0;
  while (N > 0) {
    scanf(" %d %d", &S, &E);
    cap_at -= S;
    cap_at += E;
    if (cap_at > C)
      exe = 1;
    N--;
  }
  exe ? printf("S") : printf("N");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xec3(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    11a4 <main+0x84>
lea    0xe9e(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1040 <scanf@plt>
mov    -0x10(%rbp),%ecx
mov    -0x1c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    1196 <main+0x76>
movl   $0x1,-0x18(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1151 <main+0x31>
cmpl   $0x0,-0x18(%rbp)
je     11bf <main+0x9f>
lea    0xe52(%rip),%rdi
call   1030 <printf@plt>
jmp    11cb <main+0xab>
lea    0xe43(%rip),%rdi
call   1030 <printf@plt>
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
sub    $0x18,%rsp
lea    0xecb(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0x14(%rsp),%rdx
call   1040 <scanf@plt>
cmpl   $0x0,0x8(%rsp)
jle    11a7 <main+0x87>
xor    %ebp,%ebp
lea    0xeac(%rip),%r14
lea    0x10(%rsp),%r15
lea    0xc(%rsp),%r12
mov    $0x1,%r13d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1040 <scanf@plt>
sub    0x10(%rsp),%ebp
add    0xc(%rsp),%ebp
cmp    0x14(%rsp),%ebp
cmovg  %r13d,%ebx
mov    0x8(%rsp),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,0x8(%rsp)
cmp    $0x1,%eax
jg     1170 <main+0x50>
mov    $0x53,%edi
test   %ebx,%ebx
jne    11ac <main+0x8c>
mov    $0x4e,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c" %d %d\00"
@.str.1 = [2 x i8] c"S\00"
@.str.2 = [2 x i8] c"N\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %7
%8 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3)
store i32 0, i32* %6
br label %9
9: ; preds = %24, %0
%10 = load i32, i32* %2
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %27
12: ; preds = %9
%13 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %4, i32* %5)
%14 = load i32, i32* %4
%15 = load i32, i32* %7
%16 = sub nsw i32 %15, %14
store i32 %16, i32* %7
%17 = load i32, i32* %5
%18 = load i32, i32* %7
%19 = add nsw i32 %18, %17
store i32 %19, i32* %7
%20 = load i32, i32* %7
%21 = load i32, i32* %3
%22 = icmp sgt i32 %20, %21
br i1 %22, label %23, label %24
23: ; preds = %12
store i32 1, i32* %6
br label %24
24: ; preds = %23, %12
%25 = load i32, i32* %2
%26 = add nsw i32 %25, -1
store i32 %26, i32* %2
br label %9
27: ; preds = %9
%28 = load i32, i32* %6
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %34
32: ; preds = %27
%33 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %34
34: ; preds = %32, %30
%35 = phi i32 [ %31, %30 ], [ %33, %32 ]
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c" %d %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%10 = load i32, i32* %1
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %28
12: ; preds = %0, %12
%13 = phi i32 [ %19, %12 ], [ 0, %0 ]
%14 = phi i32 [ %22, %12 ], [ 0, %0 ]
%15 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %4)
%16 = load i32, i32* %3
%17 = sub nsw i32 %13, %16
%18 = load i32, i32* %4
%19 = add nsw i32 %17, %18
%20 = load i32, i32* %2
%21 = icmp sgt i32 %19, %20
%22 = select i1 %21, i32 1, i32 %14
%23 = load i32, i32* %1
%24 = add nsw i32 %23, -1
store i32 %24, i32* %1
%25 = icmp sgt i32 %23, 1
br i1 %25, label %12, label %26
26: ; preds = %12
%27 = icmp eq i32 %22, 0
br i1 %27, label %28, label %29
28: ; preds = %0, %26
br label %29
29: ; preds = %26, %28
%30 = phi i32 [ 78, %28 ], [ 83, %26 ]
%31 = call i32 @putchar(i32 %30)
ret i32 0
}