Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
def print_ans(N, sr):
    """Test Case
    >>> print_ans(3, ["acornistnt", "peanutbomb", "constraint"])
    1
    >>> print_ans(2, ["oneplustwo", "ninemodsix"])
    0
    >>> print_ans(5,["abaaaaaaaa","oneplustwo","aaaaaaaaba","twoplusone","aaaabaaaaa"]) 
    4
    """
    for i in range(N):
        sr[i] = "".join(sorted(sr[i]))
    count = 0
    for i in range(N):
        tmp = sr[i]
        for k in range(i + 1, N):
            if tmp == sr[k]:
                count +=1
    print(count)


if __name__ == '__main__':
    N = int(input().rstrip())
    sr = [ input().rstrip() for _ in range(N)]
    print_ans(N, sr)


Fixed submission:
import sys
input = sys.stdin.readline
from collections import Counter
def print_ans(N, sr):
    """Test Case
    >>> print_ans(3, ["acornistnt", "peanutbomb", "constraint"])
    1
    >>> print_ans(2, ["oneplustwo", "ninemodsix"])
    0
    >>> print_ans(5,["abaaaaaaaa","oneplustwo","aaaaaaaaba","twoplusone","aaaabaaaaa"]) 
    4
    """
    for i in range(N):
        sr[i] = "".join(sorted(sr[i]))
    C = Counter(sr)
    ans = 0
    for v in C.values():
        ans += v * (v - 1) // 2
    print(ans)

    # for i in range(N):
    #     tmp = sr[i]
    #     for k in range(i + 1, N):
    #         if tmp == sr[k]:
    #             count +=1
    # print(count)


if __name__ == '__main__':
    N = int(input().rstrip())
    sr = [ input().rstrip() for _ in range(N)]
    print_ans(N, sr)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
def print_ans(N, sr):
    """Test Case
    >>> print_ans(3, ["acornistnt", "peanutbomb", "constraint"])
    1
    >>> print_ans(2, ["oneplustwo", "ninemodsix"])
    0
    >>> print_ans(5,["abaaaaaaaa","oneplustwo","aaaaaaaaba","twoplusone","aaaabaaaaa"]) 
    4
    """
    check_ar = []
    for s in sr:
        check_ar.append("".join(sorted(s)))
    count = 0
    for i in range(N):
        tmp = check_ar[i]
        for k in range(i + 1, N):
            if tmp == check_ar[k]:
                count +=1
    print(count)


if __name__ == '__main__':
    N = int(input().rstrip())
    sr = [ input().rstrip() for _ in range(N)]
    print_ans(N, sr)


Fixed submission:
import sys
input = sys.stdin.readline
from collections import Counter
def print_ans(N, sr):
    """Test Case
    >>> print_ans(3, ["acornistnt", "peanutbomb", "constraint"])
    1
    >>> print_ans(2, ["oneplustwo", "ninemodsix"])
    0
    >>> print_ans(5,["abaaaaaaaa","oneplustwo","aaaaaaaaba","twoplusone","aaaabaaaaa"]) 
    4
    """
    for i in range(N):
        sr[i] = "".join(sorted(sr[i]))
    C = Counter(sr)
    ans = 0
    for v in C.values():
        ans += v * (v - 1) // 2
    print(ans)

    # for i in range(N):
    #     tmp = sr[i]
    #     for k in range(i + 1, N):
    #         if tmp == sr[k]:
    #             count +=1
    # print(count)


if __name__ == '__main__':
    N = int(input().rstrip())
    sr = [ input().rstrip() for _ in range(N)]
    print_ans(N, sr)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
def print_ans(N):
    """Test Case
    >>> print_ans(11)
    9
    >>> print_ans(136)
    46
    >>> print_ans(100000)
    90909
    """
    # counter = 0
    # for i in range(1, N + 1):
    #     if len(str(i)) % 2 != 0:
    #         counter +=1
    # print(counter)
    length = len(str(N))
    ans = []

    for i in reversed(range(length - 1)):
        if i % 2 == 0:
            ans.append("9")
        else:
            ans.append("0")
    answer = int("".join(ans))
    if length % 2 != 0:
        answer += N % (10 ** (length -1)) + 1
    print(answer)


if __name__ == '__main__':
    N = int(input().rstrip())
    print_ans(N)


