program kadai
integer  ::  N,K
integer,allocatable  ::  p(:)
real(8)  ::  ans,ans_max

read(*,*) N,K
allocate(p(N))
read(*,*) p

ans=0.0_8
do i=1,K
    ans=ans+p(i)
end do
ans_max=ans

do i=1,N-K
    ans=ans-p(i)
    ans=ans+p(i+K)
    !write(*,*) ans,ans_max
    ans_max=max(ans,ans_max)
end do
write(*,*) (ans_max+real(K,8))/2.0_8

end program kadai
; 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"

@_QFEp.0 = internal unnamed_addr global ptr null
@_QFEp.8 = internal unnamed_addr global i64 0
@_QQcl.67d22bb15fac5cd9c2bfd3ca993c1c47 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_2461/source.f\00"
@_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

define void @_QQmain() local_unnamed_addr {
  %1 = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.67d22bb15fac5cd9c2bfd3ca993c1c47, i32 6)
  %5 = call i1 @_FortranAioInputInteger(ptr %4, ptr nonnull %3, i32 4)
  %6 = call i1 @_FortranAioInputInteger(ptr %4, ptr nonnull %2, i32 4)
  %7 = call i32 @_FortranAioEndIoStatement(ptr %4)
  %8 = load i32, ptr %3, align 4, !tbaa !3
  %9 = call i32 @llvm.smax.i32(i32 %8, i32 0)
  %10 = zext i32 %9 to i64
  %11 = shl nuw nsw i64 %10, 2
  %12 = call ptr @malloc(i64 %11)
  store ptr %12, ptr @_QFEp.0, align 8, !tbaa !7
  store i64 %10, ptr @_QFEp.8, align 8, !tbaa !7
  %13 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.67d22bb15fac5cd9c2bfd3ca993c1c47, i32 8)
  %.unpack = load ptr, ptr @_QFEp.0, align 8, !tbaa !7
  %.unpack156.unpack.unpack158 = load i64, ptr @_QFEp.8, align 8, !tbaa !7
  store ptr %.unpack, ptr %1, align 8, !tbaa !7
  %.fca.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 1
  store i64 4, ptr %.fca.1.gep, align 8, !tbaa !7
  %.fca.2.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 2
  store i32 20180515, ptr %.fca.2.gep, align 8, !tbaa !7
  %.fca.3.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 3
  store i8 1, ptr %.fca.3.gep, align 4, !tbaa !7
  %.fca.4.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 4
  store i8 9, ptr %.fca.4.gep, align 1, !tbaa !7
  %.fca.5.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 5
  store i8 0, ptr %.fca.5.gep, align 2, !tbaa !7
  %.fca.6.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 6
  store i8 0, ptr %.fca.6.gep, align 1, !tbaa !7
  %.fca.7.0.0.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 0
  store i64 1, ptr %.fca.7.0.0.gep, align 8, !tbaa !7
  %.fca.7.0.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 1
  store i64 %.unpack156.unpack.unpack158, ptr %.fca.7.0.1.gep, align 8, !tbaa !7
  %.fca.7.0.2.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 2
  store i64 4, ptr %.fca.7.0.2.gep, align 8, !tbaa !7
  %14 = call i1 @_FortranAioInputDescriptor(ptr %13, ptr nonnull %1)
  %15 = call i32 @_FortranAioEndIoStatement(ptr %13)
  %16 = load i32, ptr %2, align 4, !tbaa !3
  %17 = icmp sgt i32 %16, 0
  br i1 %17, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0
  %18 = zext i32 %16 to i64
  %.unpack173 = load ptr, ptr @_QFEp.0, align 8, !tbaa !7
  %xtraiter = and i64 %18, 3
  %19 = icmp ult i32 %16, 4
  br i1 %19, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %18, 4294967292
  br label %20

20:                                               ; preds = %20, %.lr.ph.new
  %indvars.iv = phi i64 [ 1, %.lr.ph.new ], [ %indvars.iv.next.3, %20 ]
  %.0138185 = phi double [ 0.000000e+00, %.lr.ph.new ], [ %37, %20 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.3, %20 ]
  %21 = add nsw i64 %indvars.iv, -1
  %22 = getelementptr i32, ptr %.unpack173, i64 %21
  %23 = load i32, ptr %22, align 4, !tbaa !3
  %24 = sitofp i32 %23 to double
  %25 = fadd contract double %.0138185, %24
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %26 = getelementptr i32, ptr %.unpack173, i64 %indvars.iv
  %27 = load i32, ptr %26, align 4, !tbaa !3
  %28 = sitofp i32 %27 to double
  %29 = fadd contract double %25, %28
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %30 = getelementptr i32, ptr %.unpack173, i64 %indvars.iv.next
  %31 = load i32, ptr %30, align 4, !tbaa !3
  %32 = sitofp i32 %31 to double
  %33 = fadd contract double %29, %32
  %34 = getelementptr i32, ptr %.unpack173, i64 %indvars.iv.next.1
  %35 = load i32, ptr %34, align 4, !tbaa !3
  %36 = sitofp i32 %35 to double
  %37 = fadd contract double %33, %36
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.loopexit.unr-lcssa, label %20

