Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, p: "List[int]"):
    max_value = 0
    for i in range(N - K + 1):
        compare_value = sum(p[i : i + K])

        if max_value < compare_value:
            max_value = max(max_value, compare_value)
            index_first = i
        else:
            pass
    # print(max_value)
    # print(index_first)
    result = 0
    for j in range(K):
        idm = (p[index_first + j] / 2) * (1 + p[index_first + j])
        idm /= p[index_first + j]
        result += idm
    print(result)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, p)


if __name__ == "__main__":
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
import numpy as np


def solve(N: int, K: int, p: "List[int]"):
    cumsum = np.cumsum(p)
    # print(cumsum)
    max_value = 0
    index_first = 0
    for i in range(N - K):
        if max_value < cumsum[i + K] - cumsum[i]:
            max_value = max(max_value, cumsum[i + K] - cumsum[i])
            index_first = i + 1

    # print(max_value)
    # print(index_first)
    result = 0
    for j in range(K):
        idm = (p[index_first + j] / 2) * (1 + p[index_first + j])
        idm = idm / p[index_first + j]
        result += idm

    print(result)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, p)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, p: "List[int]"):
    max_value = 0
    for i in range(N - K + 1):
        compare_value = sum([p[i + k] for k in range(K)])

        if max_value < compare_value:
            max_value = max(max_value, compare_value)
            index_first = i
        else:
            pass
    # print(max_value)
    # print(index_first)
    result = 0
    for j in range(K):
        result += sum(
            [i / p[index_first + j] for i in range(1, p[index_first + j] + 1)]
        )
    print(result)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, p)


if __name__ == "__main__":
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
import numpy as np


def solve(N: int, K: int, p: "List[int]"):
    cumsum = np.cumsum(p)
    # print(cumsum)
    max_value = 0
    index_first = 0
    for i in range(N - K):
        if max_value < cumsum[i + K] - cumsum[i]:
            max_value = max(max_value, cumsum[i + K] - cumsum[i])
            index_first = i + 1

    # print(max_value)
    # print(index_first)
    result = 0
    for j in range(K):
        idm = (p[index_first + j] / 2) * (1 + p[index_first + j])
        idm = idm / p[index_first + j]
        result += idm

    print(result)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, p)


if __name__ == "__main__":
    main()