Fixed submission:
import sys
input = sys.stdin.readline
def print_ans(N):
    """Test Case
    >>> print_ans(11)
    9
    >>> print_ans(136)
    46
    >>> print_ans(100000)
    90909
    """
    counter = 0
    for i in range(1, N + 1):
        if len(str(i)) % 2 != 0:
            counter +=1
    print(counter)

if __name__ == '__main__':
    N = int(input().rstrip())
    print_ans(N)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import math
def print_ans(N, D):
    """Test Case
    >>> print_ans(6, 2)
    2
    >>> print_ans(14, 3)
    2
    >>> print_ans(20, 4)
    3
    """
    print(math.ceil(N / (D * 2 + 1)))
    

if __name__ == '__main__':
    N, D = map(int,input().rstrip().sprit())
    print_ans(N, D)


Fixed submission:
import sys
input = sys.stdin.readline
import math
def print_ans(N, D):
    """Test Case
    >>> print_ans(6, 2)
    2
    >>> print_ans(14, 3)
    2
    >>> print_ans(20, 4)
    3
    """
    print(math.ceil(N / (D * 2 + 1)))
    

if __name__ == '__main__':
    N, D = map(int,input().rstrip().split())
    print_ans(N, D)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
import math
def print_ans(N, ar):
    """Test Case
    >>> print_ans(3, [1, 4, 3])
    4
    3
    4
    >>> print_ans(2, [5, 5])
    5
    5
    """
    for i in range(N):
        ans_max = 1
        for k in range(N):
            if i != k:
                ans_max = max(ans_max, ar[k])
        print(ans_max)

if __name__ == '__main__':
    N = int(input().rstrip())
    ar = [int(input().rstrip()) for i in range(N)]
    print_ans(N, ar)


Fixed submission:
import sys
input = sys.stdin.readline
import numpy as np
def print_ans(N, ar):
    """Test Case
    >>> print_ans(3, [1, 4, 3])
    4
    3
    4
    >>> print_ans(2, [5, 5])
    5
    5
    """
    ar = np.array(ar)
    ar_idx = np.argsort(ar)

    for i in range(N):
        for k in reversed(range(N)):
            if i != ar_idx[k]:
                print(ar[ar_idx[k]])
                break

if __name__ == '__main__':
    N = int(input().rstrip())
    ar = [int(input().rstrip()) for i in range(N)]
    print_ans(N, ar)
Buggy python submission (verdict: Runtime Error):
# B problem
import numpy as np
def check_abs(arr, lists):
    ret = 0
    for i, k in lists:
        tmp = ( arr - k ) ** 2
        if (np.sum(tmp) ** 0.5).is_integer():
            ret += 1
    return ret
T = input()
N, D = map(int,T.split())
lists = []
for i in range(N):
    data = input().split()
    tmp = list(map(int, data))
    lists.append(tmp)
tmp2 = np.array(lists)
for i in range(N):
    ress = 0
    arr = tmp2[i]
    np.delete(tmp2, i, 0)
    res = check_abs(arr, tmp2)
    ress += res
print(ress)

Fixed submission:
import sys
input = sys.stdin.readline
import numpy as np
def print_ans(N, D, dr):
    """Test Case
    >>> print_ans(3, 2, [[1, 2], [5, 5], [-2, 8]])
    1
    >>> print_ans(3, 4, [[-3, 7, 8, 2], [-12, 1, 10, 2], [-2, 8, 9, 3]])
    2
    >>> print_ans(5, 1, [[1],[2],[3],[4],[5]])
    10
    """
    dr = [np.array(d) for d in dr]
    ans = 0
    for i in range(N-1):
        for k in range(i + 1, N):
            multi_ar = dr[i] - dr[k] 
            abs_tmp = float(np.sum(multi_ar ** 2) ** (1/2))
            if(abs_tmp.is_integer()):
                ans += 1
    print(ans)



if __name__ == '__main__':
    N, D = map(int, input().rstrip().split())
    dr = [list(map(int, input().rstrip().split())) for _ in range(N)]
    print_ans(N, D, dr)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import numpy as np
def print_ans(A, B, C, D):
    """Test Case
    >>> print_ans(4, 9, 2, 3)
    2
    >>> print_ans(10, 40, 6, 8)
    23
    >>> print_ans(314159265358979323, 846264338327950288, 419716939, 937510582)
    532105071133627368
    """
    ar = np.arange(A, B + 1)
    cr = ar[ar % C != 0]
    dr = cr[cr % D != 0]
    print(len(dr))

