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

def solve(n, k, p):
    E = {}
    p_map = {}
    for i, p_i in enumerate(p):
        E[p_i] = (1.0 + p_i)/2
        p_map[i] = p_i
    # pprint(E)
    
    ans = 0
    for i in range(n - k + 1):
        tmp_E = 0
        for j in range(k):
            tmp_E += E[p_map[i+j]]
        ans = max(ans, tmp_E)
    print(ans)

if __name__ == '__main__':
    n, k = map(int, sys.stdin.readline().strip().split(" "))
    p = list(map(int, sys.stdin.readline().strip().split(" ")))
    solve(n, k, p)

Fixed submission:
import sys
from pprint import pprint

def solve(n, k, p):
    acum_E = [0]
    sum_E = 0
    for i, p_i in enumerate(p):
        sum_E += (1.0 + p_i)/2 
        acum_E.append(sum_E)
    # pprint(acum_E)
    
    ans = 0
    for i in range(n - k + 1):
        # print(i+k, i)
        ans = max(ans, acum_E[i + k] - acum_E[i])
    print(ans)

if __name__ == '__main__':
    n, k = map(int, sys.stdin.readline().strip().split(" "))
    p = list(map(int, sys.stdin.readline().strip().split(" ")))
    solve(n, k, p)

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

def solve(n, k, p):
    E = {}
    p_map = {}
    for i, p_i in enumerate(p):
        E[p_i] = (1.0 + p_i)/2
        p_map[i] = p_i
    # pprint(E)
    
    ans = 0
    for i in range(n - k + 1):
        ans = max(ans, sum([E[p_map[i+j]] for j in range(k)]))
    print(ans)

if __name__ == '__main__':
    n, k = map(int, sys.stdin.readline().strip().split(" "))
    p = list(map(int, sys.stdin.readline().strip().split(" ")))
    solve(n, k, p)

Fixed submission:
import sys
from pprint import pprint

def solve(n, k, p):
    acum_E = [0]
    sum_E = 0
    for i, p_i in enumerate(p):
        sum_E += (1.0 + p_i)/2 
        acum_E.append(sum_E)
    # pprint(acum_E)
    
    ans = 0
    for i in range(n - k + 1):
        # print(i+k, i)
        ans = max(ans, acum_E[i + k] - acum_E[i])
    print(ans)

if __name__ == '__main__':
    n, k = map(int, sys.stdin.readline().strip().split(" "))
    p = list(map(int, sys.stdin.readline().strip().split(" ")))
    solve(n, k, p)

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

def solve(n, k, p):
    E = [(1.0 + p_i)/2 for p_i in p]
    # pprint(E)
    
    ans = 0
    for i in range(n - k + 1):
        ans = max(ans, sum(E[i:i+k]))
    print(ans)

if __name__ == '__main__':
    n, k = map(int, sys.stdin.readline().strip().split(" "))
    p = list(map(int, sys.stdin.readline().strip().split(" ")))
    solve(n, k, p)

Fixed submission:
import sys
from pprint import pprint

def solve(n, k, p):
    acum_E = [0]
    sum_E = 0
    for i, p_i in enumerate(p):
        sum_E += (1.0 + p_i)/2 
        acum_E.append(sum_E)
    # pprint(acum_E)
    
    ans = 0
    for i in range(n - k + 1):
        # print(i+k, i)
        ans = max(ans, acum_E[i + k] - acum_E[i])
    print(ans)

if __name__ == '__main__':
    n, k = map(int, sys.stdin.readline().strip().split(" "))
    p = list(map(int, sys.stdin.readline().strip().split(" ")))
    solve(n, k, p)

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

def solve(n, k, p):
    E = [(1.0 + p_i)/2 for p_i in p]
    # pprint(E)
    
    ans = 0
    for i in range(n - k + 1):
        # print(i+3)
        ans = max(ans, sum([E[i+j] for j in range(k)]))
        # print(i, sum([E[i+j] for j in range(k)]))
    print(ans)

if __name__ == '__main__':
    n, k = map(int, sys.stdin.readline().strip().split(" "))
    p = list(map(int, sys.stdin.readline().strip().split(" ")))
    solve(n, k, p)

Fixed submission:
import sys
from pprint import pprint

def solve(n, k, p):
    acum_E = [0]
    sum_E = 0
    for i, p_i in enumerate(p):
        sum_E += (1.0 + p_i)/2 
        acum_E.append(sum_E)
    # pprint(acum_E)
    
    ans = 0
    for i in range(n - k + 1):
        # print(i+k, i)
        ans = max(ans, acum_E[i + k] - acum_E[i])
    print(ans)

if __name__ == '__main__':
    n, k = map(int, sys.stdin.readline().strip().split(" "))
    p = list(map(int, sys.stdin.readline().strip().split(" ")))
    solve(n, k, p)

Buggy python submission (verdict: Runtime Error):
def solve(n, k, p):
    E = [(1.0 + p_i)/2 for p_i in p]
    # pprint(E)
    
    ans = 0
    for i in range(n - k + 1):
        # print(i+3)
        ans = max(ans, sum([E[i+j] for j in range(k)]))
        # print(i, sum([E[i+j] for j in range(k)]))
    print(ans)

if __name__ == '__main__':
    n, k = map(int, sys.stdin.readline().strip().split(" "))
    p = list(map(int, sys.stdin.readline().strip().split(" ")))
    solve(n, k, p)

Fixed submission:
import sys
from pprint import pprint

def solve(n, k, p):
    acum_E = [0]
    sum_E = 0
    for i, p_i in enumerate(p):
        sum_E += (1.0 + p_i)/2 
        acum_E.append(sum_E)
    # pprint(acum_E)
    
    ans = 0
    for i in range(n - k + 1):
        # print(i+k, i)
        ans = max(ans, acum_E[i + k] - acum_E[i])
    print(ans)

if __name__ == '__main__':
    n, k = map(int, sys.stdin.readline().strip().split(" "))
    p = list(map(int, sys.stdin.readline().strip().split(" ")))
    solve(n, k, p)