Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def popcnt(n):
    return bin(n).count("1")
N = int(input())
L = [0]*(N+1)
for i in range(1,N+1):
    L[i] = L[i%popcnt(i)]+1
X = input()
M = X.count("1")+1
m = M-2
X = list(X)
XM = int(X[-1])
Xm = int(X[-1])
tM = 1
tm = 1
X.reverse()
for i in range(1,N):
    tM = tM*2%M
    tm = tm*2%m
    if X[i] == "1":
        XM = (XM + tM)%M
        Xm = (Xm + tm)%m
ans = []
tM = 1
tm = 1
for i in range(N):
    A = 0
    if X[i] == "0":
        A = (XM + tM)%M
    else:
        A = (Xm + m - tm)%m
    ans.append(A)
    tM = (tM*2)%M
    tm = (tm*2)%m
ans.reverse()
for a in ans:
    print(L[a]+1)

Fixed submission:
def popcnt(n):
    return bin(n).count("1")
N = int(input())
L = [0]*(N+1)
for i in range(1,N+1):
    L[i] = L[i%popcnt(i)]+1
L[N] = -1
X = input()
M = X.count("1")+1
m = max(1,M-2)
X = list(X)
XM = int(X[-1])
Xm = int(X[-1])
tM = 1
tm = 1
X.reverse()
for i in range(1,N):
    tM = tM*2%M
    tm = tm*2%m
    if X[i] == "1":
        XM = (XM + tM)%M
        Xm = (Xm + tm)%m
ans = []
tM = 1
tm = 1
for i in range(N):
    A = 0
    if X[i] == "0":
        A = (XM + tM)%M
    else:
        A = (Xm + m - tm)%m
        if M == 2:
            A = N
    ans.append(A)
    tM = (tM*2)%M
    tm = (tm*2)%m
ans.reverse()
for a in ans:
    print(L[a]+1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]
num = 0
for i in range(N):
    num += A[i]
Q = int(input())
for _ in range(Q):
    B,C = [int(i) for i in input().split()]
    for i in range(N):
        if A[i] == B:
            A[i] = C
            num += C-B
    print(num)

Fixed submission:
N = int(input())
L = [int(i) for i in input().split()]
A = [0]*(1+(10**5))
num = 0
for l in L:
    A[l] += 1
    num += l
Q = int(input())
for _ in range(Q):
    B,C =[int(i) for i in input().split()]
    num += (C-B)*A[B]
    A[C] += A[B]
    A[B] = 0
    print(num)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]
A.sort()
c = [False]*N
ans = 0
for i in range(N):
    if c[i]:
        continue
    if i == N-1 or A[i] != A[i+1]:
        ans += 1
    if i == N-1:
        break
    for j in range(i+1,N):
        if not c[j] and A[j]%A[i]==0:
            c[j] = True
print(ans)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
A.sort()
B = [True]*(A[-1]+1)
i = 0
for i in range(N):
  if i < N-1 and A[i] == A[i+1]:
    B[A[i]] = False
  if A[-1] < 2*A[i]:
    continue
  M = A[-1]//A[i]+1
  for j in range(2,M):
    B[j*A[i]] = False

ans = 0
for a in A:
  if B[a]:
    ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]
A.sort(reverse = True)
ans = 0
while A:
    a = A.pop(-1)
    if not A or a != A[-1]:
        ans += 1
    A = [i for i in A if i%a != 0]
print(ans)


Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
A.sort()
B = [True]*(A[-1]+1)
i = 0
for i in range(N):
  if i < N-1 and A[i] == A[i+1]:
    B[A[i]] = False
  if A[-1] < 2*A[i]:
    continue
  M = A[-1]//A[i]+1
  for j in range(2,M):
    B[j*A[i]] = False

ans = 0
for a in A:
  if B[a]:
    ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]
A.sort(reverse = True)
ans = 0
while A:
    a = A.pop(-1)
    if not A or a != A[-1]:
        ans += 1
    B = []
    for i in A:
        if i%a != 0:
            B.append(i)
    A = B
