Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
p = list(map(int, input().split()))

ans, ai = 0, 10**9
for i in range(N-K+1):
  sum = 0
  for k in range(K):
    sum += p[i+k]
  ans = max(ans, sum)
  if ans == sum:
    ai = i

dp = [0]*1001
dp[0] = 0
for i in range(1000):
  dp[i+1] = i+1 + dp[i]
  
ans, num = 0, 0
for i in range(ai, ai+K):
  ans += dp[p[i]]/p[i]

print(ans)

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

ans, ai = 0, -1
sum = 0
for i in range(N-K+1):
  if i == 0:
    for k in range(K):
      sum += p[i+k]
  else:
    sum = sum - p[i-1] + p[i+k]
  ans = max(ans, sum)
  if ans == sum:
    ai = i

dp = [0]*1001
dp[0] = 0
for i in range(1000):
  dp[i+1] = i+1 + dp[i]

ans = 0.0
for i in range(ai, ai+K):
  ans += dp[p[i]]/p[i]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
p = list(map(int, input().split()))

ans, ai = 0, 10**9
for i in range(N-K+1):
  sum = 0
  for k in range(K):
    sum += p[i+k]
  ans = max(ans, sum)
  if ans == sum:
    ai = i

ans, num = 0, 0
for i in range(ai, ai+K):
  tmp = 0
  for j in range(1,p[i]+1):
    tmp += j
  ans += tmp/p[i]

print(ans)

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

ans, ai = 0, -1
sum = 0
for i in range(N-K+1):
  if i == 0:
    for k in range(K):
      sum += p[i+k]
  else:
    sum = sum - p[i-1] + p[i+k]
  ans = max(ans, sum)
  if ans == sum:
    ai = i

dp = [0]*1001
dp[0] = 0
for i in range(1000):
  dp[i+1] = i+1 + dp[i]

ans = 0.0
for i in range(ai, ai+K):
  ans += dp[p[i]]/p[i]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
p = list(map(int, input().split()))

ans, ai = 0, 10**9
for i in range(N-K+1):
  sum = 0
  for k in range(K):
    sum += p[i+k]
  ans = max(ans, sum)
  if ans == sum:
    ai = i

ans, num = 0, 0
for i in range(ai, ai+K):
  tmp = 0
  for j in range(1,p[i]+1):
    tmp += j
  ans += tmp/p[i]

print(ans)

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

ans, ai = 0, -1
sum = 0
for i in range(N-K+1):
  if i == 0:
    for k in range(K):
      sum += p[i+k]
  else:
    sum = sum - p[i-1] + p[i+k]
  ans = max(ans, sum)
  if ans == sum:
    ai = i

dp = [0]*1001
dp[0] = 0
for i in range(1000):
  dp[i+1] = i+1 + dp[i]

ans = 0.0
for i in range(ai, ai+K):
  ans += dp[p[i]]/p[i]

print(ans)

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
p = list(map(int, input().split()))

def dice_sum(i):
  if i == 1:
    return 1
  else:
    return i + dice_sum(i-1)

ans = 0
for i in range(N-K+1):
  sum, num, ave = 0, 0, 0
  for k in range(K):
    sum = dice_sum(p[i+k])
    num = p[i+k]
    ave += sum/num
  ans = max(ans, ave)

print(ans)

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

ans, ai = 0, -1
sum = 0
for i in range(N-K+1):
  if i == 0:
    for k in range(K):
      sum += p[i+k]
  else:
    sum = sum - p[i-1] + p[i+k]
  ans = max(ans, sum)
  if ans == sum:
    ai = i

dp = [0]*1001
dp[0] = 0
for i in range(1000):
  dp[i+1] = i+1 + dp[i]

ans = 0.0
for i in range(ai, ai+K):
  ans += dp[p[i]]/p[i]

print(ans)

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
p = list(map(int, input().split()))

def dice_sum(i):
  if i == 1:
    return 1
  else:
    return i + dice_sum(i-1)

ans = 0
for i in range(N-K+1):
  sum, num, ave = 0, 0, 0
  for k in range(K):
    sum = dice_sum(p[i+k])
    num = p[i+k]
    ave += sum/num
  ans = max(ans, ave)

print(ans)

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

ans, ai = 0, -1
sum = 0
for i in range(N-K+1):
  if i == 0:
    for k in range(K):
      sum += p[i+k]
  else:
    sum = sum - p[i-1] + p[i+k]
  ans = max(ans, sum)
  if ans == sum:
    ai = i

dp = [0]*1001
dp[0] = 0
for i in range(1000):
  dp[i+1] = i+1 + dp[i]

ans = 0.0
for i in range(ai, ai+K):
  ans += dp[p[i]]/p[i]

print(ans)