Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import copy

def main():
    N, K = map(int, input().split())
    p = list(map(float, input().split()))

    p = np.array(p)
    p_prime = p
    p_1 = p + 1
    p = p * p_1 / 2
    p = p / p_prime
    k = p
    for i in range(K-1):
        k = k + np.roll(p, i+1)

    print(max(k))


    return 0

if __name__ == '__main__':
    main()

Fixed submission:
import math
def main():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))

    P_e = []
    for p in P:
        P_e.append((1 + p)/2)

    P_sum = [0]
    tmp = 0
    for i in range(N):
        tmp += P_e[i]
        P_sum.append(tmp)

    max = 0
    for i in range(K, N+1):
        tmp = P_sum[i] - P_sum[i-K]
        if tmp > max:
            max = tmp

    print(max)
    return 0
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

def main():
    N, K = map(int, input().split())
    p = list(map(float, input().split()))

    p = np.array(p)
    p_prime = p
    p_1 = p + 1
    p = p * p_1 / 2
    p = p / p_prime

    su = 0
    for i in range(0, N-K+1):
        tmp = sum(p[i:(i+K)])
        if tmp > su:
            su = tmp
    print(su)


    return 0

if __name__ == '__main__':
    main()

Fixed submission:
import math
def main():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))

    P_e = []
    for p in P:
        P_e.append((1 + p)/2)

    P_sum = [0]
    tmp = 0
    for i in range(N):
        tmp += P_e[i]
        P_sum.append(tmp)

    max = 0
    for i in range(K, N+1):
        tmp = P_sum[i] - P_sum[i-K]
        if tmp > max:
            max = tmp

    print(max)
    return 0
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

def main():
    N, K = map(int, input().split())
    p = list(map(int, input().split()))

    su = 0
    l_sum = []
    i = 0
    while (N-K) >= i:
        tmp_p = p[i:(i+K)]
        if sum(tmp_p) >= su:
            su = sum(tmp_p)
            l_sum = tmp_p
        i += 1

    ans = 0

    l_sum = np.array(l_sum)
    l_r = l_sum
    l_sum_1 = l_sum + 1
    l_sum = l_sum * l_sum_1
    l_sum = l_sum / 2
    l_sum = l_sum / l_r
    print(sum(l_sum))




    return 0

if __name__ == '__main__':
    main()

Fixed submission:
import math
def main():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))

    P_e = []
    for p in P:
        P_e.append((1 + p)/2)

    P_sum = [0]
    tmp = 0
    for i in range(N):
        tmp += P_e[i]
        P_sum.append(tmp)

    max = 0
    for i in range(K, N+1):
        tmp = P_sum[i] - P_sum[i-K]
        if tmp > max:
            max = tmp

    print(max)
    return 0
if __name__ == '__main__':
    main()

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

    su = 0
    l_sum = []
    i = 0
    while (N-K) >= i:
        tmp_p = p[i:(i+K)]
        if sum(tmp_p) >= su:
            su = sum(tmp_p)
            l_sum = tmp_p
        i += 1

    ans = 0
    for l in l_sum:
        r = l * (l+1)
        r = r/2
        ans += r/l
    print(ans)



    return 0

if __name__ == '__main__':
    main()

Fixed submission:
import math
def main():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))

    P_e = []
    for p in P:
        P_e.append((1 + p)/2)

    P_sum = [0]
    tmp = 0
    for i in range(N):
        tmp += P_e[i]
        P_sum.append(tmp)

    max = 0
    for i in range(K, N+1):
        tmp = P_sum[i] - P_sum[i-K]
        if tmp > max:
            max = tmp

    print(max)
    return 0
if __name__ == '__main__':
    main()