Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
x, y = map(int,input().split())
if (x+y)%3!=0:
  print(0)
  exit()
n = (x+y)//3
if 0 > x-n or 0 > y-n:
  print(0)
  exit()

m = min(x-n,y-n)
mod = 1000000007
a=1
b=1

for i in range(1,m+1):
  a = a *(n+1-i) % mod
  b = b * i %mod
print(ans)
  


Fixed submission:
#coding:utf-8
import bisect
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = True



def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    x, y = LMIIS()

    if (x+y)%3!=0:
      print(0)
      exit()
    n = (x+y)//3
    if 0 > x-n or 0 > y-n:
      print(0)
      exit()

    m = min(x-n,y-n)
    mod = 10**9 + 7

    a = 1
    b = 1
    c = 1
    for i in range(1, n+1):
        a = a * i % mod
    for i in range(1, n - m + 1):
        b = b * i % mod
    for i in range(1, m + 1):
        c = c * i % mod
    print(a * pow(b * c, mod - 2, mod) % mod)




if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
x, y = map(int,input().split())
if (x+y)%3!=0:
  print(0)
  exit()
n = (x+y)//3
if 0 > x-n or 0 > y-n:
  print(0)
  exit()

m = min(x-n,y-n)
mod = 1000000007
ans = 1
for i in range(m):
  ans = (ans *(n-i) // i) % mod
print(ans)
  

Fixed submission:
#coding:utf-8
import bisect
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = True



def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    x, y = LMIIS()

    if (x+y)%3!=0:
      print(0)
      exit()
    n = (x+y)//3
    if 0 > x-n or 0 > y-n:
      print(0)
      exit()

    m = min(x-n,y-n)
    mod = 10**9 + 7

    a = 1
    b = 1
    c = 1
    for i in range(1, n+1):
        a = a * i % mod
    for i in range(1, n - m + 1):
        b = b * i % mod
    for i in range(1, m + 1):
        c = c * i % mod
    print(a * pow(b * c, mod - 2, mod) % mod)




if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8
import bisect
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = True



def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    n, t = LMIIS()
    ab = XLMIIS(n)

    dp1 = [[0]*t for _ in range(n)]
    for i in range(1, n):
        for j in range(1, t):
            if j < ab[i-1][0]:
                dp1[i][j] = dp1[i-1][j]
            else:
                dp1[i][j] = max(dp1[i-1][j], dp1[i-1][j-ab[i-1][0]] + ab[i-1][1])


    dp2 = [[0]*t for _ in range(n)]
    for i in range(1, n):
        for j in range(1, t):
            if j < ab[n - i][0]:
                dp2[i][j] = dp2[i-1][j]
            else:
                dp2[i][j] = max(dp2[i-1][j], dp2[i-1][j-ab[n-i][0]] + ab[n-i][1])

    ans = 0
    for i in range(n):
        for j in range(t - 1):
            ans = max(ans, dp1[i][j] + dp2[n - i - 1][t - j - 1] + ab[i][1])
    print(ans)

if __name__ == '__main__':
    main()


Fixed submission:
#coding:utf-8
import bisect
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = True



def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    n, t = LMIIS()
    ab = XLMIIS(n)

    dp1 = [[0]*t for _ in range(n)]
    for i in range(1, n):
        for j in range(1, t):
            if j < ab[i-1][0]:
                dp1[i][j] = dp1[i-1][j]
            else:
                dp1[i][j] = max(dp1[i-1][j], dp1[i-1][j-ab[i-1][0]] + ab[i-1][1])


    dp2 = [[0]*t for _ in range(n)]
    for i in range(1, n):
        for j in range(1, t):
            if j < ab[n - i][0]:
                dp2[i][j] = dp2[i-1][j]
            else:
                dp2[i][j] = max(dp2[i-1][j], dp2[i-1][j-ab[n-i][0]] + ab[n-i][1])

    ans = 0
    for i in range(n):
        for j in range(t - 1):
            ans = max(ans, dp1[i][j] + dp2[n - i - 1][t - j - 1] + ab[i][1])
    print(ans)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

for i in range(m):
    x = a.pop()
    x = x // 2
    bisect.insort(a, x)



print(sum(map(int, a)))


Fixed submission:
import heapq
n, m = map(int, input().split())
a = list(map(int, input().split()))

heap = []
for i in a:
    heapq.heappush(heap, -i)


for i in range(m):
    x = - heapq.heappop(heap)
    x = x / 2
    heapq.heappush(heap, - x)



print(sum(map(lambda n: int (-n), heap)))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n, m = map(int, input().split())
a = list(map(int, input().split()))

a.sort()

for i in range(m):
    x = a.pop()
    x = x / 2
    bisect.insort(a, x)



print(sum(map(int, a)))


Fixed submission:
import heapq
n, m = map(int, input().split())
a = list(map(int, input().split()))

heap = []
for i in a:
    heapq.heappush(heap, -i)


for i in range(m):
    x = - heapq.heappop(heap)
    x = x / 2
    heapq.heappush(heap, - x)



print(sum(map(lambda n: int (-n), heap)))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n, m = map(int, input().split())
a = list(map(int, input().split()))

a.sort()

for i in range(m):
    x = a.pop()
    x = x / 2
    bisect.insort(a, x)



print(sum(map(int, a)))


Fixed submission:
import heapq
n, m = map(int, input().split())
a = list(map(int, input().split()))

heap = []
for i in a:
    heapq.heappush(heap, -i)


for i in range(m):
    x = - heapq.heappop(heap)
    x = x / 2
    heapq.heappush(heap, - x)



print(sum(map(lambda n: int (-n), heap)))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n, m = map(int, input().split())
a = list(map(int, input().split()))
l = len(a)
a.sort()

for i in range(m):
    x = a.pop(l-1)
    x = x / 2
    bisect.insort(a, x)



print(sum(map(int, a)))


Fixed submission:
import heapq
n, m = map(int, input().split())
a = list(map(int, input().split()))

heap = []
for i in a:
    heapq.heappush(heap, -i)


for i in range(m):
    x = - heapq.heappop(heap)
    x = x / 2
    heapq.heappush(heap, - x)



print(sum(map(lambda n: int (-n), heap)))
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)
n, q = list(map(int, input().split()))
tree = [[] for i in range(n)]
for i in range(n - 1):
    a, b= list(map(int, input().split()))
    tree[a-1].append(b-1)
