Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

acc = 1
for i in input().split():
  acc *= int(i)

if acc > 10**18:
  print('-1')
else:
  print(acc)


Fixed submission:
N = int(input())
AS = [int(i) for i in input().split()]

m = 10 ** 18
acc = 1
if 0 in AS:
  print(0)
  import sys
  sys.exit()

for i in AS:
  acc *= i
  if acc > m:
    print('-1')
    import sys
    sys.exit()

print(acc)

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

N = int(input())
AS = [int(i) for i in input().split()]

m = reduce(mul, AS, 1)
if m > 10**18:
  print('-1')
else:
  print(m)


Fixed submission:
N = int(input())
AS = [int(i) for i in input().split()]

m = 10 ** 18
acc = 1
if 0 in AS:
  print(0)
  import sys
  sys.exit()

for i in AS:
  acc *= i
  if acc > m:
    print('-1')
    import sys
    sys.exit()

print(acc)
Buggy python submission (verdict: Runtime Error):
from copy import deepcopy

N, M, X = [int(i) for i in input().split()]

CAS = [[int(i) for i in input().split()] for _ in range(N)]


ok = False
mi = [float('inf'), *[0]*(M-1)]

fs = '{:0' + str(M) + 'b}'

for i in range(2**N):
  s = fs.format(i)
  t = [0]*M
  for i, f in enumerate(s):
    if f == '1':
      t = [a+b for a, b in zip(CAS[i], t)]

  if all(a >= X for a in t[1:]) and mi[0] > t[0]:
    mi = t
    ok = True


if ok:
  print(mi[0])
else:
  print(-1)


Fixed submission:
from copy import deepcopy

N, M, X = [int(i) for i in input().split()]

CAS = [[int(i) for i in input().split()] for _ in range(N)]


ok = False
mi = [float('inf'), *[0]*(M)]

fs = '{:0' + str(N) + 'b}'

for i in range(2**N):
  s = fs.format(i)
  t = [0]*(M+1)
  for i, f in enumerate(s):
    if f == '1':
      t = [a+b for a, b in zip(CAS[i], t)]

  if all(a >= X for a in t[1:]) and mi[0] > t[0]:
    mi = t
    ok = True


if ok:
  print(mi[0])
else:
  print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
L, R = [int(i) for i in input().split()]

c = set()

for i in range(L, R + 1):
  t = i % 2019
  if i in c:
    break
  c.add(i)


m = float('inf')
l = list(c)
for i in range(len(l)):
  for j in range(i + 1, len(l)):
    m = min(m, l[i] * l[j] % 2019)

print(m)


Fixed submission:
L, R = [int(i) for i in input().split()]

c = set()

for i in range(L, R + 1):
  t = i % 2019
  if t in c:
    break
  c.add(t)


m = float('inf')
l = list(c)
for i in range(len(l)):
  for j in range(i + 1, len(l)):
    m = min(m, l[i] * l[j] % 2019)

print(m)
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = [int(i) for i in input().split()]
S = input()

cs = []
for i in range(1, 1 + N):
  cs.append(S[:i].count('AC'))

for l, r in ([int(i) for i in input().split()] for _ in range(Q)):
  print(cs[r - 1] - cs[l - 1])


Fixed submission:
N, Q = [int(i) for i in input().split()]
S = input()
lrs = [[int(i) for i in input().split()] for _ in range(Q)]


cache = {1: {'c': 0, 'm': False}}
cnt = 0
for i in range(1, N):
    if S[i - 1]+S[i] == 'AC':
        cnt += 1
    cache[i + 1] = {'c': cnt, 'm': True}

for l, r in lrs:
    print(cache[r]['c'] - cache[l]['c'])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = [int(i) for i in input().split()]
S = input()
lrs = [[int(i) for i in input().split()] for _ in range(Q)]


for l, r in lrs:
    print(S[l - 1:r].count('AC'))


Fixed submission:
N, Q = [int(i) for i in input().split()]
S = input()
lrs = [[int(i) for i in input().split()] for _ in range(Q)]


cache = {1: {'c': 0, 'm': False}}
cnt = 0
for i in range(1, N):
    if S[i - 1]+S[i] == 'AC':
        cnt += 1
    cache[i + 1] = {'c': cnt, 'm': True}

for l, r in lrs:
    print(cache[r]['c'] - cache[l]['c'])
Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce


A, B = [int(i) for i in input().split()]

print(reduce(lambda acc, x: acc ^ x, range(A, B + 1), 0))