print(ans)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
A.sort()
B = [True]*(A[-1]+1)
i = 0
for i in range(N):
  if i < N-1 and A[i] == A[i+1]:
    B[A[i]] = False
  if A[-1] < 2*A[i]:
    continue
  M = A[-1]//A[i]+1
  for j in range(2,M):
    B[j*A[i]] = False

ans = 0
for a in A:
  if B[a]:
    ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]
A.sort(reverse = True)
ans = 0
while A:
    a = A.pop(-1)
    if not A or a != A[-1]:
        ans += 1
    A = [i for i in A if i%a != 0]
print(ans)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
A.sort()
B = [True]*(A[-1]+1)
i = 0
for i in range(N):
  if i < N-1 and A[i] == A[i+1]:
    B[A[i]] = False
  if A[-1] < 2*A[i]:
    continue
  M = A[-1]//A[i]+1
  for j in range(2,M):
    B[j*A[i]] = False

ans = 0
for a in A:
  if B[a]:
    ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
p = 998244353

N,S = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
dp = np.zeros(S+1)
dp[0] = 1
for a in A:
  if S < a:
    dp = 2*dp
    continue
  tmp = 2*dp
  dp = np.append(np.zeros(a),dp[:S-a+1])
  dp += tmp
  dp %= p
print(int(dp[S]))

Fixed submission:
import numpy as np
p = 998244353

N,S = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
dp = np.zeros(S+1)
dp[0] = 1
for a in A:
  if S < a:
    dp *= 2
    dp %= p
    continue
  tmp = 2*dp
  dp = np.append(np.zeros(a),dp[:S-a+1])
  dp += tmp
  dp %= p
print(int(dp[S]))

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
p = 998244353
q = 75497471

N,S = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
L = []
for i in range(1,N+1):
  for a in itertools.combinations(range(N),i):
    num = 0
    for j in a:
      num += A[j]
    if num == S:
      L.append(i)
ans = 0
for l in L:
  l = N-l
  t = l//30
  u = l%30
  num = 1
  for _ in range(t):
    num *= q
    num %= p
  num *= 2**u
  num %= p
  ans += num
  
print(ans)

Fixed submission:
import numpy as np
p = 998244353

N,S = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
dp = np.zeros(S+1)
dp[0] = 1
for a in A:
  if S < a:
    dp *= 2
    dp %= p
    continue
  tmp = 2*dp
  dp = np.append(np.zeros(a),dp[:S-a+1])
  dp += tmp
  dp %= p
print(int(dp[S]))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from collections import deque

N,M,X = [int(i) for i in input().split()]
A = np.array([[int(i) for i in input().split()]])
for _ in range(N-1):
    B = np.array([int(i) for i in input().split()])
    A = np.vstack([A, B])

m = min([np.sum(A[:,i:i+1]) for i in range(1,M+1)])
if m < X:
    print(-1)
    exit()

ans = np.sum(A[:,0:1])
q = deque([[i] for i in range(N)])
while len(q) != 0:
    L = q.pop()
    L.sort(reverse=True)
    B = A.copy()
    for i in L:
        B = np.delete(B, i, 0)
    m = min([np.sum(B[:,i:i+1]) for i in range(1,M+1)])
    if m < X:
        continue
    ans = min([ans,np.sum(B[:,0:1])])
    for i in range(N):
        L1 = L.copy()
        L1.append(i)
        L1set = set(L1)
        if len(L) < len(L1set):
            q.append(L1)

print(ans)

Fixed submission:
N,M,X = [int(i) for i in input().split()]
A = []
for _ in range(N):
    A.append([int(i) for i in input().split()])
ans = float("inf")

for i in range(1,2**N):
    a = 0
    e = [0]*M
    bi = "0"*N + bin(i)[2:]
    bi = list(bi[len(bi)-N:])
    for j in range(N):
        if bi[j] == "1":
            a += A[j][0]
            for k in range(M):
                e[k] += A[j][k+1]
    c = True
    for i in range(M):
        c &= e[i] >= X
    if c:
        ans = min(ans,a)
if ans > 10**7:
    print(-1)
else:
    print(ans)

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