if __name__ == '__main__':
    A, B, C, D = map(int, input().rstrip().split())
    print_ans(A, B, C, D)




Fixed submission:
import sys
input = sys.stdin.readline
import numpy as np
def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x
def calc(x, C, D, l):
    x1 = x // C
    x2 = x // D
    x3 = x // l
    return x - x1 -x2 + x3

def print_ans(A, B, C, D):
    """Test Case
    >>> print_ans(4, 9, 2, 3)
    2
    >>> print_ans(10, 40, 6, 8)
    23
    >>> print_ans(314159265358979323, 846264338327950288, 419716939, 937510582)
    532105071133627368
    """
    # Greatest common divisor
    g = gcd(max(C,D),min(C,D))
    # Least common multiple
    l = C * D // g
    print(calc(B, C, D, l) - calc(A - 1, C, D, l))



if __name__ == '__main__':
    A, B, C, D = map(int, input().rstrip().split())
    print_ans(A, B, C, D)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
def print_ans(N, a_list):
    """Test Case
    >>> print_ans(3, [7, 6, 8])
    2
    >>> print_ans(3, [12, 15, 18])
    6
    >>> print_ans(2, [1000000000, 1000000000])
    1000000000
    """
    m_list = []
    a_list.append(0)
    for i in range(N):
        m = 0
        for k in range(i):
            m = gcd(max(m, a_list[k]), min(m, a_list[k]))
        for l in range(i + 1, N + 1):
            m = gcd(max(m, a_list[l]), min(m, a_list[l]))
        m_list.append(m)
    print(max(m_list))

if __name__ == '__main__':
    N = int(input().rstrip())
    a_list = list(map(int, input().rstrip().split()))
    print_ans(N, a_list)


Fixed submission:
import sys
input = sys.stdin.readline
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from fractions import *
def print_ans(N, a_list):
    """Test Case
    >>> print_ans(3, [0, 7, 6, 8, 0])
    2
    >>> print_ans(3, [0, 12, 15, 18, 0])
    6
    >>> print_ans(2, [0, 1000000000, 1000000000,0])
    1000000000
    """
    l_list = [0 for _ in range(N + 2)]
    r_list = [0 for _ in range(N + 2)]
    for i in range(1, N + 1):
        l_list[i] = gcd(l_list[i-1], a_list[i])
    for i in range(N, 0, -1):
            r_list[i] = gcd(r_list[i + 1], a_list[i])
    m_list = [0 for _ in range(N + 1)]
    for i in range(1, N + 1):
        m_list[i] = gcd(l_list[i - 1],r_list[i+ 1])
    print(max(m_list))

if __name__ == '__main__':
    N = int(input().rstrip())
    a_list = [0] + list(map(int, input().rstrip().split())) + [0]
    print_ans(N, a_list)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
def print_ans(N, Q, S, arr):
    """Test Case
    >>> print_ans(8, 3, "ACACTACG", [[3, 7], [2, 3], [1, 8]])
    2
    0
    3
    """
    ans_list = [S[ar[0]-1:ar[1]].count("AC") for ar in arr]
    for ans in ans_list:
        print(ans)

if __name__ == '__main__':
    N, Q = map(int, input().rstrip().split())
    S = input().rstrip()
    arr = [list(map(int, input().rstrip().split())) for _ in range(Q)]
    print_ans(N, Q, S, arr)


Fixed submission:
import sys
input = sys.stdin.readline
def print_ans(N, Q, S, arr):
    """Test Case
    >>> print_ans(8, 3, "ACACTACG", [[3, 7], [2, 3], [1, 8]])
    2
    0
    3
    """
    t = [0] * (N+1)
    for i in range(N):
        t[i+1] = t[i] + (1 if S[i:i+2] == "AC" else 0)
    for ar in arr:
        print(t[ar[1] - 1] - t[ar[0] - 1] )

if __name__ == '__main__':
    N, Q = map(int, input().rstrip().split())
    S = input().rstrip()
    arr = [list(map(int, input().rstrip().split())) for _ in range(Q)]
    print_ans(N, Q, S, arr)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
def print_ans(N, Q, S, arr):
    """Test Case
    >>> print_ans(8, 3, "ACACTACG", [[3, 7], [2, 3], [1, 8]])
    2
    0
    3
    """
    for ar in arr:
        tmp_S = S[ar[0] - 1:ar[1]]
        print(tmp_S.count("AC"))