Fixed submission:
A, B = [int(i) for i in input().split()]

def calc(i):
  rem = i % 4
  if rem == 0:
    return i
  elif rem == 1:
    return 1
  elif rem == 2:
    return i + 1
  elif rem == 3:
    return 0

print(calc(A - 1) ^ calc(B))
Buggy python submission (verdict: Time Limit Exceeded):
import re
S = input()

cnt = 0
while True:
  s = re.sub('01|10', '', S, 1)
  if s != S:
    S = s
    cnt += 2
  else:
    print(cnt)
    exit()


Fixed submission:
import re
S = input()

print(min(S.count('0'), S.count('1')) * 2)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = [int(i) for i in input().split()]
XS = [int(i) for i in input().split()]

if M < N:
  print(0)
else:
  xs = sorted(XS)
  ds = list(map(lambda a,b: b-a, xs, xs[1:]))
  for _ in range(N-1):
    ds.remove(max(ds))

  print(sum(ds))


Fixed submission:
N, M = [int(i) for i in input().split()]
XS = [int(i) for i in input().split()]

if M <= N:
  print(0)
else:
  xs = sorted(XS)
  ds = list(map(lambda a,b: b-a, xs, xs[1:]))
  print(sum(sorted(ds)[:M-N]))
Buggy python submission (verdict: Time Limit Exceeded):
N, K = [int(i) for i in input().split()]
HS = [int(i) for i in input().split()]

dp = [float('inf')]*N

dp[0] = 0
dp[1] = abs(HS[1] - HS[0])

for i in range(2, N):
  dp[i] = min([dp[i-k] + abs(HS[i] - HS[i-k]) for k in range(1, K + 1)])

print(dp[N-1])


Fixed submission:
N, K = [int(i) for i in input().split()]
HS = [int(i) for i in input().split()]

dp = [float('inf')]*N

dp[0] = 0
dp[1] = abs(HS[1] - HS[0])

for i in range(2, N):
  dp[i] = min([dp[i-k] + abs(HS[i] - HS[i-k]) for k in range(1, K + 1)])

print(dp[N-1])
Buggy python submission (verdict: Runtime Error):
N, M = [int(i) for i in input().split()]

if N == 1 and M == 1:
    print(1)
elif N == 1:
    print(M - 2)
elif M == 1:
    print(N - 2)
else:
    print(N * M - ((N - 2) * 2 + (M - 2) * 2) - 4)



Fixed submission:
l = [input() for i in range(3)]

print(''.join([l[0][:1], l[1][1:2], l[2][2:3]]))
Buggy python submission (verdict: Time Limit Exceeded):
def back(x, y, N, M):
    if x == 0 and x == (N - 1) and y == 0 and y == (M - 1):
        return True

    if x == 0 and x == (N - 1) and (y == 0 or y == (M - 1)):
        return False

    if (x == 0 or x == (N - 1)) and y == 0 and y == (M - 1):
        return False

    if x == 0 and x == (N - 1):
        return True

    if y == 0 and y == (M - 1):
        return True

    if x == 0:
        return False

    if x == (N - 1):
        return False

    if y == 0:
        return False

    if y == (M - 1):
        return False

    return True



N, M = [int(i) for i in input().split()]

print(len([None for i in range(N) for j in range(M) if back(i, j, N, M)]))


Fixed submission:
N, M = [int(i) for i in input().split()]

if N == 1 and M == 1:
    print(1)
elif N == 1:
    print(M - 2)
elif M == 1:
    print(N - 2)
else:
    print(N * M - ((N - 2) * 2 + (M - 2) * 2) - 4)

Buggy python submission (verdict: Time Limit Exceeded):
def back(p, N, M):
    x, y = p
    if x == 0 and x == (N - 1) and y == 0 and y == (M - 1):
        return True

    if x == 0 and x == (N - 1) and (y == 0 or y == (M - 1)):
        return False

    if (x == 0 or x == (N - 1)) and y == 0 and y == (M - 1):
        return False

    if x == 0 and x == (N - 1):
        return True

    if y == 0 and y == (M - 1):
        return True

    if x == 0:
        return False

    if x == (N - 1):
        return False

    if y == 0:
        return False

    if y == (M - 1):
        return False

    return True



N, M = [int(i) for i in input().split()]

print(len([p for p in [[i, j] for i in range(N) for j in range(M)] if back(p, N, M)]))


Fixed submission:
N, M = [int(i) for i in input().split()]

if N == 1 and M == 1:
    print(1)
elif N == 1:
    print(M - 2)