s = [0] * n
for i in range(q):
    p, x = list(map(int, input().split()))
    s[p-1] += x


def f(n):
    global s
    for i in range(len(tree[n])):
        s[tree[n][i]] += s[n]
        f(tree[n][i])



f(0)

print(" ".join(list(map(str, s))))


Fixed submission:
n, q = list(map(int, input().split()))
tree = [[] for i in range(n)]
for i in range(n - 1):
    a, b= list(map(int, input().split()))
    tree[a-1].append(b-1)
s = [0] * n
for i in range(q):
    p, x = list(map(int, input().split()))
    s[p-1] += x

queue = [0]

while(len(queue) != 0):
    n = queue.pop()
    for i in range(len(tree[n])):
        s[tree[n][i]] += s[n]
        queue.append(tree[n][i])
# def f(n):
#     global s
#     for i in range(len(tree[n])):
#         s[tree[n][i]] += s[n]
#         f(tree[n][i])
#
# f(0)

print(" ".join(list(map(str, s))))
Buggy python submission (verdict: Runtime Error):
N = int(input())
x = [0] * N
y = [0] * N
for i in range(N):
    x[i], y[i] = list(map(int, input().split()))

l = {}

for i in range(N):
    for j in range(i + 1, N):
        p = x[i] - x[j]
        q = y[i] - y[j]
        if p < 0:
            p = -p
            q = -q
        if str([p, q]) in l:
            l[str([p, q])] += 1
        else:
            l[str([p, q])] = 1

print(N - max(l.values()))



Fixed submission:
N = int(input())
if N == 1:
    print(1)
    exit()

