Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
ans,sums = 0,[0]*K
for i,pi in enumerate(map(int, input().split())):
  sums[i%K] = (pi+1)/2
  ans = max(ans, sum(sums))
print(ans)

Fixed submission:
from itertools import accumulate
N, K = map(int, input().split())
ans = [0] + list(accumulate(map(lambda x: (int(x)+1)/2., input().split())))
print(max([y-x for x,y in zip(ans, ans[K:])]))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
E = lambda x: (x+1)*(x/2)/x
N, K = map(int, input().split())
sums = deque([0]*K)
ans = 0
for pi in map(int, input().split()):
  sums.popleft(); sums.append(E(pi))
  ans = max(ans, sum(sums))
print(ans)

Fixed submission:
from itertools import accumulate
N, K = map(int, input().split())
ans = [0] + list(accumulate(map(lambda x: (int(x)+1)/2., input().split())))
print(max([y-x for x,y in zip(ans, ans[K:])]))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
E = lambda x: (x+1)*(x/2)/x
N, K = map(int, input().split())
sums = deque([0]*K)
ans = 0
for pi in map(int, input().split()):
  sums.popleft(); sums.append(E(pi))
  ans = max(ans, sum(sums))
print(ans)


Fixed submission:
from itertools import accumulate
N, K = map(int, input().split())
ans = [0] + list(accumulate(map(lambda x: (int(x)+1)/2., input().split())))
print(max([y-x for x,y in zip(ans, ans[K:])]))

Buggy python submission (verdict: Time Limit Exceeded):
E = lambda x: (x+1)*(x/2)/x
N, K = map(int, input().split())
Es = [E(pi) for pi in map(int, input().split())]
sums = [sum(Es[:i]) for i in range(N+1)]
print(max([sj-si for sj,si in zip(sums[K:],sums)]))

Fixed submission:
from itertools import accumulate
N, K = map(int, input().split())
ans = [0] + list(accumulate(map(lambda x: (int(x)+1)/2., input().split())))
print(max([y-x for x,y in zip(ans, ans[K:])]))

Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
double E(double x){
  return (x+1.) * x / 2. / x;
}

int main(){
  int N,K;
  cin >> N >> K;
  vector<double> Es(N,0);
  double ans = 0;
  auto itr = Es.begin();
  for(int i=0; i<N; i++){
    cin >> *itr;
    *itr = E(*itr); 
    itr++;
    if(i+1 >= K) ans = max(ans, accumulate(prev(itr,K), itr, 0.0));
  }
  cout << ans << endl;
}

Fixed submission:
from itertools import accumulate
N, K = map(int, input().split())
ans = [0] + list(accumulate(map(lambda x: (int(x)+1)/2., input().split())))
print(max([y-x for x,y in zip(ans, ans[K:])]))

Buggy python submission (verdict: Time Limit Exceeded):
E = lambda x: x if x==1 else (x+1)*(x/2)/x
N, K = map(int, input().split())
Es = [E(pi) for pi in map(int, input().split())]
print(max([sum(Es[i:i+K]) for i in range(N+1-K)]))

Fixed submission:
from itertools import accumulate
N, K = map(int, input().split())
ans = [0] + list(accumulate(map(lambda x: (int(x)+1)/2., input().split())))
print(max([y-x for x,y in zip(ans, ans[K:])]))

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
ps = list(map(int, input().split()))
E = lambda x: x if x==1 else (x+1)*(x/2)/x
ans = (0,0)
for i in range(N-(K-1)):
  s = sum(ps[i:i+K])
  ans = (i,s) if ans[1] < s else ans
print(sum(map(E, ps[ans[0]:ans[0]+K])))

Fixed submission:
from itertools import accumulate
N, K = map(int, input().split())
ans = [0] + list(accumulate(map(lambda x: (int(x)+1)/2., input().split())))
print(max([y-x for x,y in zip(ans, ans[K:])]))