program main
  implicit none
  integer(8) :: n, a, i, j, j2
  integer(8), allocatable :: xn(:)
  integer(8), parameter :: MX = 2500
  integer(8) :: dp1(-MX:MX), dp2(-MX:MX)
  read(*, *) n, a
  allocate(xn(n))
  read(*, *) (xn(i), i = 1, n)

  do i = 1, n
    xn(i) = xn(i) - a
  end do

  dp1(:) = 0
  dp1(0) = 1

  do i = 1, n
    dp2(:) = dp1(:)
    do j = -MX, MX
      j2 = j + xn(i)
      if (-MX <= j2 .and. j2 <= MX) then
        dp2(j2) = dp2(j2) + dp1(j)
      end if
    end do
    dp1(:) = dp2(:)
  end do

  write(*, "(i0)") dp2(0) - 1

  deallocate(xn)
  contains
end

; ModuleID = 'FIRModule'
source_filename = "FIRModule"
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"

@_QFEdp1 = internal unnamed_addr global [5001 x i64] undef
@_QFEdp2 = internal unnamed_addr global [5001 x i64] undef
@_QFExn.0 = internal unnamed_addr global ptr null
@_QQcl.e6cfe12457d561a4475a411b2c435830 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_7935/source.f\00"
@_QQcl.28693029 = linkonce constant [4 x i8] c"(i0)"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #1

define void @_QQmain() local_unnamed_addr {
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  %3 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.e6cfe12457d561a4475a411b2c435830, i32 7)
  %4 = call i1 @_FortranAioInputInteger(ptr %3, ptr nonnull %2, i32 8)
  %5 = call i1 @_FortranAioInputInteger(ptr %3, ptr nonnull %1, i32 8)
  %6 = call i32 @_FortranAioEndIoStatement(ptr %3)
  %7 = load i64, ptr %2, align 8, !tbaa !3
  %8 = call i64 @llvm.smax.i64(i64 %7, i64 0)
  %9 = shl i64 %8, 3
  %10 = call ptr @malloc(i64 %9)
  store ptr %10, ptr @_QFExn.0, align 8, !tbaa !7
  %11 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.e6cfe12457d561a4475a411b2c435830, i32 9)
  %12 = load i64, ptr %2, align 8, !tbaa !3
  %13 = icmp sgt i64 %12, 0
  br i1 %13, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0, %.lr.ph
  %14 = phi i64 [ %18, %.lr.ph ], [ 1, %0 ]
  %.unpack177 = load ptr, ptr @_QFExn.0, align 8, !tbaa !7
  %15 = add i64 %14, -1
  %16 = getelementptr i64, ptr %.unpack177, i64 %15
  %17 = call i1 @_FortranAioInputInteger(ptr %11, ptr %16, i32 8)
  %18 = add nuw i64 %14, 1
  %exitcond.not = icmp eq i64 %14, %12
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %0
  %19 = call i32 @_FortranAioEndIoStatement(ptr %11)
  %20 = load i64, ptr %2, align 8, !tbaa !3
  %21 = icmp sgt i64 %20, 0
  br i1 %21, label %.lr.ph193, label %.preheader191.thread

.preheader191.thread:                             ; preds = %._crit_edge
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(40008) @_QFEdp1, i8 0, i64 40008, i1 false), !tbaa !3
  store i64 1, ptr getelementptr inbounds ([5001 x i64], ptr @_QFEdp1, i64 0, i64 2500), align 16, !tbaa !3
  br label %._crit_edge194

.lr.ph193:                                        ; preds = %._crit_edge
  %.unpack165 = load ptr, ptr @_QFExn.0, align 8, !tbaa !7
  %min.iters.check = icmp ult i64 %20, 6
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.memcheck