x = [0] * N
y = [0] * N
for i in range(N):
    x[i], y[i] = list(map(int, input().split()))

l = {}

for i in range(N):
    for j in range(i + 1, N):
        p = x[i] - x[j]
        q = y[i] - y[j]
        if p < 0:
            p = -p
            q = -q
        if p == 0:
            q = abs(q)
        if str([p, q]) in l:
            l[str([p, q])] += 1
        else:
            l[str([p, q])] = 1

print(N - max(l.values()))
Buggy python submission (verdict: Time Limit Exceeded):
N, M = list(map(int, input().split()))
a = [int(input()) for i in range(M)]

dp = [0, 1]

for i in range(1, N + 1):
    if i in a:
        dp.append(0)
        continue
    dp.append(dp[i - 1] + dp[i])

print(dp[N + 1] % 1000000007)


Fixed submission:
N, M = list(map(int, input().split()))
a = [int(input()) for i in range(M)]
a.append(0)
dp = [0, 1]
a_flag = 0

for i in range(1, N + 1):
    if i == a[a_flag]:
        dp.append(0)
        a_flag += 1
        continue
    dp.append(dp[i - 1] + dp[i])

print(dp[N + 1] % 1000000007)
Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
A = list(map(int, input().split()))
x = [0] * N
y = [0] * N
tmp = A[0]
for i in range(1, N):
    t = math.gcd(tmp, A[i])
    x[i] = int(tmp / t)
    tmp = t
tmp = A[N - 1]
for i in range(N - 2, -1, -1):
    t = math.gcd(tmp, A[i])
    y[i] =  int(tmp / t)
    tmp = t
m = 0
for i in range(1, N - 1):
    a = math.gcd(x[i], y[i])
    if m < a:
        m = a
print(tmp * max(m, y[0], x[N - 1]))




Fixed submission:

import fractions
N = int(input())
A = list(map(int, input().split()))
x = [0] * N
y = [0] * N
tmp = A[0]
for i in range(1, N):
    t = fractions.gcd(tmp, A[i])
    x[i] = int(tmp / t)
    tmp = t
tmp = A[N - 1]
for i in range(N - 2, -1, -1):
    t = fractions.gcd(tmp, A[i])
    y[i] =  int(tmp / t)
    tmp = t
m = 0
for i in range(1, N - 1):
    a = fractions.gcd(x[i], y[i])
    if m < a:
        m = a
print(tmp * max(m, y[0], x[N - 1]))
Buggy python submission (verdict: Runtime Error):
N, Q = list(map(int, input().split()))
S = input()
l = [0] * Q
r = [0] * Q
for x in range(Q):
    l[x], r[x] = list(map(int, input().split()))

isAC = [0] * len(S)
for x in range(len(S) - 1):
    if S[x] == "A" and S[x + 1] == "C":
        isAC[x] = 1

for x in range(Q):
    ans = 0
    cut_isAC = isAC[l[x] - 1:r[x] - 1]
    for y in range(len(cut_isAC)):
        ans += cut_isAC[y]
    print(ans)


Fixed submission:
b = input()
tmp = {'A':'T', 'T':'A', 'G':'C', 'C':'G'}
print(tmp[b])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
b = list(map(int, input().split()))
a = [1, 2, 3, 4, 5]

def f(a, ans):
    if len(a) == 0:
        for i in range(len(ans)):
            print(ans[len(ans) - i - 1])
        exit()
    for i in range(len(a)):
        if i + 1 == a[i]:
            f(a[0:i] + a[i + 1:len(a)], ans + [i + 1])

f(b, [])
print(-1)



Fixed submission:
N = int(input())
b = list(map(int, input().split()))
a = [1, 2, 3, 4, 5]

def f(a, ans):
    if len(a) == 0:
        for i in range(len(ans)):
            print(ans[len(ans) - i - 1])
        exit()
    for i in range(len(a) - 1, -1, -1):
        if i + 1 == a[i]:
            f(a[0:i] + a[i + 1:len(a)], ans + [i + 1])
            break


f(b, [])
print(-1)