._crit_edge.loopexit.unr-lcssa:                   ; preds = %20, %.lr.ph
  %.lcssa200.ph = phi double [ undef, %.lr.ph ], [ %37, %20 ]
  %indvars.iv.unr = phi i64 [ 1, %.lr.ph ], [ %indvars.iv.next.3, %20 ]
  %.0138185.unr = phi double [ 0.000000e+00, %.lr.ph ], [ %37, %20 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge.loopexit.unr-lcssa, %.epil.preheader
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.epil.preheader ], [ %indvars.iv.unr, %._crit_edge.loopexit.unr-lcssa ]
  %.0138185.epil = phi double [ %42, %.epil.preheader ], [ %.0138185.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.epil.preheader ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %38 = add nsw i64 %indvars.iv.epil, -1
  %39 = getelementptr i32, ptr %.unpack173, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !3
  %41 = sitofp i32 %40 to double
  %42 = fadd contract double %.0138185.epil, %41
  %indvars.iv.next.epil = add nuw nsw i64 %indvars.iv.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.epil.preheader, !llvm.loop !9

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.epil.preheader, %0
  %.0138.lcssa = phi double [ 0.000000e+00, %0 ], [ %.lcssa200.ph, %._crit_edge.loopexit.unr-lcssa ], [ %42, %.epil.preheader ]
  %43 = load i32, ptr %3, align 4, !tbaa !3
  %44 = sub i32 %43, %16
  %45 = icmp sgt i32 %44, 0
  br i1 %45, label %.lr.ph189, label %._crit_edge190

.lr.ph189:                                        ; preds = %._crit_edge
  %46 = zext i32 %44 to i64
  %.unpack161 = load ptr, ptr @_QFEp.0, align 8, !tbaa !7
  br label %47

47:                                               ; preds = %.lr.ph189, %47
  %indvars.iv194 = phi i64 [ 1, %.lr.ph189 ], [ %indvars.iv.next195, %47 ]
  %.0187 = phi double [ %.0138.lcssa, %.lr.ph189 ], [ %62, %47 ]
  %.1186 = phi double [ %.0138.lcssa, %.lr.ph189 ], [ %60, %47 ]
  %48 = add nsw i64 %indvars.iv194, -1
  %49 = getelementptr i32, ptr %.unpack161, i64 %48
  %50 = load i32, ptr %49, align 4, !tbaa !3
  %51 = sitofp i32 %50 to double
  %52 = fsub contract double %.1186, %51
  %53 = trunc i64 %indvars.iv194 to i32
  %54 = add i32 %16, %53
  %55 = sext i32 %54 to i64
  %56 = add nsw i64 %55, -1
  %57 = getelementptr i32, ptr %.unpack161, i64 %56
  %58 = load i32, ptr %57, align 4, !tbaa !3
  %59 = sitofp i32 %58 to double
  %60 = fadd contract double %52, %59
  %61 = fcmp ogt double %60, %.0187
  %62 = select i1 %61, double %60, double %.0187
  %indvars.iv.next195 = add nuw nsw i64 %indvars.iv194, 1
  %exitcond197.not = icmp eq i64 %indvars.iv194, %46
  br i1 %exitcond197.not, label %._crit_edge190, label %47

._crit_edge190:                                   ; preds = %47, %._crit_edge
  %.0.lcssa = phi double [ %.0138.lcssa, %._crit_edge ], [ %62, %47 ]
  %63 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.67d22bb15fac5cd9c2bfd3ca993c1c47, i32 22)
  %64 = load i32, ptr %2, align 4, !tbaa !3
  %65 = sitofp i32 %64 to double
  %66 = fadd contract double %.0.lcssa, %65
  %67 = fmul contract double %66, 5.000000e-01
  %68 = call i1 @_FortranAioOutputReal64(ptr %63, double %67)
  %69 = call i32 @_FortranAioEndIoStatement(ptr %63)
  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 i1 @_FortranAioInputDescriptor(ptr, ptr) local_unnamed_addr

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

declare i1 @_FortranAioOutputReal64(ptr, double) local_unnamed_addr

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

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

!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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.unroll.disable"}
