#import <stdio.h>
#define MAXINDEX 2500
typedef long long INT;
INT getValue(INT *A, INT i){
    return A[i+MAXINDEX+1];
}
void setValue(INT *A, INT i, INT value){
    A[i+MAXINDEX+1] = value;
}
int main(){
    INT N,M;
    scanf("%lld %lld",&N,&M);
    INT A[2*MAXINDEX+2] = {0};
    INT B[2*MAXINDEX+2] = {0};
    setValue(A,0,1);
    INT *C = A;
    INT *D = B;
    for(INT i=0;i<N;i++){
        INT x;
        scanf("%lld",&x);
        for(INT j=-MAXINDEX;j<=MAXINDEX;j++){
            INT k = j - (x-M);
            setValue(D, j, getValue(C,j) + getValue(C,k));
        }
        INT *E = D;
        D = C;
        C = E;
    }
    printf("%lld",getValue(C,0)-1);
}

; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/ObjectiveC/Source_914/source.m'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/ObjectiveC/Source_914/source.m"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"

@.str = private unnamed_addr constant [10 x i8] c"%lld %lld\00", align 1
@.str.1 = private unnamed_addr constant [5 x i8] c"%lld\00", align 1

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local i64 @getValue(ptr nocapture noundef readonly %A, i64 noundef %i) local_unnamed_addr #0 {
entry:
  %0 = getelementptr i64, ptr %A, i64 %i
  %arrayidx = getelementptr i64, ptr %0, i64 2501
  %1 = load i64, ptr %arrayidx, align 8, !tbaa !5
  ret i64 %1
}

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) uwtable
define dso_local void @setValue(ptr nocapture noundef writeonly %A, i64 noundef %i, i64 noundef %value) local_unnamed_addr #1 {
entry:
  %0 = getelementptr i64, ptr %A, i64 %i
  %arrayidx = getelementptr i64, ptr %0, i64 2501
  store i64 %value, ptr %arrayidx, align 8, !tbaa !5
  ret void
}

; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #2 {
entry:
  %N = alloca i64, align 8
  %M = alloca i64, align 8
  %A = alloca [5002 x i64], align 16
  %B = alloca [5002 x i64], align 16
  %x = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %N) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %M) #6
  %call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %N, ptr noundef nonnull %M)
  call void @llvm.lifetime.start.p0(i64 40016, ptr nonnull %A) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(40016) %A, i8 0, i64 40016, i1 false)
  call void @llvm.lifetime.start.p0(i64 40016, ptr nonnull %B) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(40016) %B, i8 0, i64 40016, i1 false)
  %arrayidx.i = getelementptr inbounds i64, ptr %A, i64 2501
  store i64 1, ptr %arrayidx.i, align 8, !tbaa !5
  %0 = load i64, ptr %N, align 8, !tbaa !5
  %cmp35 = icmp sgt i64 %0, 0
  br i1 %cmp35, label %for.body, label %for.cond.cleanup

for.cond.cleanup.loopexit:                        ; preds = %for.cond.cleanup6
  %.pre = load i64, ptr %invariant.gep32, align 8, !tbaa !5
  %1 = add nsw i64 %.pre, -1
  br label %for.cond.cleanup

for.cond.cleanup:                                 ; preds = %for.cond.cleanup.loopexit, %entry
  %sub15 = phi i64 [ 0, %entry ], [ %1, %for.cond.cleanup.loopexit ]
  %call16 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %sub15)
  call void @llvm.lifetime.end.p0(i64 40016, ptr nonnull %B) #6
  call void @llvm.lifetime.end.p0(i64 40016, ptr nonnull %A) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %M) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %N) #6
  ret i32 0

for.body:                                         ; preds = %entry, %for.cond.cleanup6
  %C.038 = phi ptr [ %D.037, %for.cond.cleanup6 ], [ %A, %entry ]
  %D.037 = phi ptr [ %C.038, %for.cond.cleanup6 ], [ %B, %entry ]
  %i.036 = phi i64 [ %inc12, %for.cond.cleanup6 ], [ 0, %entry ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %x) #6
  %call3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
  %invariant.gep = getelementptr i64, ptr %C.038, i64 2501
  %invariant.gep32 = getelementptr i64, ptr %D.037, i64 2501
  br label %for.body7

for.cond.cleanup6:                                ; preds = %for.body7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %x) #6
  %inc12 = add nuw nsw i64 %i.036, 1
  %2 = load i64, ptr %N, align 8, !tbaa !5
  %cmp = icmp slt i64 %inc12, %2
  br i1 %cmp, label %for.body, label %for.cond.cleanup.loopexit

for.body7:                                        ; preds = %for.body7.1, %for.body
  %j.034 = phi i64 [ -2500, %for.body ], [ %inc.1, %for.body7.1 ]
  %3 = load i64, ptr %x, align 8, !tbaa !5
  %4 = load i64, ptr %M, align 8, !tbaa !5
  %sub.neg = sub i64 %j.034, %3
  %gep = getelementptr i64, ptr %invariant.gep, i64 %j.034
  %5 = load i64, ptr %gep, align 8, !tbaa !5
  %6 = getelementptr i64, ptr %invariant.gep, i64 %sub.neg
  %gep31 = getelementptr i64, ptr %6, i64 %4
  %7 = load i64, ptr %gep31, align 8, !tbaa !5
  %add = add nsw i64 %7, %5
  %gep33 = getelementptr i64, ptr %invariant.gep32, i64 %j.034
  store i64 %add, ptr %gep33, align 8, !tbaa !5
  %inc = or i64 %j.034, 1
  %exitcond.not = icmp eq i64 %inc, 2501
  br i1 %exitcond.not, label %for.cond.cleanup6, label %for.body7.1

for.body7.1:                                      ; preds = %for.body7
  %8 = load i64, ptr %x, align 8, !tbaa !5
  %9 = load i64, ptr %M, align 8, !tbaa !5
  %sub.neg.1 = sub i64 %inc, %8
  %gep.1 = getelementptr i64, ptr %invariant.gep, i64 %inc
  %10 = load i64, ptr %gep.1, align 8, !tbaa !5
  %11 = getelementptr i64, ptr %invariant.gep, i64 %sub.neg.1
  %gep31.1 = getelementptr i64, ptr %11, i64 %9
  %12 = load i64, ptr %gep31.1, align 8, !tbaa !5
  %add.1 = add nsw i64 %12, %10
  %gep33.1 = getelementptr i64, ptr %invariant.gep32, i64 %inc
  store i64 %add.1, ptr %gep33.1, align 8, !tbaa !5
  %inc.1 = add nsw i64 %j.034, 2
  br label %for.body7
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #3

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #3

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { nounwind }

!llvm.linker.options = !{}
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