Buggy python submission (verdict: Runtime Error):
N = int(input())
b = list(map(int, input().split()))
a = [1, 2, 3, 4, 5]

def f(a, ans):
    if len(a) == 0:
        for i in range(len(ans)):
            print(ans[len(ans) - i - 1])
        exir()
    for i in range(len(a)):
        if i + 1 == a[i]:
            f(a[0:i] + a[i + 1:len(a)], ans + [i + 1])

f(b, [])
print(-1)



Fixed submission:
N = int(input())
b = list(map(int, input().split()))
a = [1, 2, 3, 4, 5]

def f(a, ans):
    if len(a) == 0:
        for i in range(len(ans)):
            print(ans[len(ans) - i - 1])
        exit()
    for i in range(len(a) - 1, -1, -1):
        if i + 1 == a[i]:
            f(a[0:i] + a[i + 1:len(a)], ans + [i + 1])
            break


f(b, [])
print(-1)
Buggy python submission (verdict: Runtime Error):
N, M, C = list(map(int, input().split()))
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(N)]
ans = 0
for i in range(N):
    sum = 0
    for j in range(M):
        sum += A[i - 1][j - 1] * B[j - 1]
    if sum > - C:
        ans += 1
print(ans)


Fixed submission:
H, W = list(map(int, input().split()))
h, w = list(map(int, input().split()))
print(H*W - h*W - H*w + h*w)
Buggy python submission (verdict: Time Limit Exceeded):
A, B = list(map(int, input().split()))
ans = 0
for i in range(A, B+1):
    ans = ans^ i
print(ans)


Fixed submission:
A, B = list(map(int, input().split()))
c = []
c.append(A % 4 // 2 ^ (B + 1) % 4 // 2)

keta = 2
while(B // keta != 0):
    if A // keta % 2 == 0:
        a = 0
    else:
        a = A % keta
    if B // keta % 2 == 0:
        b = 0
    else:
        b = B % keta
        b += 1
    c.append((b - a) % 2)
    keta = keta<<1
ans = 0

for i in range(len(c) - 1, -1, -1):
    ans = ans<<1
    ans ^= c[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for _ in range(N)]

A.sort()

ans = A[len(A) - 1] - A[0]
small = 0
large = len(A) - 1
while (True):

    if large - small == 1:
        break
    elif large - small == 2:
        ans += max(A[large] - A[large - 1], A[small + 1] - A[small])
        break
    ans += A[large - 1] - A[small] + A[large] - A[small + 1]
    small += 1
    large -= 1

print(ans)


Fixed submission:
S = input()
if len(S) == 2:
    print(S)
else:
    print(S[::-1])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]

A.sort()

ans = A[len(A) - 1] - A[0]
small = 0
large = len(A) - 1
while (A != []):

    if len(A) == 2:
        break
    elif len(A) == 3:
        ans += max(A[1] - A[0], A[2] - A[1])
        break
    ans += A[len(A) - 2] - A[0] + A[len(A) - 1] - A[1]
    A = A[1:-1]

print(ans)


Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]

A.sort()

ans = A[len(A) - 1] - A[0]
small = 0
large = len(A) - 1
while (True):

    if large - small == 1:
        break
    elif large - small == 2:
        ans += max(A[large] - A[large - 1], A[small + 1] - A[small])
        break
    ans += A[large - 1] - A[small] + A[large] - A[small + 1]
    small += 1
    large -= 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import math

n = int(input())
aa = list(map(int, input().split()))

# def findsame(aa):
#     s = 0
#     for a in aa:
#         s += (len([x for x in aa if x == a]) - 1)
#     return int(s / 2)

# for k in range(len(aa) - 1):
#     print(findsame(aa[:k] + aa[k+1:]))
# print(findsame(aa[:len(aa)-1]))

aaa = dict()
for a in aa:
    if a not in aaa:
        aaa[a] = len([x for x in aa if x == a])

sum = 0
for k in aaa:
    sum += int(aaa[k] * (aaa[k] - 1) / 2)

for a in aa:
    print(sum - (aaa[a] - 1))


Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import math

