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

calRes = 0
calIndex = 0
expectedList = []

for i in range(N):
    cal = list(range(1, p[i] + 1))
    expectedList.append(sum(cal) * (1 / len(cal)))

for o in range(N - (K - 1)):
    calTemp = sum(expectedList[o:o + K])
    if calRes < calTemp:
       calRes = calTemp
       calIndex = o

expectedCorrect = sum(expectedList[calIndex : calIndex + K])

print(expectedCorrect)

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

expectedList = [(1 + s) /  2 for s in p]
cumsum = sum(expectedList[:K])
confirm_cumsum = cumsum

for i in range(K, N):
    cumsum += expectedList[i]
    cumsum -= expectedList[i - K]
    if cumsum > confirm_cumsum:
        confirm_cumsum = cumsum

print(confirm_cumsum)

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

calRes = 0
calIndex = 0
expectedList = []
expectedCorList = []

for i in range(N):
    cal = list(range(1, p[i] + 1))
    expectedList.append(sum(cal) * (1 / len(cal)))

    calTemp = sum(expectedList[i:i + K])
    if calRes < calTemp:
       calRes = calTemp
       calIndex = i

for l in range(K):
    expectedCorList.append(expectedList[calIndex + l])

calCor = sum(expectedCorList)
print(calCor)

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

expectedList = [(1 + s) /  2 for s in p]
cumsum = sum(expectedList[:K])
confirm_cumsum = cumsum

for i in range(K, N):
    cumsum += expectedList[i]
    cumsum -= expectedList[i - K]
    if cumsum > confirm_cumsum:
        confirm_cumsum = cumsum

print(confirm_cumsum)

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

calRes = 0
calIndex = 0
expectedList = []
expectedCorList = []
Counter = 0

for i in range(N):
    cal = list(range(1, p[i] + 1))
    Counter += 1
    expectedList.append(sum(cal) * (1 / len(cal)))

for o in range(N - 2):
    calTemp = sum(expectedList[o:o + K])
    if calRes < calTemp:
       calRes = calTemp
       calIndex = o

for l in range(K):
    expectedCorList.append(expectedList[calIndex + l])

calCor = sum(expectedCorList)
print(calCor)

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

expectedList = [(1 + s) /  2 for s in p]
cumsum = sum(expectedList[:K])
confirm_cumsum = cumsum

for i in range(K, N):
    cumsum += expectedList[i]
    cumsum -= expectedList[i - K]
    if cumsum > confirm_cumsum:
        confirm_cumsum = cumsum

print(confirm_cumsum)

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

calRes = 0
calIndex = 0
expectedList = []
expectedCorList = []
Counter = 0

for i in range(N):
    cal = list(range(1, p[i] + 1))
    Counter += 1
    expectedList.append(sum(cal) * (1 / len(cal)))

for o in range(N - 2):
    calTemp = sum(expectedList[o:o + K])
    if calRes < calTemp:
       calRes = calTemp
       calIndex = o

for l in range(K):
    expectedCorList.append(expectedList[calIndex + l])

calCor = sum(expectedCorList)
print(calCor)

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

expectedList = [(1 + s) /  2 for s in p]
cumsum = sum(expectedList[:K])
confirm_cumsum = cumsum

for i in range(K, N):
    cumsum += expectedList[i]
    cumsum -= expectedList[i - K]
    if cumsum > confirm_cumsum:
        confirm_cumsum = cumsum

print(confirm_cumsum)

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

calEnd = N - 2
calCount = 0
calRes = 0
calIndex = 0
calCor = 0
calList = []
Counter = 0

for i in range(N - 2):
    calTemp = p[i] + p[i + 1] + p[i + 2]
    if calRes <= calTemp:
       calRes = calTemp
       calIndex = i
    
    calCount += 1

for o in range(K):
    cal = list(range(1, p[calIndex + Counter] + 1))
    Counter += 1
    calList.append(sum(cal) * (1 / len(cal)))

calCor = sum(calList)
print(calCor)

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

expectedList = [(1 + s) /  2 for s in p]
cumsum = sum(expectedList[:K])
confirm_cumsum = cumsum

for i in range(K, N):
    cumsum += expectedList[i]
    cumsum -= expectedList[i - K]
    if cumsum > confirm_cumsum:
        confirm_cumsum = cumsum

print(confirm_cumsum)