elif M == 1:
    print(N - 2)
else:
    print(N * M - ((N - 2) * 2 + (M - 2) * 2) - 4)
Buggy python submission (verdict: Runtime Error):
N = int(input())

tree = {}

for _ in range(N-1):
  A, B, C = [int(i) for i in input().split()]
  if A not in tree:
    tree[A] = []
  if B not in tree:
    tree[B] = []
  tree[A].append((B, C))
  tree[B].append((A, C))


c = {}
q = []
visited = set()

def dfs(a, acc):
  c[a] = acc
  for n, cost in tree[a]:
    if n not in visited:
      visited.add(n)
      dfs(n, acc + cost)


Q, K = [int(i) for i in input().split()]
visited.add(K)
c[K] = 0
dfs(K, 0)

for _ in range(Q):
  x, y = [int(i) for i in input().split()]
  print(c[x] + c[y])


Fixed submission:
N = int(input())

tree = {}

for _ in range(N-1):
  A, B, C = [int(i) for i in input().split()]
  if A not in tree:
    tree[A] = []
  if B not in tree:
    tree[B] = []
  tree[A].append((B, C))
  tree[B].append((A, C))


c = {}
q = []
visited = set()

def dfs(a, acc):
  q.append((a, acc))

  while q:
    n, r = q.pop()
    c[n] = r
    visited.add(n)
    for b, cost in ((b, cost) for b, cost in tree[n] if b not in visited):
      q.append((b, cost + r))


Q, K = [int(i) for i in input().split()]
dfs(K, 0)

for _ in range(Q):
  x, y = [int(i) for i in input().split()]
  print(c[x] + c[y])
Buggy python submission (verdict: Time Limit Exceeded):
N, M = [int(i) for i in input().split()]

