Buggy python submission (verdict: Time Limit Exceeded):
def calc_expected_value(n):
    sum_n = [i for i in range(1, n+1)]
    return sum(sum_n) / n


n, k_range = map(int, input().split())
p = list(map(int, input().split()))
e_list = [0] * n
ans_list = [0] * n
ans = 0.0

for i in range(n):
    if i < k_range-1:
        e_list[i] = calc_expected_value(p[i])
    elif i == k_range-1:
        e_list[i] = calc_expected_value(p[i])
        ans_list[i] = sum([e_list[i-k] for k in range(k_range)])
    else:
        e_list[i] = calc_expected_value(p[i])
        # ans = max(ans, sum([e_list[i-k] for k in range(k_range)]))
        ans_list[i] = ans_list[i-1] + e_list[i] - e_list[i-k_range]

print(max(ans_list))

Fixed submission:
def calc_expected_value(n):
    return (n+1) / 2


n, k_range = map(int, input().split())
p = list(map(int, input().split()))
e_list = [0] * n
ans_list = [0] * n
ans = 0.0

for i in range(n):
    e_list[i] = calc_expected_value(p[i])
    if i == k_range-1:
        ans_list[i] = sum([e_list[i-k] for k in range(k_range)])
    else:
        ans_list[i] = ans_list[i-1] + e_list[i] - e_list[i-k_range]

print(max(ans_list))

Buggy python submission (verdict: Time Limit Exceeded):
def calc_expected_value(n):
    sum_n = [i for i in range(1, n+1)]
    return sum(sum_n) / n


n, k_range = map(int, input().split())
p = list(map(int, input().split()))
e_list = [0] * (n+1)
ans = 0.0

for i in range(n):
    if i < k_range-1:
        e_list[i] = calc_expected_value(p[i])
    else:
        e_list[i] = calc_expected_value(p[i])
        ans = max(ans, sum([e_list[i-k] for k in range(k_range)]))

print(ans)

Fixed submission:
def calc_expected_value(n):
    return (n+1) / 2


n, k_range = map(int, input().split())
p = list(map(int, input().split()))
e_list = [0] * n
ans_list = [0] * n
ans = 0.0

for i in range(n):
    e_list[i] = calc_expected_value(p[i])
    if i == k_range-1:
        ans_list[i] = sum([e_list[i-k] for k in range(k_range)])
    else:
        ans_list[i] = ans_list[i-1] + e_list[i] - e_list[i-k_range]

print(max(ans_list))

Buggy python submission (verdict: Time Limit Exceeded):
def calc_expected_value(n):
    sum_n = [i for i in range(1, n+1)]
    return sum(sum_n) / n


n, k_range = map(int, input().split())
p = list(map(int, input().split()))
sum_dice_num = 0
ans = 0.0

for i in range(n-k_range+1):
    k_dice_num = sum(p[i:i+k_range])
    if k_dice_num < sum_dice_num:
        continue
    else:
        e = sum([calc_expected_value(p[i+k]) for k in range(k_range)])
        sum_dice_num = k_dice_num
        ans = max(ans, e)

print(ans)

Fixed submission:
def calc_expected_value(n):
    return (n+1) / 2


n, k_range = map(int, input().split())
p = list(map(int, input().split()))
e_list = [0] * n
ans_list = [0] * n
ans = 0.0

for i in range(n):
    e_list[i] = calc_expected_value(p[i])
    if i == k_range-1:
        ans_list[i] = sum([e_list[i-k] for k in range(k_range)])
    else:
        ans_list[i] = ans_list[i-1] + e_list[i] - e_list[i-k_range]

print(max(ans_list))

Buggy python submission (verdict: Time Limit Exceeded):
def calc_expected_value(n):
    sum_n = [i for i in range(1, n+1)]
    return sum(sum_n) / n


n, k_range = map(int, input().split())
p = list(map(int, input().split()))
ans = 0.0

for i in range(n-k_range+1):
    e = sum([calc_expected_value(p[i+k]) for k in range(k_range)])
    ans = max(ans, e)

print(ans)

Fixed submission:
def calc_expected_value(n):
    return (n+1) / 2


n, k_range = map(int, input().split())
p = list(map(int, input().split()))
e_list = [0] * n
ans_list = [0] * n
ans = 0.0

for i in range(n):
    e_list[i] = calc_expected_value(p[i])
    if i == k_range-1:
        ans_list[i] = sum([e_list[i-k] for k in range(k_range)])
    else:
        ans_list[i] = ans_list[i-1] + e_list[i] - e_list[i-k_range]

print(max(ans_list))