N,M,X = [int(i) for i in input().split()]
A = np.array([[int(i) for i in input().split()]])
for _ in range(N-1):
    B = np.array([int(i) for i in input().split()])
    A = np.vstack([A, B])

m = min([np.sum(A[:,i:i+1]) for i in range(1,M+1)])
if m < X:
    print(-1)
    exit()

ans = np.sum(A[:,0:1])
q = deque([[i] for i in range(N)])
while len(q) != 0:
    L = q.pop()
    L.sort(reverse=True)
    B = A.copy()
    for i in L:
        B = np.delete(B, i, 0)
    m = min([np.sum(B[:,i:i+1]) for i in range(1,M+1)])
    if m < X:
        continue
    ans = min([ans,np.sum(B[:,0:1])])
    for i in range(N):
        L1 = L.copy()
        L1.append(i)
        L1set = set(L1)
        if len(L) < len(L1set):
            q.appendleft(L1)

print(ans)

Fixed submission:
N,M,X = [int(i) for i in input().split()]
A = []
for _ in range(N):
    A.append([int(i) for i in input().split()])
ans = float("inf")

for i in range(1,2**N):
    a = 0
    e = [0]*M
    bi = "0"*N + bin(i)[2:]
    bi = list(bi[len(bi)-N:])
    for j in range(N):
        if bi[j] == "1":
            a += A[j][0]
            for k in range(M):
                e[k] += A[j][k+1]
    c = True
    for i in range(M):
        c &= e[i] >= X
    if c:
        ans = min(ans,a)
if ans > 10**7:
    print(-1)
else:
    print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np

N = int(input())
A = np.array([int(i) for i in input().split()])
A = A[A<=2*(10**5)]

H = [0]*(5*(10**5))
L = [0]*(5*(10**5))

for i in range(N):
    H[A[i]+i] += 1
    if i-A[i] >= 0:
        L[i-A[i]] += 1

ans = 0

for i in range(5*(10**5)):
    ans += H[i]*L[i]

print(ans)


Fixed submission:
import numpy as np

N = int(input())
A = np.array([int(i) for i in input().split()])

H = [0]*(5*(10**5))
L = [0]*(5*(10**5))

for i in range(N):
    if A[i] <= 2*(10**5):
        H[A[i]+i] += 1
    if i-A[i] >= 0:
        L[i-A[i]] += 1

ans = 0

for i in range(5*(10**5)):
    ans += H[i]*L[i]