cnt = min(N, M // 2)
N -= cnt
M -= cnt * 2

while True:
  if N >= 1:
    N -= 1
  elif M >= 2:
    M -= 2
  else:
    break

  if M >= 2:
    cnt += 1
    M -= 2
  else:
    break

print(cnt)


Fixed submission:
N, M = [int(i) for i in input().split()]

cnt = min(N, M // 2)
N -= cnt
M -= cnt * 2

if M > 0:
  cnt += M // 4

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = [int(i) for i in input().split()]

cnt = min(N, M // 2)
N -= cnt
M -= cnt * 2

while True:
  if N >= 1:
    N -= 1
  elif M >= 2:
    M -= 2
  else:
    break

  if M >= 2:
    cnt += 1
    M -= 2
  else:
    break

print(cnt)


Fixed submission:
N, M = [int(i) for i in input().split()]

cnt = min(N, M // 2)
N -= cnt
M -= cnt * 2

if M > 0:
  cnt += M // 4

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = [int(i) for i in input().split()]

cnt = 0
while True:
  if N >= 1:
    N -= 1
  elif M >= 2:
    M -= 2
  else:
    break

  if M >= 2:
    cnt += 1
    M -= 2
  else:
    break

print(cnt)


Fixed submission:
N, M = [int(i) for i in input().split()]

cnt = min(N, M // 2)
N -= cnt
M -= cnt * 2

if M > 0:
  cnt += M // 4

print(cnt)
Buggy python submission (verdict: Runtime Error):
N=int(input())

def make_divisors(n):
    divisors=[]
    for i range(1,int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    
    divisors.sort()
    return divisors

ans=0
divisors=make_divisors(N)

for d in divisors:
    m=(d-1)
    if m and (N//m==N%m):
        ans+=m

print(ans)

Fixed submission:
N=int(input())

def make_divisors(n):
    divisors=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    
    divisors.sort()
    return divisors

ans=0
divisors=make_divisors(N)

for d in divisors:
    m=(d-1)
    if m and (N//m==N%m):
        ans+=m

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
satu = n//1000
if n n % 1000 == 0:
  print(0)
  quit()
ans = 1000*(satu+1)-n
print(ans)

Fixed submission:
n = int(input())
satu = n//1000
if  n % 1000 == 0:
  print(0)
  quit()
ans = 1000*(satu+1)-n
print(ans)
Buggy python submission (verdict: Runtime Error):
heapq.heapify(b)

n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
a = deque(a)

heapq.heappush(b,-1*a.popleft())
ans = 0

while len(a)>0:
  temp = a.popleft()
  point = -1*heapq.heappop(b)
  ans+=point
  heapq.heappush(b, -1*temp)
  heapq.heappush(b, -1*temp)
  
print(ans)
  

Fixed submission:
import heapq
from collections import deque
b=[]
heapq.heapify(b)

n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
a = deque(a)

heapq.heappush(b,-1*a.popleft())
ans = 0

while len(a)>0:
  temp = a.popleft()
  point = -1*heapq.heappop(b)
  ans+=point
  heapq.heappush(b, -1*temp)
  heapq.heappush(b, -1*temp)
  
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
print(int(a+a**2+a**3))

Fixed submission:
n = int(input())   
print(int(n+n**2+n**3))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 0

while len(a) >= 1:
  ans += 1
  temp=a.pop(0)
  if len(a) >= 1:
    if a[0] == temp:
      ans -= 1
    a = list(filter(lambda x: x % temp != 0, a))
  
print(ans)

Fixed submission:
a = list(map(int, input().split()))
for i in range(5):
  if a[i] == 0:
    print(i+1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 0

while len(a) >= 1:
  ans += 1
  temp=a.pop(0)
  if len(a) >= 1:
    if a[0] == temp:
      ans -= 1
    a = list(filter(lambda x: x % temp != 0, a))
  
print(ans)

Fixed submission:
n = int(input())
a  = list(map(int, input().split()))
a.sort()
dp = [0]*a[n-1]
ans = 0
temp2 = 0
for i in range(n):
  if temp2 == a[i]:
    ans -= 1
    temp2=0
  if dp[a[i]-1] == 0:
    ans += 1
    temp = a[i]
    temp2 = a[i]
    while temp <= a[n-1]:
      dp[temp-1] = 1
      temp = temp+a[i]
  #print(dp)    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 0
for i in range(n):
  if a[i] != 0:
    if i == n-1:
      ans +=1
    else: 
      if a[i] == a[i+1]:
        for j in range(i+1, n):
          if a[j]%a[i]==0:
            a[j]=0
      else:
        ans += 1
        for j in range(i+1, n):
          if a[j]%a[i]==0:
            a[j]=0
        
    
print(ans)

Fixed submission:
n = int(input())
a  = list(map(int, input().split()))
a.sort()
dp = [0]*a[n-1]
ans = 0
temp2 = 0
for i in range(n):
  if temp2 == a[i]:
    ans -= 1
    temp2=0
  if dp[a[i]-1] == 0:
    ans += 1
    temp = a[i]
    temp2 = a[i]
    while temp <= a[n-1]:
      dp[temp-1] = 1
      temp = temp+a[i]
  #print(dp)    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = list(map(int, input().split()))
tele = list(map(int, input().split()))
loc = 1
act = [[0]*n for i in range(n)]
count = 1
log = []
log.append(loc)
while True:
  newloc=tele[loc-1]
  log.append(newloc)
  #print(newloc)
  if act[loc-1][newloc-1] == 0:
    act[loc-1][newloc-1] =count
    act[newloc-1][loc-1] =count
  else:
    loop=count-act[loc-1][newloc-1]
    loopstart=act[loc-1][newloc-1]
    break
  count+=1
  loc=newloc

if k <= loopstart:
  ans=log[k]
else:
  num = (k-(loopstart-1)) % loop 
  ans=log[loopstart-1+num]
#print(loop)
#print(loopstart)
#print(count)
#print(act)
#print(log)
print(ans)
    
  

Fixed submission:
n, k = list(map(int, input().split()))
tele = list(map(int, input().split()))
loc = 1
act = [-1]*n
act[0]=0
count = 1
log = []
log.append(loc)
flg = True
while True:
  newloc=tele[loc-1]
  if count ==k:
    print(newloc)
    flg = False
  log.append(newloc)
  #print(newloc)
  if act[newloc-1] == -1:
    act[newloc-1] =count
  else:
    loop=count-act[newloc-1]
    loopstart=act[newloc-1]
    break
  count+=1
  loc=newloc

  

if flg:
  num = (k-loopstart) % loop 
  ans=log[loopstart+num]
  print(ans)

#print(loopstart)
#print(log)
#print(log[loopstart])
#print(num)
Buggy python submission (verdict: Time Limit Exceeded):
N ,M = list(map(int, input().split()))
H = list(map(int, input().split()))
lis = [[0] * N for i in range(N)]

for i in range(M):
  A, B = list(map(int, input().split()))
  lis[A-1][B-1]=H[B-1]
  lis[B-1][A-1]=H[A-1]
  
ans = 0

for i in range(N):
  if max(lis[i]) < H[i]:
    ans += 1
  elif max(lis) == 0:
    ans += 1
print(ans)

Fixed submission:
N ,M = list(map(int, input().split()))
H = list(map(int, input().split()))
lis = [1] * N
for i in range(M):
  A, B = list(map(int, input().split()))
  if H[A-1] > H[B-1]:
    lis[B-1]=0
  elif H[A-1] < H[B-1]:
    lis[A-1]=0
  else:
    lis[A-1]=0
    lis[B-1]=0
    
print(lis.count(1))
Buggy python submission (verdict: Runtime Error):
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
  
x = int(input())
lis = make_divisors(x)
for i in range(0, len(lis)):

  for j in range(-100,100):
    if (j+lis[i])**5 -j**5 ==x:
      ans = str(j+lis[i])+' '+str(j)
      break

print(ans)

Fixed submission:
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
  
x = int(input())
lis = make_divisors(x)
flg = False

for i in range(0, len(lis)):

  for j in range(-1000,1000):
    if (j+lis[i])**5 -j**5 ==x:
      ans = str(j+lis[i])+' '+str(j)
      #flg = False
      break


if flg:
  for i in range(0, len(lis)):
    for j in range(-1000,1000):
      if (j+lis[i])**5 -j**5 ==x:
        ans = str(j+lis[i])+' '+str(j)
        break

  
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math
A, B, N = list(map(int, input().split()))
max = -10000
for i in range(1, N+1):
  temp = math.floor(A*i/B)-A*math.floor(i/B)
  if temp >= max:
    max =  temp
    
print(max)
  

Fixed submission:
import math
A, B, N = list(map(int, input().split()))
if B-1 >= N:
  num = N
else:
  num = B-1
  
print(math.floor(A*num/B)-A*math.floor(num/B))
Buggy python submission (verdict: Runtime Error):
import math 
a = int(input)
print(math.pi * 2 * a)


Fixed submission:
import math 
a = int(input())
ans = 2 * a * math.pi
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
dic = {}

for _ in range(N):
  inp = input()
  if inp not in dic:
    dic[inp] = 1
  else:
    dic[inp] = dic[inp] + 1

ans = [kv[0] for kv in dic.items() if kv[1] == max(dic.values())]
ans.sort()
for i in ans:
  print(i)

Fixed submission:
N = int(input())
dic = {}

for _ in range(N):
  inp = input()
  if inp not in dic:
    dic[inp] = 1
  else:
    dic[inp] = dic[inp] + 1

num = max(dic.values())
ans = []
for i in dic:
  if dic[i] == num:
    ans.append(i)
    
ans.sort()
for i in ans:
  print(i)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
num = list(map(int, input().split()))
ans = "YES"
lis = []
for i in num:
  if not i in lis:
    lis.append(i)
  else:
    ans="NO"
    break
    
print(ans)

Fixed submission:
n = int(input())
num = list(map(int, input().split()))
lenbef = len(num)
numset = set(num)
lenaft = len(numset)

if lenbef == lenaft:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
N ,K = list(map(int, input().split()))
p = list(map(lambda x: (1+int(x))/2, input().split()))
s = [0]*N
s[0]=p[0]
for i in range(1,N):
  s[i] = s[i-1]+p[i]

l = []
for i in range(N-K):
  l.append(s[i+K]-s[i])
  
print(max(l))

Fixed submission:
N ,K = list(map(int, input().split()))
p = list(map(lambda x: (1+int(x))/2, input().split()))
s = [0]*N
s[0]=p[0]
for i in range(1,N):
  s[i] = s[i-1]+p[i]

l = [s[K-1]]
for i in range(N-K):
  l.append(s[i+K]-s[i])

print(max(l))

Buggy python submission (verdict: Runtime Error):
import numpy as np
N ,K = list(map(int, input().split()))
p = list(map(lambda x: (1+int(x))/2, input().split()))
s = [0]*N
s[0]=p[0]
sum = 0
for i in range(1,N):
  s[i] = s[i-1]+p[i]

l = []
for i in range(N-K):
  l.append(s[i+K]-s[i])
  
print(max(l))

Fixed submission:
N ,K = list(map(int, input().split()))
p = list(map(lambda x: (1+int(x))/2, input().split()))
s = [0]*N
s[0]=p[0]
for i in range(1,N):
  s[i] = s[i-1]+p[i]

l = [s[K-1]]
for i in range(N-K):
  l.append(s[i+K]-s[i])

print(max(l))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N ,K = list(map(int, input().split()))
p = list(map(int, input().split()))
pline=[]
for i in range(N-K+1):
  p[i] = sum(np.array(list(map(lambda x: (x+1)/2, p[i:i+K]))))
  
print(max(p))

Fixed submission:
N ,K = list(map(int, input().split()))
p = list(map(lambda x: (1+int(x))/2, input().split()))
s = [0]*N
s[0]=p[0]
for i in range(1,N):
  s[i] = s[i-1]+p[i]

l = [s[K-1]]
for i in range(N-K):
  l.append(s[i+K]-s[i])

print(max(l))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N ,K = list(map(int, input().split()))
p = np.array(list(map(int, input().split())))
pline=[]
for i in range(N-K+1):
  num = np.array(list(map(lambda x: (x+1)/2, p[i:i+K])))
  pline.append(num.sum())
print(max(pline))

Fixed submission:
N ,K = list(map(int, input().split()))
p = list(map(lambda x: (1+int(x))/2, input().split()))
s = [0]*N
s[0]=p[0]
for i in range(1,N):
  s[i] = s[i-1]+p[i]

l = [s[K-1]]
for i in range(N-K):
  l.append(s[i+K]-s[i])

print(max(l))

Buggy python submission (verdict: Time Limit Exceeded):
N ,K = list(map(int, input().split()))
p = list(map(int, input().split()))
pline=[]
for i in range(N-K+1):
  num = 0
  for j in range(K):
    num+= (p[i+j]+1)/2
  pline.append(num)

print(max(pline))

Fixed submission:
N ,K = list(map(int, input().split()))
p = list(map(lambda x: (1+int(x))/2, input().split()))
s = [0]*N
s[0]=p[0]
for i in range(1,N):
  s[i] = s[i-1]+p[i]

l = [s[K-1]]
for i in range(N-K):
  l.append(s[i+K]-s[i])

print(max(l))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
ans = 0
lis = [0]*1000
#one = [0]*10
#two = [0]*10
#three=[0]*10
from itertools import combinations
for i,j,k in combinations(list(range(n)), 3):
  temp = int("".join([s[i], s[j], s[k]]))
  if lis[temp]==0:
    ans+=1
    lis[temp]=1
print(ans)

Fixed submission:
n = int(input())
s = input()
ans = 0
lis = [0]*1000
one = [0]*10
two = [0]*100

for i in range(n):
  temp1 = int(s[i])
  if one[temp1]==1:
    continue
  else:
    one[temp1]=1
 
  for j in range(i+1, n):
    temp2 =  int("".join([s[i], s[j]]))
    if two[temp2]==1:
      continue
    else:
      two[temp2]=1
    
    for k in range(j+1, n):
      pin=int("".join([s[i], s[j], s[k]]))
      if lis[pin]==0:
        ans+=1
        lis[pin]=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
ans = 0
lis = [0]*1000
for i in range(n):
  for j in range(i+1, n):
    for k in range(j+1, n):
      num = int("".join([s[i],s[j],s[k]]))
      #print(num)
      if lis[num]==0:
        ans+=1
        lis[num]=1
print(ans)

Fixed submission:
n = int(input())
s = input()
ans = 0
lis = [0]*1000
one = [0]*10
two = [0]*100

for i in range(n):
  temp1 = int(s[i])
  if one[temp1]==1:
    continue
  else:
    one[temp1]=1
 
  for j in range(i+1, n):
    temp2 =  int("".join([s[i], s[j]]))
    if two[temp2]==1:
      continue
    else:
      two[temp2]=1
    
    for k in range(j+1, n):
      pin=int("".join([s[i], s[j], s[k]]))
      if lis[pin]==0:
        ans+=1
        lis[pin]=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
ans = 0
lis = [0]*1000
for i in range(n):
  for j in range(i+1, n):
    for k in range(j+1, n):
      num = int("".join([s[i],s[j],s[k]]))
      #print(num)
      if lis[num]==0:
        ans+=1
        lis[num]=1
print(ans)

Fixed submission:
n = int(input())
s = input()
ans = 0
lis = [0]*1000
one = [0]*10
two = [0]*100

for i in range(n):
  temp1 = int(s[i])
  if one[temp1]==1:
    continue
  else:
    one[temp1]=1
 
  for j in range(i+1, n):
    temp2 =  int("".join([s[i], s[j]]))
    if two[temp2]==1:
      continue
    else:
      two[temp2]=1
    
    for k in range(j+1, n):
      pin=int("".join([s[i], s[j], s[k]]))
      if lis[pin]==0:
        ans+=1
        lis[pin]=1
print(ans)