vector.memcheck:                                  ; preds = %.lr.ph193
  %22 = shl i64 %20, 3
  %uglygep = getelementptr i8, ptr %.unpack165, i64 %22
  %uglygep198 = getelementptr inbounds i8, ptr %1, i64 8
  %bound0 = icmp ult ptr %.unpack165, %uglygep198
  %bound1 = icmp ult ptr %1, %uglygep
  %found.conflict = and i1 %bound0, %bound1
  br i1 %found.conflict, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %vector.memcheck
  %n.vec = and i64 %20, -4
  %ind.end = or i64 %n.vec, 1
  %23 = load i64, ptr %1, align 8, !tbaa !3, !alias.scope !9
  %broadcast.splatinsert200 = insertelement <2 x i64> poison, i64 %23, i64 0
  %broadcast.splat201 = shufflevector <2 x i64> %broadcast.splatinsert200, <2 x i64> poison, <2 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %24 = getelementptr i64, ptr %.unpack165, i64 %index
  %wide.load = load <2 x i64>, ptr %24, align 8, !tbaa !3, !alias.scope !12, !noalias !9
  %25 = getelementptr i64, ptr %24, i64 2
  %wide.load199 = load <2 x i64>, ptr %25, align 8, !tbaa !3, !alias.scope !12, !noalias !9
  %26 = sub <2 x i64> %wide.load, %broadcast.splat201
  %27 = sub <2 x i64> %wide.load199, %broadcast.splat201
  store <2 x i64> %26, ptr %24, align 8, !tbaa !3, !alias.scope !12, !noalias !9
  store <2 x i64> %27, ptr %25, align 8, !tbaa !3, !alias.scope !12, !noalias !9
  %index.next = add nuw i64 %index, 4
  %28 = icmp eq i64 %index.next, %n.vec
  br i1 %28, label %middle.block, label %vector.body, !llvm.loop !14

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %20, %n.vec
  br i1 %cmp.n, label %.preheader191, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %vector.memcheck, %.lr.ph193, %middle.block
  %.ph = phi i64 [ 1, %vector.memcheck ], [ 1, %.lr.ph193 ], [ %ind.end, %middle.block ]
  %xtraiter = and i64 %20, 1
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %scalar.ph.prol.loopexit, label %scalar.ph.prol

scalar.ph.prol:                                   ; preds = %scalar.ph.preheader
  %29 = add nsw i64 %.ph, -1
  %30 = getelementptr i64, ptr %.unpack165, i64 %29
  %31 = load i64, ptr %30, align 8, !tbaa !3
  %32 = load i64, ptr %1, align 8, !tbaa !3
  %33 = sub i64 %31, %32
  store i64 %33, ptr %30, align 8, !tbaa !3
  %34 = add nuw i64 %.ph, 1
  br label %scalar.ph.prol.loopexit

scalar.ph.prol.loopexit:                          ; preds = %scalar.ph.prol, %scalar.ph.preheader
  %.unr = phi i64 [ %.ph, %scalar.ph.preheader ], [ %34, %scalar.ph.prol ]
  %35 = icmp eq i64 %20, %.ph
  br i1 %35, label %.preheader191, label %scalar.ph

.preheader191:                                    ; preds = %scalar.ph.prol.loopexit, %scalar.ph, %middle.block
  %.pre = load i64, ptr %2, align 8, !tbaa !3
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(40008) @_QFEdp1, i8 0, i64 40008, i1 false), !tbaa !3
  store i64 1, ptr getelementptr inbounds ([5001 x i64], ptr @_QFEdp1, i64 0, i64 2500), align 16, !tbaa !3
  %36 = icmp sgt i64 %.pre, 0
  br i1 %36, label %.preheader190.lr.ph, label %._crit_edge194

scalar.ph:                                        ; preds = %scalar.ph.prol.loopexit, %scalar.ph
  %37 = phi i64 [ %48, %scalar.ph ], [ %.unr, %scalar.ph.prol.loopexit ]
  %38 = add i64 %37, -1
  %39 = getelementptr i64, ptr %.unpack165, i64 %38
  %40 = load i64, ptr %39, align 8, !tbaa !3
  %41 = load i64, ptr %1, align 8, !tbaa !3
  %42 = sub i64 %40, %41
  store i64 %42, ptr %39, align 8, !tbaa !3
  %43 = add nuw i64 %37, 1
  %44 = getelementptr i64, ptr %.unpack165, i64 %37
  %45 = load i64, ptr %44, align 8, !tbaa !3
  %46 = load i64, ptr %1, align 8, !tbaa !3
  %47 = sub i64 %45, %46
  store i64 %47, ptr %44, align 8, !tbaa !3
  %48 = add nuw i64 %37, 2
  %exitcond195.not.1 = icmp eq i64 %43, %20
  br i1 %exitcond195.not.1, label %.preheader191, label %scalar.ph, !llvm.loop !17

.preheader190.lr.ph:                              ; preds = %.preheader191
  %.unpack153 = load ptr, ptr @_QFExn.0, align 8, !tbaa !7
  br label %.preheader190