if __name__ == '__main__':
    N, Q = map(int, input().rstrip().split())
    S = input().rstrip()
    arr = [list(map(int, input().rstrip().split())) for _ in range(Q)]
    print_ans(N, Q, S, arr)


Fixed submission:
import sys
input = sys.stdin.readline
def print_ans(N, Q, S, arr):
    """Test Case
    >>> print_ans(8, 3, "ACACTACG", [[3, 7], [2, 3], [1, 8]])
    2
    0
    3
    """
    t = [0] * (N+1)
    for i in range(N):
        t[i+1] = t[i] + (1 if S[i:i+2] == "AC" else 0)
    for ar in arr:
        print(t[ar[1] - 1] - t[ar[0] - 1] )

if __name__ == '__main__':
    N, Q = map(int, input().rstrip().split())
    S = input().rstrip()
    arr = [list(map(int, input().rstrip().split())) for _ in range(Q)]
    print_ans(N, Q, S, arr)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
def print_ans(H, W, h, w):
    """Test Case
    >>> print_ans(3, 2, 2, 1)
    1
    >>> print_ans(5, 5, 2, 3)
    6
    >>> print_ans(2, 4, 2, 4)
    0
    """
    print((H - h) * (W  -w))


if __name__ == '__main__':
    H, W = map(int, input().rstrip().split())
    h, w = map(int, input().rstrip().split())
    print_ans(b)




Fixed submission:
import sys
input = sys.stdin.readline
def print_ans(H, W, h, w):
    """Test Case
    >>> print_ans(3, 2, 2, 1)
    1
    >>> print_ans(5, 5, 2, 3)
    6
    >>> print_ans(2, 4, 2, 4)
    0
    """
    print((H - h) * (W  -w))


if __name__ == '__main__':
    H, W = map(int, input().rstrip().split())
    h, w = map(int, input().rstrip().split())
    print_ans(H, W, h, w)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

def print_ans(A, B):
    """Test Case
    >>> print_ans(2, 4)
    5
    >>> print_ans(123, 456)
    435
    """
    # if (B -A + 1) % 2 == 0:
    #     print(122 ^ 1)
    # else:
    #     print( B ^ 1)
    tmp = A
    for i in range(A + 1, B + 1):
        tmp = tmp ^ i
    print(tmp)

    

if __name__ == '__main__':
    A, B = map(int, input().rstrip().split())
    print_ans(A, B)


Fixed submission:
import sys
input = sys.stdin.readline
def calc(x):
    if x == 0:
        return 0
    r = x % 4
    if r == 0:
        return x
    elif r == 1:
        return 1
    elif r == 2:
        return 1 ^ x
    else:
        return 0
def print_ans(A, B):
    """Test Case
    >>> print_ans(2, 4)
    5
    >>> print_ans(123, 456)
    435
    >>> print_ans(123456789012, 123456789012)
    123456789012
    """
    tmp = calc(A -1)
    tmp2 = calc(B)
    print(tmp ^ tmp2)

    

if __name__ == '__main__':
    A, B = map(int, input().rstrip().split())
    print_ans(A, B)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
import re
def print_ans(S):
    """Test Case
    >>> print_ans("0011")
    4
    >>> print_ans("11011010001011")
    12
    >>> print_ans("0")
    0
    """
    flg = True
    ans = 0
    while flg:
        tmp = re.sub(r"01|10", "", S)
        if len(tmp) == len(S):
            flg = False
            break
        else:
            ans += len(S) - len(tmp)
            S = tmp
    print(ans)
        


if __name__ == '__main__':
    S = input().rstrip()
    print_ans(S)


Fixed submission:
import sys
input = sys.stdin.readline
import re
def print_ans(S):
    """Test Case
    >>> print_ans("0011")
    4
    >>> print_ans("11011010001011")
    12
    >>> print_ans("0")
    0
    """
    flg = True
    ans = 0
    # while flg:
    #     tmp = re.sub(r"01|10", "", S)
    #     if len(tmp) == len(S):
    #         flg = False
    #         break
    #     else:
    #         ans += len(S) - len(tmp)
    #         S = tmp
    # print(ans)
    list_0 = []
    list_1 = []
    for s in S:
        if s =="0":
            list_0.append(s)
        else:
            list_1.append(s)
    print(min(len(list_0), len(list_1)) * 2)
        


