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

plist = list(map(int,input().split()))

maxval = 0

temp = -1

dic = {}

def expectedval(inp):
	if inp in dic:
		return inp
	res = (1 + inp) /2
	return res

for i in range(n-(k-1)):
	summ = 0
	if temp == -1:
		for j in range (k):
			summ += expectedval(plist[i + j])
	else:
		summ = summ - expectedval(plist(i - 1)) + expectedval(plist(i + k))
	maxval = max(summ, maxval)

print(maxval)

Fixed submission:
n, k = map(int,input().split())

plist = list(map(int,input().split()))

maxval = 0

temp = -1

def expectedval(inp):
	return (1 + inp) /2

for i in range(n-(k-1)):
	# print(i, k)
	summ = 0
	if temp == -1:
		for j in range (k):
			summ += expectedval(plist[i + j])
		temp = summ
	else:
		# print(plist[i-1], plist[i+k -1], expectedval(plist[i - 1]), expectedval(plist[i + k - 1]))
		summ = temp - expectedval(plist[i - 1]) + expectedval(plist[i + k - 1])
		temp = summ
	# print(summ)
	maxval = max(summ, maxval)

print(maxval)

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

plist = list(map(int,input().split()))

maxval = 0

temp = -1

def expectedval(inp):
	return (1 + inp) /2

for i in range(n-(k-1)):
	summ = 0
	if temp == -1:
		for j in range (k):
			summ += expectedval(plist[i + j])
	else:
		summ = summ - expectedval(plist(i - 1)) + expectedval(plist(i + k))
	maxval = max(summ, maxval)

print(maxval)

Fixed submission:
n, k = map(int,input().split())

plist = list(map(int,input().split()))

maxval = 0

temp = -1

def expectedval(inp):
	return (1 + inp) /2

for i in range(n-(k-1)):
	# print(i, k)
	summ = 0
	if temp == -1:
		for j in range (k):
			summ += expectedval(plist[i + j])
		temp = summ
	else:
		# print(plist[i-1], plist[i+k -1], expectedval(plist[i - 1]), expectedval(plist[i + k - 1]))
		summ = temp - expectedval(plist[i - 1]) + expectedval(plist[i + k - 1])
		temp = summ
	# print(summ)
	maxval = max(summ, maxval)

print(maxval)

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

plist = list(map(int,input().split()))

maxval = 0


def expectedval(inp):
	return (1 + inp) /2

maxcomb = []
maxsum = 0
bestpos = 0

for i in range(n-(k-1)):
	summ = 0
	for j in range (k):
		summ += plist[i + j]
	if summ > maxsum:
		maxsum = summ
		bestpos = i

res = 0
for j in range (k):
	res += expectedval(plist[bestpos + j])

print(res)

Fixed submission:
n, k = map(int,input().split())

plist = list(map(int,input().split()))

maxval = 0

temp = -1

def expectedval(inp):
	return (1 + inp) /2

for i in range(n-(k-1)):
	# print(i, k)
	summ = 0
	if temp == -1:
		for j in range (k):
			summ += expectedval(plist[i + j])
		temp = summ
	else:
		# print(plist[i-1], plist[i+k -1], expectedval(plist[i - 1]), expectedval(plist[i + k - 1]))
		summ = temp - expectedval(plist[i - 1]) + expectedval(plist[i + k - 1])
		temp = summ
	# print(summ)
	maxval = max(summ, maxval)

print(maxval)

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

plist = list(map(int,input().split()))

maxval = 0


def expectedval(inp):
	return (1 + inp) * (inp/2) / inp

maxcomb = []
maxsum = 0
bestpos = 0

for i in range(n-(k-1)):
	summ = 0
	for j in range (k):
		summ += plist[i + j]
	if summ > maxsum:
		maxsum = summ
		bestpos = i

res = 0
for j in range (k):
	res += expectedval(plist[bestpos + j])

print(res)

Fixed submission:
n, k = map(int,input().split())

plist = list(map(int,input().split()))

maxval = 0

temp = -1

def expectedval(inp):
	return (1 + inp) /2

for i in range(n-(k-1)):
	# print(i, k)
	summ = 0
	if temp == -1:
		for j in range (k):
			summ += expectedval(plist[i + j])
		temp = summ
	else:
		# print(plist[i-1], plist[i+k -1], expectedval(plist[i - 1]), expectedval(plist[i + k - 1]))
		summ = temp - expectedval(plist[i - 1]) + expectedval(plist[i + k - 1])
		temp = summ
	# print(summ)
	maxval = max(summ, maxval)

print(maxval)

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

plist = list(map(int,input().split()))

maxval = 0

def expectedval(inp):
	return (1 + inp) * (inp/2) / inp


for i in range(n-(k-1)):
	summ = 0
	for j in range (k):
		summ += expectedval(plist[i + j])
	maxval = max(summ, maxval)

print(maxval)



Fixed submission:
n, k = map(int,input().split())

plist = list(map(int,input().split()))

maxval = 0

temp = -1

def expectedval(inp):
	return (1 + inp) /2

for i in range(n-(k-1)):
	# print(i, k)
	summ = 0
	if temp == -1:
		for j in range (k):
			summ += expectedval(plist[i + j])
		temp = summ
	else:
		# print(plist[i-1], plist[i+k -1], expectedval(plist[i - 1]), expectedval(plist[i + k - 1]))
		summ = temp - expectedval(plist[i - 1]) + expectedval(plist[i + k - 1])
		temp = summ
	# print(summ)
	maxval = max(summ, maxval)

print(maxval)