.preheader190:                                    ; preds = %.preheader190.lr.ph, %.preheader.preheader
  %49 = phi i64 [ 1, %.preheader190.lr.ph ], [ %77, %.preheader.preheader ]
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(40008) @_QFEdp2, ptr noundef nonnull align 16 dereferenceable(40008) @_QFEdp1, i64 40008, i1 false), !tbaa !3
  %50 = add i64 %49, -1
  %51 = getelementptr i64, ptr %.unpack153, i64 %50
  %52 = load i64, ptr %51, align 8, !tbaa !3
  br label %53

53:                                               ; preds = %75, %.preheader190
  %54 = phi i64 [ -2500, %.preheader190 ], [ %76, %75 ]
  %55 = add nsw i64 %54, 2500
  %56 = add i64 %55, %52
  %57 = icmp ult i64 %56, 5001
  br i1 %57, label %58, label %64

58:                                               ; preds = %53
  %59 = getelementptr [5001 x i64], ptr @_QFEdp2, i64 0, i64 %56
  %60 = load i64, ptr %59, align 8, !tbaa !3
  %61 = getelementptr [5001 x i64], ptr @_QFEdp1, i64 0, i64 %55
  %62 = load i64, ptr %61, align 16, !tbaa !3
  %63 = add i64 %62, %60
  store i64 %63, ptr %59, align 8, !tbaa !3
  br label %64

64:                                               ; preds = %58, %53
  %exitcond196.not = icmp eq i64 %54, 2500
  br i1 %exitcond196.not, label %.preheader.preheader, label %65

65:                                               ; preds = %64
  %66 = add nsw i64 %54, 2501
  %67 = add i64 %66, %52
  %68 = icmp ult i64 %67, 5001
  br i1 %68, label %69, label %75

69:                                               ; preds = %65
  %70 = getelementptr [5001 x i64], ptr @_QFEdp2, i64 0, i64 %67
  %71 = load i64, ptr %70, align 8, !tbaa !3
  %72 = getelementptr [5001 x i64], ptr @_QFEdp1, i64 0, i64 %66
  %73 = load i64, ptr %72, align 8, !tbaa !3
  %74 = add i64 %73, %71
  store i64 %74, ptr %70, align 8, !tbaa !3
  br label %75

75:                                               ; preds = %69, %65
  %76 = add nsw i64 %54, 2
  br label %53

.preheader.preheader:                             ; preds = %64
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(40008) @_QFEdp1, ptr noundef nonnull align 16 dereferenceable(40008) @_QFEdp2, i64 40008, i1 false), !tbaa !3
  %77 = add nuw i64 %49, 1
  %exitcond197.not = icmp eq i64 %49, %.pre
  br i1 %exitcond197.not, label %._crit_edge194, label %.preheader190

._crit_edge194:                                   ; preds = %.preheader.preheader, %.preheader191.thread, %.preheader191
  %78 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.e6cfe12457d561a4475a411b2c435830, i32 29)
  %79 = load i64, ptr getelementptr inbounds ([5001 x i64], ptr @_QFEdp2, i64 0, i64 2500), align 16, !tbaa !3
  %80 = add i64 %79, -1
  %81 = call i1 @_FortranAioOutputInteger64(ptr %78, i64 %80)
  %82 = call i32 @_FortranAioEndIoStatement(ptr %78)
  %.unpack = load ptr, ptr @_QFExn.0, align 8, !tbaa !7
  call void @free(ptr %.unpack)
  store ptr null, ptr @_QFExn.0, align 8, !tbaa !7
  ret void
}

declare ptr @_FortranAioBeginExternalListInput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioInputInteger(ptr, ptr, i32) local_unnamed_addr

declare i32 @_FortranAioEndIoStatement(ptr) local_unnamed_addr

declare ptr @_FortranAioBeginExternalFormattedOutput(ptr, i64, ptr, i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger64(ptr, i64) local_unnamed_addr

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smax.i64(i64, i64) #2

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #1 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }

!llvm.module.flags = !{!0, !1, !2}

!0 = !{i32 2, !"Debug Info Version", i32 3}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{!4, !4, i64 0}
!4 = !{!"any data access", !5, i64 0}
!5 = !{!"any access", !6, i64 0}
!6 = !{!"Flang Type TBAA Root"}
!7 = !{!8, !8, i64 0}
!8 = !{!"descriptor member", !5, i64 0}
!9 = !{!10}
!10 = distinct !{!10, !11}
!11 = distinct !{!11, !"LVerDomain"}
!12 = !{!13}
!13 = distinct !{!13, !11}
!14 = distinct !{!14, !15, !16}
!15 = !{!"llvm.loop.isvectorized", i32 1}
!16 = !{!"llvm.loop.unroll.runtime.disable"}
!17 = distinct !{!17, !15}