if __name__ == '__main__':
    S = input().rstrip()
    print_ans(S)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
import re
def print_ans(S):
    """Test Case
    >>> print_ans("0011")
    4
    >>> print_ans("11011010001011")
    12
    >>> print_ans("0")
    0
    """
    flg = True
    ans = 0
    while flg:
        tmp = re.search(r"01|10", S)
        if tmp == None:
            flg = False
        else:
            S = S[:tmp.start()] + S[tmp.start() + 2:]
            ans += 2
    print(ans)
        


if __name__ == '__main__':
    S = input().rstrip()
    print_ans(S)


Fixed submission:
import sys
input = sys.stdin.readline
import re
def print_ans(S):
    """Test Case
    >>> print_ans("0011")
    4
    >>> print_ans("11011010001011")
    12
    >>> print_ans("0")
    0
    """
    flg = True
    ans = 0
    # while flg:
    #     tmp = re.sub(r"01|10", "", S)
    #     if len(tmp) == len(S):
    #         flg = False
    #         break
    #     else:
    #         ans += len(S) - len(tmp)
    #         S = tmp
    # print(ans)
    list_0 = []
    list_1 = []
    for s in S:
        if s =="0":
            list_0.append(s)
        else:
            list_1.append(s)
    print(min(len(list_0), len(list_1)) * 2)
        


if __name__ == '__main__':
    S = input().rstrip()
    print_ans(S)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys


def solve(K: int):
    if K % 2 == 0:
        print(-1)
    else:
        num = 7
        cnt = 1
        while True:
            if num % K == 0:
                print(cnt)
                return
            else:
                num *= 10
                num += 7
                num %= K
                cnt += 1
    return


# Generated by 1.1.7.1 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()
    K = int(next(tokens))  # type: int
    solve(K)

if __name__ == '__main__':
    main()

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


def solve(K: int):
    if K % 2 == 0:
        print(-1)
    else:
        num = 7
        cnt = 1
        stop = 10 ** 7
        while cnt < stop:
            if num % K == 0:
                print(cnt)
                return
            else:
                num *= 10
                num += 7
                num %= K
                cnt += 1
        print(-1)
    return


# Generated by 1.1.7.1 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()
    K = int(next(tokens))  # type: int
    solve(K)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    cnt = 0
    for i in range(N):
        for j in range(N):
            if i != j and A[i] % A[j] == 0:
                break
        else:
            cnt += 1
    
    print(cnt)

    return


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


# Generated by 1.1.7.1 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
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()

Fixed submission:
#!/usr/bin/env python3
import sys
from collections import Counter


def solve(N: int, A: "List[int]"):
    countA = Counter(A)
    A.sort()
    l = [True for _ in range(A[-1] + 1)]
    for i in range(N):
        j = 2
        while A[i] * j <= A[-1]:
            l[A[i] * j] = False
            j += 1
    cnt = 0
    for a in A:
        cnt += (l[a] and countA[a] == 1)
    print(cnt)




# Generated by 1.1.7.1 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
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    big = pow(10, 18)
    ret = 1
    for a in A:
        ret *= a
    if ret > big:
        print(-1)
    else:
        print(ret)
    return


# Generated by 1.1.7.1 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
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()

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


def solve(N: int, A: "List[int]"):
    big = pow(10, 18)
    ret = 1
    if 0 in A:
        print(0)
        return
    for a in A:
        ret *= a
        if ret > big:
            print(-1)
            return
    print(ret)
    return


# Generated by 1.1.7.1 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
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

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]"):
    p2 = [(i + 1) / 2 for i in p]
    m = -1
    for i in range(N - (K - 1)):
        s = 0
        for j in range(K):
            s += p2[i + j]
        m = max(m, s)
    print(m)


# 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


def solve(N: int, K: int, p: "List[int]"):
    p2 = [(i + 1) / 2 for i in p]
    l = []
    for i in range(N - (K - 1)):
        if i == 0:
            s = 0
            for j in range(K):
                s += p2[j]
            l.append(s)
        else:
            l.append(l[-1] - p2[i - 1] + p2[i + (K - 1)])
    print(max(l))
    # m = -1
    # for i in range(N - (K - 1)):
    #     s = 0
    #     for j in range(K):
    #         s += p2[i + j]
    #     m = max(m, s)
    # print(m)


# 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()