n = int(input())
aa = list(map(int, input().split()))

# def findsame(aa):
#     s = 0
#     for a in aa:
#         s += (len([x for x in aa if x == a]) - 1)
#     return int(s / 2)

# for k in range(len(aa) - 1):
#     print(findsame(aa[:k] + aa[k+1:]))
# print(findsame(aa[:len(aa)-1]))

# aaa = dict()
# for a in aa:
#     if a not in aaa:
#         aaa[a] = len([x for x in aa if x == a])

# sum = 0
# for k in aaa:
#     sum += int(aaa[k] * (aaa[k] - 1) / 2)

# for a in aa:
#     print(sum - (aaa[a] - 1))

aaa = dict()
for a in aa:
    if a not in aaa:
        aaa[a] = 1
    else:
        aaa[a] += 1

sum = 0
for k in aaa:
    sum += int(aaa[k] * (aaa[k] - 1) / 2)

for a in aa:
    print(sum - (aaa[a] - 1))

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import math

n = int(input())
aa = list(map(int, input().split()))

def findsame(aa):
    s = 0
    for a in aa:
        s += (len([x for x in aa if x == a]) - 1)
    return int(s / 2)

for k in range(len(aa) - 1):
    print(findsame(aa[:k] + aa[k+1:]))
print(findsame(aa[:len(aa)-1]))


Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import math

n = int(input())
aa = list(map(int, input().split()))

# def findsame(aa):
#     s = 0
#     for a in aa:
#         s += (len([x for x in aa if x == a]) - 1)
#     return int(s / 2)

# for k in range(len(aa) - 1):
#     print(findsame(aa[:k] + aa[k+1:]))
# print(findsame(aa[:len(aa)-1]))

# aaa = dict()
# for a in aa:
#     if a not in aaa:
#         aaa[a] = len([x for x in aa if x == a])

# sum = 0
# for k in aaa:
#     sum += int(aaa[k] * (aaa[k] - 1) / 2)

# for a in aa:
#     print(sum - (aaa[a] - 1))

aaa = dict()
for a in aa:
    if a not in aaa:
        aaa[a] = 1
    else:
        aaa[a] += 1

sum = 0
for k in aaa:
    sum += int(aaa[k] * (aaa[k] - 1) / 2)

for a in aa:
    print(sum - (aaa[a] - 1))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int, input().split()))
for i in range(1,n):
    print(a.count(i))
print(0)

Fixed submission:
import collections
n=int(input())
a=list(map(int, input().split()))
c=collections.Counter(a)
for i in range(1,n+1):
    print(c[i])
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

k=int(input())
ans=0

def gcd(*numbers):
    return reduce(math.gcd, numbers)

for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            ans+=(gcd(a,b,c))
print(ans)

Fixed submission:
import itertools
import math
from functools import reduce

k=int(input())
l=list(range(1,k+1))
ans=0

def gcd(*numbers):
    return reduce(math.gcd, numbers)

for i in itertools.product(l,repeat=3):
    ans+=(gcd(i[0],i[1],i[2]))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import collections
    import math
    n=int(input())
    a=list(map(int, input().split()))
    c=collections.Counter(a)
    cnt=list(c.items())
    ans=0
    comb=[]
    for i in range(len(cnt)): #各出現数字のAi_C_2を計算
        buf=(cnt[i][1]**2-cnt[i][1])//2
        comb.append(buf)
        ans+=buf
    for ai in a:
        for i in range(len(cnt)):
            if cnt[i][0]==ai:
                print(ans-cnt[i][1]+1)

if __name__=='__main__':
    main()

Fixed submission:
def main():
    import collections
    import math
    n=int(input())
    a=list(map(int, input().split()))
    c=collections.Counter(a)
    cnt=list(c.items())
    ans=0
    comb=[]
    for i in range(len(cnt)): #各出現数字のAi_C_2を計算
        buf=(cnt[i][1]**2-cnt[i][1])//2
        comb.append(buf)
        ans+=buf
    for ai in a:
        print(ans-c[ai]+1)

