Buggy python submission (verdict: Time Limit Exceeded):
import sys
N, K = list(map(int, input().split()))
P = list(map(int, input().split()))
P = [i for i in P if 1 <= i and i <= 10**3]
Q = [] # 期待値リスト
R = []
r = 0
if not 1 <= K <= N <= 2*10**5:
    sys.exit()
for i in range(N):
    q = (1 + P[i]) / 2
    Q.append(q)
for j in range(N-K+1):
    r_max = sum(Q[j:j+K])
    if r <= r_max:
        r = r_max
print(r)

Fixed submission:
import sys

N, K = list(map(int, input().split()))
P = list(map(int, input().split()))
P = [i for i in P if 1 <= i and i <= 10**3]
Q = [] # 期待値リスト
S = [] # 累積和
T = [] # 隣接するK個の期待値
s=0

if not 1 <= K <= N <= 2*10**5:
    sys.exit()

for i in range(N):
    # q = sum(range(1, P[i]+1)) / P[i]
    q = (1 + P[i]) / 2
    Q.append(q)
    s += q
    S.append(s)
    if i == K-1:
        T.append(S[i])
    if i > K-1:
        T.append(S[i]-S[i-K])
print(max(T))

Buggy python submission (verdict: Time Limit Exceeded):
import sys

N, K = list(map(int, input().split()))
P = list(map(int, input().split()))
P = [i for i in P if 1 <= i and i <= 10**3]
Q = []
R = []
r = 0

if not 1 <= K <= N <= 2*10**5:
    sys.exit()

for i in range(N):
    q = (1 + P[i]) / 2
    Q.append(q)
    
for j in range(N-K+1):
    r = sum(Q[j:j+K])
    R.append(r)
print(max(R))

Fixed submission:
import sys

N, K = list(map(int, input().split()))
P = list(map(int, input().split()))
P = [i for i in P if 1 <= i and i <= 10**3]
Q = [] # 期待値リスト
S = [] # 累積和
T = [] # 隣接するK個の期待値
s=0

if not 1 <= K <= N <= 2*10**5:
    sys.exit()

for i in range(N):
    # q = sum(range(1, P[i]+1)) / P[i]
    q = (1 + P[i]) / 2
    Q.append(q)
    s += q
    S.append(s)
    if i == K-1:
        T.append(S[i])
    if i > K-1:
        T.append(S[i]-S[i-K])
print(max(T))

Buggy python submission (verdict: Time Limit Exceeded):
import sys

I = list(map(int, input().split()))
P = list(map(int, input().split()))
P = [i for i in P if 1 <= i and i <= 10**3]
N = I[0] # サイコロ数
K = I[1]
Q = []
R = []
r = 0

if not 1 <= K <= N <= 2*10**5:
    sys.exit()

for i in range(N):
    q = sum(range(1, P[i]+1)) / P[i]
    Q.append(q)
    for j in range(N-K+1):
        r = sum(Q[j:j+K])
        R.append(r)
print(max(R))

Fixed submission:
import sys

N, K = list(map(int, input().split()))
P = list(map(int, input().split()))
P = [i for i in P if 1 <= i and i <= 10**3]
Q = [] # 期待値リスト
S = [] # 累積和
T = [] # 隣接するK個の期待値
s=0

if not 1 <= K <= N <= 2*10**5:
    sys.exit()

for i in range(N):
    # q = sum(range(1, P[i]+1)) / P[i]
    q = (1 + P[i]) / 2
    Q.append(q)
    s += q
    S.append(s)
    if i == K-1:
        T.append(S[i])
    if i > K-1:
        T.append(S[i]-S[i-K])
print(max(T))

Buggy python submission (verdict: Time Limit Exceeded):
import sys

I = list(map(int, input().split()))
P = list(map(int, input().split()))
P = [i for i in P if 1 <= i and i <= 10**3]
N = I[0] # サイコロ数
K = I[1]
if not 1 <= K <= N <= 2*10**5:
    sys.exit()

Q = []
for i in range(N):
    q = sum(range(1, P[i]+1)) / P[i]
    Q.append(q)
# print(Q)

r = 0
R = []
for i in range(N-K+1):
    r = sum(Q[i:i+K])
    R.append(r)
# print(R)
print(max(R))
# rangeの終端は+1

Fixed submission:
import sys

N, K = list(map(int, input().split()))
P = list(map(int, input().split()))
P = [i for i in P if 1 <= i and i <= 10**3]
Q = [] # 期待値リスト
S = [] # 累積和
T = [] # 隣接するK個の期待値
s=0

if not 1 <= K <= N <= 2*10**5:
    sys.exit()

for i in range(N):
    # q = sum(range(1, P[i]+1)) / P[i]
    q = (1 + P[i]) / 2
    Q.append(q)
    s += q
    S.append(s)
    if i == K-1:
        T.append(S[i])
    if i > K-1:
        T.append(S[i]-S[i-K])
print(max(T))