Buggy python submission (verdict: Time Limit Exceeded):
n , k = map(int, input().split())
P = list(map(int, input().split()))

def dice_expctations(num:int)->float:
    return (num+1) / 2

E = list(map(dice_expctations, P))

back = 0
head = k-1
ans = 0
while head <= n-1:
    tmp = 0
    for i in range(back, head+1):
        tmp += E[i]
    if tmp > ans:
        ans = tmp
    else:
        pass
    back += 1
    head += 1

print(ans)




Fixed submission:
N,K=map(int,input().split())
p=list(map(int,input().split()))
pE=list(map(lambda i :(1+i)/2,p))
pA=[sum(pE[0:K])]
inter=sum(pE[0:K])
for i in range(0,N-K):
    inter=inter+pE[K+i]-pE[i]
    pA.append(inter)

ans=max(pA)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n , k = map(int, input().split())
P = list(map(int, input().split()))

def dice_expctations(num:int)->float:
    return (num+1) / 2

E = list(map(dice_expctations, P))

back = 0
head = k-1
ans = 0
while head <= n-1:
    tmp = 0
    for i in range(back, head+1):
        tmp += E[i]
    if tmp > ans:
        ans = tmp
    else:
        pass
    back += 1
    head += 1

print(ans)




Fixed submission:
N,K=map(int,input().split())
p=list(map(int,input().split()))
pE=list(map(lambda i :(1+i)/2,p))
pA=[sum(pE[0:K])]
inter=sum(pE[0:K])
for i in range(0,N-K):
    inter=inter+pE[K+i]-pE[i]
    pA.append(inter)

ans=max(pA)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
D=list(map(int,input().split()))
DE=list(map(lambda i :(1+i)/2,D))
DS=[]
A=[]
for i in range(0,N-K+1):
    DS.append(sum(DE[0:i+K])-sum(DE[0:i]))
ans=max(DS)
print(ans)



Fixed submission:
N,K=map(int,input().split())
p=list(map(int,input().split()))
pE=list(map(lambda i :(1+i)/2,p))
pA=[sum(pE[0:K])]
inter=sum(pE[0:K])
for i in range(0,N-K):
    inter=inter+pE[K+i]-pE[i]
    pA.append(inter)

ans=max(pA)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#1からaまでのa種類の目がそれぞれ等確率で出るサイコロの期待値を求める関数
def kitaiti(a):
    prob=1/a
    b=0
    for i in range(1,a+1):
        b+=i
    kitaiti=prob*b
    return kitaiti

N,K=map(int,input().split())
D=list(map(int,input().split()))
DE=list(map(kitaiti,D))

e=0
anse=0
for i in range(N-K+1):
    e=0
    for j in range(i,i+K):
        e+=DE[j]
    if anse<e:
        anse=e
    else:
        pass

print(anse)

Fixed submission:
N,K=map(int,input().split())
p=list(map(int,input().split()))
pE=list(map(lambda i :(1+i)/2,p))
pA=[sum(pE[0:K])]
inter=sum(pE[0:K])
for i in range(0,N-K):
    inter=inter+pE[K+i]-pE[i]
    pA.append(inter)

ans=max(pA)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def kitaiti(a):
    prob=1/a
    b=0
    for i in range(1,a+1):
        b+=i
    kitaiti=prob*b
    return kitaiti

N,K=map(int,input().split())
p=list(map(int,input().split()))

e=0
anse=0
for i in range(N-K+1):
    e=0
    for j in range(i,i+K):
        e+=kitaiti(p[j])
    if anse<e:
        anse=e
    else:
        pass

print(anse)

Fixed submission:
N,K=map(int,input().split())
p=list(map(int,input().split()))
pE=list(map(lambda i :(1+i)/2,p))
pA=[sum(pE[0:K])]
inter=sum(pE[0:K])
for i in range(0,N-K):
    inter=inter+pE[K+i]-pE[i]
    pA.append(inter)

ans=max(pA)
print(ans)