if __name__=='__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import collections
    import math
    n=int(input())
    a=list(map(int, input().split()))
    c=collections.Counter(a)
    cnt=list(c.items())
    ans=0
    comb=[]
    for i in range(len(cnt)): #各出現数字のAi_C_2を計算
        buf=(cnt[i][1]**2-cnt[i][1])//2
        comb.append(buf)
        ans+=buf
    for ai in a:
        for i in range(len(cnt)):
            if cnt[i][0]==ai:
                print(ans-cnt[i][1]+1)

if __name__=='__main__':
    main()

Fixed submission:
def main():
    import collections
    import math
    n=int(input())
    a=list(map(int, input().split()))
    c=collections.Counter(a)
    cnt=list(c.items())
    ans=0
    comb=[]
    for i in range(len(cnt)): #各出現数字のAi_C_2を計算
        buf=(cnt[i][1]**2-cnt[i][1])//2
        comb.append(buf)
        ans+=buf
    for ai in a:
        print(ans-c[ai]+1)

if __name__=='__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n,k=map(int,input().split())
    p=list(map(int,input().split()))
    kitai=[]
    ans=0
    for i in range(n):
        buf=sum(range(1,p[i]+1))/p[i]
        kitai.append(buf)
        if i<=k-1:
            ans+=buf
    x=ans
    for i in range(k,n):
        x-=kitai[i-k]
        x+=kitai[i]
        if ans<=x:
            ans=x
    print(ans)

if __name__=='__main__':
    main()

Fixed submission:
def main():
    n,k=map(int,input().split())
    p=list(map(int,input().split()))
    kitai=[]
    ans=0
    for i in range(n):
        buf=sum(range(1,p[i]+1))/p[i]
        kitai.append(buf)
        if i<=k-1:
            ans+=buf
    x=ans
    for i in range(k,n):
        x-=kitai[i-k]
        x+=kitai[i]
        if ans<=x:
            ans=x
    print(ans)

if __name__=='__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    from collections import deque
    n,k=map(int,input().split())
    p=list(map(int,input().split()))
    kitai=[]
    queue=deque()
    ans=0
    for i in range(n):
        buf=sum(range(1,p[i]+1))/p[i]
        kitai.append(buf)
        if i<=k-1:
            queue.append(buf)
            ans+=buf
    for i in range(k,n):
        queue.popleft()
        queue.append(kitai[i])
        if ans<=sum(queue):
            ans=sum(queue)
    print(ans)

if __name__=='__main__':
    main()

Fixed submission:
def main():
    n,k=map(int,input().split())
    p=list(map(int,input().split()))
    kitai=[]
    ans=0
    for i in range(n):
        buf=sum(range(1,p[i]+1))/p[i]
        kitai.append(buf)
        if i<=k-1:
            ans+=buf
    x=ans
    for i in range(k,n):
        x-=kitai[i-k]
        x+=kitai[i]
        if ans<=x:
            ans=x
    print(ans)

if __name__=='__main__':
    main()

Buggy python submission (verdict: Runtime Error):
from collections import deque
n,k=map(int, input().split())
p=list(map(int, input().split()))
queue=deque()
prod=1
ans=0
for i in range(k):
    queue.append(p[i])
    prod*=p[i]
ans=sum(queue)
for i in range(k-1,n-1):
    buf=sum(queue)
    if buf>=ans: #隣接するkコのサイコロの最大値を記録
        ans=buf
        x=prod
    queue.popleft()
    queue.append(p[i+1])
    prod*=p[i+1]/p[i]
l=list(range(3,ans+1))
y=(sum(l))/x
print(y)

Fixed submission:
def main():
    n,k=map(int,input().split())
    p=list(map(int,input().split()))
    kitai=[]
    ans=0
    for i in range(n):
        buf=sum(range(1,p[i]+1))/p[i]
        kitai.append(buf)
        if i<=k-1:
            ans+=buf
    x=ans
    for i in range(k,n):
        x-=kitai[i-k]
        x+=kitai[i]
        if ans<=x:
            ans=x
    print(ans)

if __name__=='__main__':
    main()