print(ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np

N = int(input())
A = np.array([int(i) for i in input().split()])
A = A[A<=2*(10**5)]

H = [0]*(5*(10**5))
L = [0]*(5*(10**5))

for i in range(N):
    H[A[i]+i] += 1
    if i-A[i] >= 0:
        L[i-A[i]] += 1

ans = 0

for i in range(N):
    ans += H[i]*L[i]

print(ans)


Fixed submission:
import numpy as np

N = int(input())
A = np.array([int(i) for i in input().split()])

H = [0]*(5*(10**5))
L = [0]*(5*(10**5))

for i in range(N):
    if A[i] <= 2*(10**5):
        H[A[i]+i] += 1
    if i-A[i] >= 0:
        L[i-A[i]] += 1

ans = 0

for i in range(5*(10**5)):
    ans += H[i]*L[i]

print(ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np

N = int(input())
A = np.array([int(i) for i in input().split()])
A = A[A<=2*(10**5)]

H = [0]*(4*(10**5))
L = [0]*(4*(10**5))

for i in range(N):
    H[A[i]+i] += 1
    if i-A[i] >= 0:
        L[i-A[i]] += 1

ans = 0

for i in range(N):
    ans += H[i]*L[i]

print(ans)


Fixed submission:
import numpy as np

N = int(input())
A = np.array([int(i) for i in input().split()])

H = [0]*(5*(10**5))
L = [0]*(5*(10**5))

for i in range(N):
    if A[i] <= 2*(10**5):
        H[A[i]+i] += 1
    if i-A[i] >= 0:
        L[i-A[i]] += 1

ans = 0

for i in range(5*(10**5)):
    ans += H[i]*L[i]

print(ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np

N = int(input())
A = np.array([int(i) for i in input().split()])
A = A[A<=2*(10**5)]

H = [0]*(3*(10**5))
L = [0]*(3*(10**5))

for i in range(N):
    H[A[i]+i] += 1
    if i-A[i] >= 0:
        L[i-A[i]] += 1

ans = 0

for i in range(N):
    ans += H[i]*L[i]

print(ans)


Fixed submission:
import numpy as np

N = int(input())
A = np.array([int(i) for i in input().split()])

H = [0]*(5*(10**5))
L = [0]*(5*(10**5))

for i in range(N):
    if A[i] <= 2*(10**5):
        H[A[i]+i] += 1
    if i-A[i] >= 0:
        L[i-A[i]] += 1

ans = 0

for i in range(5*(10**5)):
    ans += H[i]*L[i]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
A,B,N = [int(i) for i in input().split()]
x = N
M = A*N//B
ans = -float("inf")

for _ in range(min([10**7,N])):
    s = (A*x)//B - A*(x//B)
    ans = max([ans,s])
    x -= 1

print(ans)

Fixed submission:
A,B,N = [int(i) for i in input().split()]
t = min([N,B-1])
print((A*t//B))
Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
L = [0]*2019
L[0]=1
digit = 1
x = 0

for i in S[::-1]:
    x += digit*int(i)
    digit *= 10
    x = x%2019
    L[x] += 1

ans = 0

for i in range(len(L)):
    ans += L[i]*(L[i]-1)//2

print(ans)

Fixed submission:
S = list(input())
L = [0]*2019
L[0]=1
digit = 1
x = 0

for i in S[::-1]:
    x += digit*int(i)
    digit *= 10
    x %= 2019
    digit %= 2019 
    L[x] += 1

ans = 0

for i in L:
    ans += i*(i-1)//2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
L = [0]*2019
L[0]=1

for i in range(len(S)):
    N = int("".join(S[i:]))%2019
    L[N] += 1

ans = 0

for i in range(len(L)):
    ans += L[i]*(L[i]-1)//2

print(ans)

Fixed submission:
S = list(input())
L = [0]*2019
L[0]=1
digit = 1
x = 0

for i in S[::-1]:
    x += digit*int(i)
    digit *= 10
    x %= 2019
    digit %= 2019 
    L[x] += 1

ans = 0

for i in L:
    ans += i*(i-1)//2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
ans = 0

for i in range(len(S)):
    for j in range(i+1,len(S)+1):
        N = "".join(S[i:j])
        N = int(N)
        if N%2019 == 0:
            ans += 1

print(ans)

Fixed submission:
S = list(input())
L = [0]*2019
L[0]=1
digit = 1
x = 0

for i in S[::-1]:
    x += digit*int(i)
    digit *= 10
    x %= 2019
    digit %= 2019 
    L[x] += 1

ans = 0

for i in L:
    ans += i*(i-1)//2

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math

def tgcd(a,b,c):
    return math.gcd(a,math.gcd(b,c))

K = int(input())
ans = 0

for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            ans += tgcd(i,j,k)

print(ans)

Fixed submission:
import math

K = int(input())
ans = 0
for a in range(1,K-1):
    for b in range(a+1,K):
        for c in range(b+1,K+1):
            r = math.gcd(math.gcd(a,b),c)
            r *= 6
            ans += r
for a in range(1,K):
    for b in range(a+1,K+1):
        r = math.gcd(a,b)
        r *= 6
        ans += r
for a in range(1,K+1):
    ans += a
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N = int(input())
A = list(map(int, input().split()))
B = A[:]
B.sort()
C = [B[0]]
D = [1]
L = 0
for i in range(N-1):
    if B[i] == B[i+1]:
        D[L] += 1
    else:
        C.append(B[i+1])
        D.append(1)
        L += 1

E = []

for i in range(len(C)):
    t = 0
    for j in range(len(C)):
        if i == j and D[j]>2:
            t += cmb(D[j]-1,2)
        if i != j and D[j]>1:
            t += cmb(D[j],2)
    E.append(t)
for i in range(N):
    print(E[C.index(A[i])])

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
C = {}
for i in A:
    if i in C.keys():
        C[i] += 1
    else:
        C[i] = 1

total = 0

for i in C.keys():
   if C[i]>1:
        total += (C[i]*(C[i]-1))//2

for i in A:
    print(total-(C[i]-1))

Buggy python submission (verdict: Time Limit Exceeded):
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N = int(input())
A = list(map(int, input().split()))
B = A[:]
B.sort()
C = [B[0]]
D = [1]
L = 0
for i in range(N-1):
    if B[i] == B[i+1]:
        D[L] += 1
    else:
        C.append(B[i+1])
        D.append(1)
        L += 1

for i in range(N):
    ans = 0
    for j in range(len(C)):
        if C[j] == A[i] and D[j]>2:
            ans += cmb(D[j]-1,2)
        if C[j] != A[i] and D[j]>1:
            ans += cmb(D[j],2)
    print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
C = {}
for i in A:
    if i in C.keys():
        C[i] += 1
    else:
        C[i] = 1

total = 0

for i in C.keys():
   if C[i]>1:
        total += (C[i]*(C[i]-1))//2

for i in A:
    print(total-(C[i]-1))
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
L = 1
for i in range(Q):
    A = list(input().split())
    if int(A[0]) == 1:
        L = -L
    if int(A[0]) == 2:
        A[1] = 2*int(A[1]) - 3
        if L*A[1] == -1:
            S = A[2] + S
        else:
            S = S + A[2]

if L == 1:
    print(S)
else:
    print(''.join(list(reversed(S))))

Fixed submission:
from collections import deque

S = input()
Q = int(input())
L = 1
S = deque(S)

for i in range(Q):
    A = list(input().split())
    if int(A[0]) == 1:
        L = -L
    if int(A[0]) == 2:
        A[1] = 2*int(A[1]) - 3
        if L*A[1] == -1:
            S.appendleft(A[2])
        else:
            S.append(A[2])

if L == 1:
    print(''.join(S))
else:
    print(''.join(list(reversed(S))))
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = []
for i in range(N):
    S.append(input())
S.sort()
S.append("A")
print(S)
B = []
M = 1
T = 1
for i in range(N):
    if S[i] == S[i+1]:
        T += 1
    elif T < M:
        T = 1
    elif T == M:
        T = 1
        B.append(S[i])
    else:
        M = T
        T = 1
        B = [S[i]]

for i in range(B):
    print(B[i])

Fixed submission:
N = int(input())
S = []
for i in range(N):
    S.append(input())
S.sort()
S.append("A")
B = []
M = 1
T = 1
for i in range(N):
    if S[i] == S[i+1]:
        T += 1
    elif T < M:
        T = 1
    elif T == M:
        T = 1
        B.append(S[i])
    else:
        M = T
        T = 1
        B = [S[i]]

for i in range(len(B)):
    print(B[i])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = []
for i in range(N):
    S.append(input())
S.sort()
B = [S[0]]
C = [1]
for i in range(N-1):
    if S[i] == S[i+1]:
        C[B.index(S[i+1])] += 1
    else:
        B.append(S[i+1])
        C.append(1)

for i in range(len(C)):
    if C[i] == max(C):
        print(B[i])

Fixed submission:
N = int(input())
S = []
for i in range(N):
    S.append(input())
S.sort()
S.append("A")
B = []
M = 1
T = 1
for i in range(N):
    if S[i] == S[i+1]:
        T += 1
    elif T < M:
        T = 1
    elif T == M:
        T = 1
        B.append(S[i])
    else:
        M = T
        T = 1
        B = [S[i]]

for i in range(len(B)):
    print(B[i])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
A.sort()

for i in range(N-1):
    for j in range(N-i-1):
        if A[i] == A[i+j+1]:
            print("NO")
            exit()

print("YES")

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A.sort()

for i in range(N-1):
    if A[i] == A[i+1]:
        print("NO")
        exit()

print("YES")

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = tuple(input().split())

for i in range(N-1):
    for j in range(N-i-1):
        if A[i] == A[i+j+1]:
            print("NO")
            exit()

print("YES")

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A.sort()

for i in range(N-1):
    if A[i] == A[i+1]:
        print("NO")
        exit()

print("YES")

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

for i in range(N-1):
    for j in range(N-i-1):
        if A[i] == A[i+j+1]:
            print("NO")
            exit()

print("YES")

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A.sort()

for i in range(N-1):
    if A[i] == A[i+1]:
        print("NO")
        exit()

print("YES")

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

for i in range(N-1):
    for j in range(N-i):
        if A[i] == A[i+j+1]:
            print("NO")
            exit()

print("YES")

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A.sort()

for i in range(N-1):
    if A[i] == A[i+1]:
        print("NO")
        exit()

print("YES")
Buggy python submission (verdict: Time Limit Exceeded):
N,K = list(map(int, input().split()))
A = list(map(int, input().split()))

for i in range(N):
    A[i] = (A[i]+1)/2

t = 0
for i in range(K):
    t += A[i]
L = (t,)

ans = 0

for i in range(N-K):
    L  = L + (L[i]+A[K+i]-A[i],)
    ans = max(ans, L[i+1])
print(max(L))

Fixed submission:
N,K = list(map(int, input().split()))
A = list(map(int, input().split()))

L = 0
for i in range(K):
    L += A[i]

ans = L

for i in range(N-K):
    L  = L+A[K+i]-A[i]
    ans = max(ans, L)
ans += K
ans /= 2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = list(map(int, input().split()))
A = list(map(int, input().split()))

for i in range(N[0]):
    A[i] = (A[i]+1)/2

t = 0
for i in range(N[1]):
    t += A[i]

L = (t,)

for i in range(N[0]-N[1]):
    L  = L + (L[i] + A[N[1]+i]-A[i] ,)
print(max(L))

Fixed submission:
N,K = list(map(int, input().split()))
A = list(map(int, input().split()))

L = 0
for i in range(K):
    L += A[i]

ans = L

for i in range(N-K):
    L  = L+A[K+i]-A[i]
    ans = max(ans, L)
ans += K
ans /= 2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = list(map(int, input().split()))
A = list(map(int, input().split()))

for i in range(len(A)):
    A[i] = (A[i]+1)/2

t = 0
for i in range(N[1]):
    t += A[i]

L = (t,)

for i in range(N[0]-N[1]):
    L  = L + (L[i] + A[N[1]+i]-A[i] ,)
print(max(L))

Fixed submission:
N,K = list(map(int, input().split()))
A = list(map(int, input().split()))

L = 0
for i in range(K):
    L += A[i]

ans = L

for i in range(N-K):
    L  = L+A[K+i]-A[i]
    ans = max(ans, L)
ans += K
ans /= 2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = list(map(int, input().split()))
A = list(map(int, input().split()))

for i in range(len(A)):
    A[i] = (A[i]+1)/2

L = [0]*(N[0]-N[1]+1)

for i in range(N[0]-N[1]+1):
    for j in range(N[1]):
        L [i] += A[i+j]
print(max(L))

Fixed submission:
N,K = list(map(int, input().split()))
A = list(map(int, input().split()))

L = 0
for i in range(K):
    L += A[i]

ans = L

for i in range(N-K):
    L  = L+A[K+i]-A[i]
    ans = max(ans, L)
ans += K
ans /= 2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = list(map(int, input().split()))
A = list(map(int, input().split()))
L = [0]*(N[0]-N[1]+1)

for i in range(N[0]-N[1]+1):
    for j in range(N[1]):
        for k in range(A[i+j]):
            L[i] += (k+1)/A[i+j]

print(max(L))

Fixed submission:
N,K = list(map(int, input().split()))
A = list(map(int, input().split()))

L = 0
for i in range(K):
    L += A[i]

ans = L

for i in range(N-K):
    L  = L+A[K+i]-A[i]
    ans = max(ans, L)
ans += K
ans /= 2
print(ans)