Buggy python submission (verdict: Time Limit Exceeded):
n, k = [int(x) for x in input().split()]
# ps = [int(x) for x in input().split()]

calc_expectedval = (lambda p: sum(range(p+1)) / p)
expected_vals = [calc_expectedval(int(x)) for x in input().split()]

prevval = sum(expected_vals[0:0+k])
maxval = prevval
for i in range(n - k):
  candidate = prevval - expected_vals[i] + expected_vals[i + k]   
  if candidate > maxval:
    maxval = candidate
  prevval = candidate
  
print(maxval)

Fixed submission:
n, k = [int(x) for x in input().split()]
# ps = [int(x) for x in input().split()]

continuous_sum = (lambda n: (n + 1) * (n // 2) + (0 if n %2 == 0 else n // 2 + 1))
calc_expectedval = (lambda p: continuous_sum(p) / p)
expected_vals = [calc_expectedval(int(x)) for x in input().split()]

prevval = sum(expected_vals[0:0+k])
maxval = prevval
for i in range(n - k):
  candidate = prevval - expected_vals[i] + expected_vals[i + k]
  if candidate > maxval:
    maxval = candidate
  prevval = candidate

print(maxval)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n, k = [int(x) for x in input().split()]
# ps = [int(x) for x in input().split()]

calc_expectedval = (lambda p: sum(range(p+1)) / p)
expected_vals = [calc_expectedval(int(x)) for x in input().split()]

convolved = np.convolve(expected_vals, np.ones(k))

print(max(convolved))

Fixed submission:
n, k = [int(x) for x in input().split()]
# ps = [int(x) for x in input().split()]

continuous_sum = (lambda n: (n + 1) * (n // 2) + (0 if n %2 == 0 else n // 2 + 1))
calc_expectedval = (lambda p: continuous_sum(p) / p)
expected_vals = [calc_expectedval(int(x)) for x in input().split()]

prevval = sum(expected_vals[0:0+k])
maxval = prevval
for i in range(n - k):
  candidate = prevval - expected_vals[i] + expected_vals[i + k]
  if candidate > maxval:
    maxval = candidate
  prevval = candidate

print(maxval)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = [int(x) for x in input().split()]
# ps = [int(x) for x in input().split()]

calc_expectedval = (lambda p: sum(range(p+1)) / p)
expected_vals = [calc_expectedval(int(x)) for x in input().split()]

# expected_vals = [sum(range(p+1)) / p for p in ps]

maxval = 0
for i in range(n - k + 1):
  candidate = sum(expected_vals[i:i+k])
  if candidate > maxval:
    maxval = candidate

print(maxval)


Fixed submission:
n, k = [int(x) for x in input().split()]
# ps = [int(x) for x in input().split()]

continuous_sum = (lambda n: (n + 1) * (n // 2) + (0 if n %2 == 0 else n // 2 + 1))
calc_expectedval = (lambda p: continuous_sum(p) / p)
expected_vals = [calc_expectedval(int(x)) for x in input().split()]

prevval = sum(expected_vals[0:0+k])
maxval = prevval
for i in range(n - k):
  candidate = prevval - expected_vals[i] + expected_vals[i + k]
  if candidate > maxval:
    maxval = candidate
  prevval = candidate

print(maxval)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = [int(x) for x in input().split()]
ps = [int(x) for x in input().split()]

expected_vals = [sum(range(p+1)) / p for p in ps]

maxval = 0
for i in range(n - k + 1):
  candidate = sum(expected_vals[i:i+k])
  if candidate > maxval:
    maxval = candidate

print(maxval)

Fixed submission:
n, k = [int(x) for x in input().split()]
# ps = [int(x) for x in input().split()]

continuous_sum = (lambda n: (n + 1) * (n // 2) + (0 if n %2 == 0 else n // 2 + 1))
calc_expectedval = (lambda p: continuous_sum(p) / p)
expected_vals = [calc_expectedval(int(x)) for x in input().split()]

prevval = sum(expected_vals[0:0+k])
maxval = prevval
for i in range(n - k):
  candidate = prevval - expected_vals[i] + expected_vals[i + k]
  if candidate > maxval:
    maxval = candidate
  prevval = candidate

print(maxval)