Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
values = list(map(int, input().split()))
if 0 in values:
  print(0)
  return

mult = 1
for i in values:
  mult *= i
  if mult > 1000000000000000000:
    print(-1)
    return

print(mult)

Fixed submission:
def main():
  n = int(input())
  values = list(map(int, input().split()))
  if 0 in values:
    print(0)
    return

  mult = 1
  for i in values:
    mult *= i
    if mult > 1000000000000000000:
      print(-1)
      return
  print(mult)

main()

Buggy python submission (verdict: Runtime Error):
def main ():
  n = int(input())
  values = list(map(int, input().split()))
  if 0 in values:
    print(0)
    return
  
  mult = 1
  for i in values:
    mult *= i
    if mult > 10**18:
      print(-1)
      return
    
    print(prod)
    
main ()


Fixed submission:
def main():
  n = int(input())
  values = list(map(int, input().split()))
  if 0 in values:
    print(0)
    return

  mult = 1
  for i in values:
    mult *= i
    if mult > 1000000000000000000:
      print(-1)
      return
  print(mult)

main()

Buggy python submission (verdict: Runtime Error):
import psyco
psyco.full()

n = int(input())
values = input().split()
mult = 1

for i in range(len(values)):
  mult *= int(values[i])
  if mult > 10**18:
    mult = -1
    break
    
print(mult)


Fixed submission:
def main():
  n = int(input())
  values = list(map(int, input().split()))
  if 0 in values:
    print(0)
    return

  mult = 1
  for i in values:
    mult *= i
    if mult > 1000000000000000000:
      print(-1)
      return
  print(mult)

main()

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
values = input().split()

mult = 1
for i in range(len(values)):
  mult *= int(values[i])
  
if mult > 10**18:
  print(-1)
else:
  print(mult)


Fixed submission:
def main():
  n = int(input())
  values = list(map(int, input().split()))
  if 0 in values:
    print(0)
    return

  mult = 1
  for i in values:
    mult *= i
    if mult > 1000000000000000000:
      print(-1)
      return
  print(mult)

main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys

N = int(input())
a_list = list(map(int, input().split()))

def inZero(nums):
  return 0 in nums

def isOverDigits(nums):
  digits = 0

  for i in range(len(nums)):
    digits += len(str(nums[i])) - 1

  if digits > 18:
    return True
  else:
    return False

def calcAns(nums):
  ans = 1
  for i in range(len(nums)):
    ans = ans * nums[i]
  return ans

if inZero(a_list):
  print(0)
  sys.exit()

ans = calcAns(a_list) 

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





Fixed submission:
import sys

N = int(input())
a_list = list(map(int, input().split()))

def inZero(nums):
  return 0 in nums

def isOverDigits(nums):
  digits = 0

  for i in range(len(nums)):
    digits += len(str(nums[i])) - 1

  if digits > 18:
    return True
  else:
    return False

def calcAns(nums):
  ans = 1
  for i in range(len(nums)):
    ans = ans * nums[i]
    if ans > 10**18 :
      return False
  return ans

if inZero(a_list):
  print(0)
  sys.exit()

ans = calcAns(a_list) 

if ans :
  print(ans)
else :
  print(-1)
Buggy python submission (verdict: Time Limit Exceeded):

def gcd(a, b) :
  if a % b == 0 :
    return b
  
  return gcd(b, a%b)

K = int(input())
ans = 0

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

print(ans)

Fixed submission:

def gcd(a, b) :
  if a % b == 0 :
    return b
  
  return gcd(b, a%b)

K = int(input())
ans = 0

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

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):

def gcd(a, b) :
  if b == 0 :
    return a
  
  return gcd(b, a%b)

K = int(input())
ans = 0
for a in range(1,K+1):
  for b in range(1,K+1):
    for c in range(1,K+1):
      ans += gcd(gcd(a,b), c)

print(ans)

Fixed submission:

def gcd(a, b) :
  if a % b == 0 :
    return b
  
  return gcd(b, a%b)

K = int(input())
ans = 0

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

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

N, K = map(int, input().split())

if K == 1:
  print(0)
else:
  # N_swp = np.abs(N - K)
  N_swp = math.sqrt((N - K)**2)
  while N_swp != 0 and N_swp < N :
    N = N_swp
    # N_swp = np.abs(N - K)
    N_swp = math.sqrt((N - K)**2)
  print(int(N))


Fixed submission:

N, K = map(int, input().split())

if K == 1:
  print(0)
else:
  a = N % K
  if a > K-a:
    print(K-a)
  else:
    print(a)

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

N, K = map(int, input().split())

if K == 1:
  print(0)
else:
  N_swp = np.abs(N - K)
  while N_swp != 0 and N_swp < N :
    N = N_swp
    N_swp = np.abs(N - K)
  print(N)


Fixed submission:

N, K = map(int, input().split())

if K == 1:
  print(0)
else:
  a = N % K
  if a > K-a:
    print(K-a)
  else:
    print(a)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
p = list(map(int, input().split()))

max = 0

for i in range(N-K+1):
    tmp = p[i]
    # print("i:" + str(i))
    for j in range(i+1,i+K):
        tmp += p[j]

    # print(tmp)
    if(max < tmp):
        max = tmp 
        maxStartIndex = i
ans = 0
for i in range(maxStartIndex, maxStartIndex+K):
    sum = p[i] * (p[i]+1) / 2
    ans += sum/p[i]
print('{:.12f}'.format(ans))
# 1 2 3 
# 3 2 1


# n, n-1, n-2
# n(n + 1)/2 

Fixed submission:
N, K = map(int, input().split())
p = list(map(int, input().split()))
p_sum = [0]
max = 0

for i in range(len(p)):
    p_sum.append(p_sum[i] + (p[i]+1)/2) 

for i in range(K,N+1):
    sum = p_sum[i] - p_sum[i-K]
    if(max < sum):
        max = sum
# for i in range(N-K+1):
#     tmp = p[i]
#     # print("i:" + str(i))
#     for j in range(i+1,i+K):
#         tmp += p[j]

#     # print(tmp)
#     if(max < tmp):
#         max = tmp 
#         maxStartIndex = i
# ans = 0
# for i in range(maxStartIndex, maxStartIndex+K):
#     sum = p[i] * (p[i]+1) / 2
#     ans += sum/p[i]
print('{:.12f}'.format(max))
# 1 2 3 
# 3 2 1


# n, n-1, n-2
# n(n + 1)/2
Buggy python submission (verdict: Runtime Error):
def sort(A):
    if len(A) < 2:
        return A
    c = len(A)//2
    return merge(sort(A[:c]), sort(A[c:]))

def merge(X, Y):
    if len(X) < 1:
        return Y
    if len(Y) < 1:
        return X
    if (X[0] < Y[0]):
        return [Y[0]]+ merge(X, Y[1:])
    else:
        return [X[0]] + merge(X[1:], Y)

N, K = map(int, input().split())
enemyHP = list(map(int, input().split()))
enemyHP = sort(enemyHP)
if(len(enemyHP) <= K):
    print(0)
else:
    print(sum(enemyHP[K:]))



Fixed submission:
# def sort(A):
#     if len(A) < 2:
#         return A
#     c = len(A)//2
#     return merge(sort(A[:c]), sort(A[c:]))

# def merge(X, Y):
#     if len(X) < 1:
#         return Y
#     if len(Y) < 1:
#         return X
#     if (X[0] < Y[0]):
#         return [Y[0]]+ merge(X, Y[1:])
    # else:
#         return [X[0]] + merge(X[1:], Y)

N, K = map(int, input().split())
enemyHP = list(map(int, input().split()))
# enemyHP = sort(enemyHP)
enemyHP.sort(reverse=True)
if(len(enemyHP) <= K):
    print(0)
else:
    print(sum(enemyHP[K:]))
Buggy python submission (verdict: Runtime Error):
N = int(input())

c = [[0] for i in range(10)]

for i in range(1, N+1):
    s = str(i)
    c[int(s[0])][int(s[-1])] += 1

ans = 0

for i in range(10):
    for j in range(10):
        ans += c[i][j] * c[j][i]

print(ans)

Fixed submission:
N = int(input())

c = [[0]* 10 for i in range(10)]

for i in range(1, N+1):
    s = str(i)
    c[int(s[0])][int(s[-1])] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += c[i][j] * c[j][i]

print(ans)
Buggy python submission (verdict: Runtime Error):
def checkABC(S):
    count = 0
    for i in range(len(S)):
        if S[i] == 'A':
            if S[i+1] == 'B':
                if S[i+2] == 'C':
                    count += 1
    
    return count


N = int(input())

S = list(input())

print(checkABC(S))

Fixed submission:
def checkABC(S):
    count = 0
    for i in range(len(S)):
        if S[i] == 'A':
            if i+1 < len(S) and S[i+1] == 'B':
                if i+2 < len(S) and S[i+2] == 'C':
                    count += 1
    
    return count


N = int(input())

S = list(input())

print(checkABC(S))
Buggy python submission (verdict: Runtime Error):
import math

A,B,X = map(int,input().split())

# A * N + B * d(N) yen 

check_num = [1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000]

if((A*1+B*1)>X):
    print(0)
else:
    flag = True
    for i in range(len(check_num)):
        if((A*check_num[i]+B*(i+1)) > X):
            flag = False
            break
    if(flag):
        print(10**9)
    else:
        value = math.ceil((X - B*i)/A)
        print(value-1)


Fixed submission:

N = int(input())
words = list(input())

for i in range(len(words)):
    check_word  = ord(words[i]) + N 
    if(check_word > ord('Z')):
        print(chr(ord('A') + (check_word - ord('Z'))-1),end="")
    else:
        print(chr(check_word),end="")
print()
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())

if K = 1:
    print(0)
else:
    print(N-K)

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

if K == 1:
    print(0)
else:
    print(N-K)
Buggy python submission (verdict: Runtime Error):

N,K = map(int,input().split()) 
numbers = list(map(int,input().split()))
num_set = set(numbers)
KindNum = len(num_set)

if KindNum < K:
    print(0)
else:
    numCount = []
    count = 0
    for num_kind in num_set:
        numCount.append(numbers.count(num_kind))
    numCount.sort()
    count = sum(numCount[:KindNum - K])
print(count)



Fixed submission:
import collections as c
import numpy as np

N,K = map(int,input().split()) 
A = list(map(int,input().split()))
A_c = c.Counter(A)
A_c = sorted(list(A_c.values()))
KindNum = len(A_c)
if KindNum < K:
    print(0)
else:
    ans = sum(A_c[:KindNum - K])
    print(ans)

Buggy python submission (verdict: Runtime Error):

N,K = map(int,input().split()) 
numbers = list(map(int,input().split()))
num_set = set(numbers)

if len(num_set) < K:
    print(0)
else:
    numCount = []
    count = 0
    KindNum = len(num_set)
    for num_kind in num_set:
        numCount.append(numbers.count(num_kind))
    numCount.sort()
    count = sum(numCount[:KindNum - K])
print(count)



Fixed submission:
import collections as c
import numpy as np

N,K = map(int,input().split()) 
A = list(map(int,input().split()))
A_c = c.Counter(A)
A_c = sorted(list(A_c.values()))
KindNum = len(A_c)
if KindNum < K:
    print(0)
else:
    ans = sum(A_c[:KindNum - K])
    print(ans)
Buggy python submission (verdict: Runtime Error):

k,s = map(int,input().split())

count = 0

for x in range(0,k+1):
    #print(x)
    for y in range(0,k+1):
        #print(y)
        if 0 <= (s-x-y) and (s-x-y) <= k:
            count += 1
print(count)

Fixed submission:

s = input()

print(s.replace(',',' '))
Buggy python submission (verdict: Time Limit Exceeded):

k,s = map(int,input().split())

count = 0

for x in range(0,k+1):
    #print(x)
    for y in range(0,k+1):
        #print(y)
        for z in range(0,k+1):
            #print(z)
            if (x+y+z) == s :
                count += 1

print(count)

Fixed submission:

k,s = map(int,input().split())

count = 0

for x in range(0,k+1):
    for y in range(0,k+1):
        if 0 <= (s-x-y) and (s-x-y) <= k:
            count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
a,b=(x for x in input().split()) 
t=len(a)
aa=[]
bb=[]
for i in range(t):
  aa.append(a[i])
  bb.append(b[i])
    
   
if(aa==bb):
	print("Yes")
else:
	print("No")
    


Fixed submission:

#a,b=(int(x) for x in input().split()) #数値の時




#a,b=(x for x in input().split()) 
a=input()
print("\n")
b=input()
t=len(a)
aa=[]
bb=[]
for i in range(t):
    aa.append(a[i])
    bb.append(b[i])
 
if(aa==bb):
  print("Yes")
else:
	print("No")

Buggy python submission (verdict: Runtime Error):
a,b=(x for x in input().split()) 
t=len(a)
aa=[]
bb=[]
for i in range(t):
    aa.append(a[i])
    bb.append(b[i])
 
if(aa==bb):
  print("Yes")
else:
	print("No")
    

Fixed submission:

#a,b=(int(x) for x in input().split()) #数値の時




#a,b=(x for x in input().split()) 
a=input()
print("\n")
b=input()
t=len(a)
aa=[]
bb=[]
for i in range(t):
    aa.append(a[i])
    bb.append(b[i])
 
if(aa==bb):
  print("Yes")
else:
	print("No")

Buggy python submission (verdict: Runtime Error):
a,b=(x for x in input().split()) 
t=len(a)
aa=[]
bb=[]
for i in range(t):
  aa.append(a[i])
  bb.append(b[i])
 
if(aa==bb):
  print("Yes")
else:
	print("No")


Fixed submission:

#a,b=(int(x) for x in input().split()) #数値の時




#a,b=(x for x in input().split()) 
a=input()
print("\n")
b=input()
t=len(a)
aa=[]
bb=[]
for i in range(t):
    aa.append(a[i])
    bb.append(b[i])
 
if(aa==bb):
  print("Yes")
else:
	print("No")

Buggy python submission (verdict: Runtime Error):
a,b=(x for x in input().split()) 
t=len(a)
aa=[]
bb=[]
for i in range(t):
  aa.append(a[i])
  bb.append(b[i])
 
if(aa==bb):
  print("Yes)
else:
	print("No")

Fixed submission:

#a,b=(int(x) for x in input().split()) #数値の時




#a,b=(x for x in input().split()) 
a=input()
print("\n")
b=input()
t=len(a)
aa=[]
bb=[]
for i in range(t):
    aa.append(a[i])
    bb.append(b[i])
 
if(aa==bb):
  print("Yes")
else:
	print("No")
Buggy python submission (verdict: Runtime Error):
a,b,c,k=(int(x) for x in input().split())

if(k<=a):
  print(a*len(k))
else:
  sum=a*len(k)
  t=k-a
  if(t<=b):
    print(sum+b*len(t))
  else:
    sum+=b*len(t)
    t2=t-c
    print(sum+c*len(t2))

Fixed submission:

#a,b=(int(x) for x in input().split()) #数値の時




#a,b=(x for x in input().split()) 
a,b,c,k=(int(x) for x in input().split())

if(k<=a):
  print(k)
else:
  sum=a
  t=k-a
  if(t<=b):
    print(sum)
    
  else:
    t-=b
    
    
    print(sum-t)
Buggy python submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())
while 1:
  C -= B
  if C <= 0:
    print('Yes')
    break
  A -= D
  if A < 0:
     print('No')
     break

Fixed submission:
S, W = map(int, input().split())

if S <= W :
  print('unsafe')
else :
  print('safe')

Buggy python submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())
while 1:
  C -= B
  if C <= 0:
    print('Yes')
    break
  A -= D
  if A < 0:
     print('No')
     break

Fixed submission:
S, W = map(int, input().split())

if S <= W :
  print('unsafe')
else :
  print('safe')

Buggy python submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())
while true:
  C -= B
  if C <= 0:
    print('Yes')
    break
  A -= D
  if A < 0:
     print('No')
      break

Fixed submission:
S, W = map(int, input().split())

if S <= W :
  print('unsafe')
else :
  print('safe')

Buggy python submission (verdict: Runtime Error):
S, W = map(int, input().split())
if S < = W :
  print('unsafe')
else :
  print('safe')

Fixed submission:
S, W = map(int, input().split())

if S <= W :
  print('unsafe')
else :
  print('safe')
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))
total = sum(A) / 4 * M
A.sort(reverse = True)
if A[M-1] >= total:
  print('Yes')
else:
  print('No')

Fixed submission:
X, Y, Z = map(int, input().split())
A = X
B = Y
C = Z
A = Z
B = X
C = Y

print(int(A), int(B), int(C))
Buggy python submission (verdict: Runtime Error):
import math
N, A, B = map(int, input().split())

ans = 0

for x in range(1, N + 1):
    SUM = 0
    num = x
    while x > 0:
        SUM += (x % 10)
        x // = 10
    if A <= SUM <= B:
        ans += num
        
print(ans)

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

ans = 0

for x in range(1, N + 1):
    SUM = 0
    num = x
    while x > 0:
        SUM += (x % 10)
        x //= 10
    if A <= SUM <= B:
        ans += num
        
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, A, B = map(int, input().split())
cnt = 0
for i in range(1, N + 1):
    if A <= i <= B:
        cnt += i
    
    while True:
        if i % 10 < 1:
            break
        cnt += i // 10
        cnt += i % 10
print(cnt)

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

ans = 0

for x in range(1, N + 1):
    SUM = 0
    num = x
    while x > 0:
        SUM += (x % 10)
        x //= 10
    if A <= SUM <= B:
        ans += num
        
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
max_num = []
  
def yakusu(num):
    cd = []
    for i in range(1, int(num*0.5 + 1)):
        if num % i ==0:
            cd.append(i)
    return cd
  
for A in yakusu(N):
    for B in yakusu(N):
        if A * B == N:
            max_num.append(max(A, B))
            
print(len(str(max(max_num))))

Fixed submission:
n = int(input())
a = int(n **(0.5) + 1)
num = 1
for i in range(1,a + 1):
    if  n%i == 0:
        num = i
ans = max(num, n // num)
print(len(str(ans)))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

R = []
G = []
B = []

ans = 0

for i,col in enumerate(S):
    if col == 'R':
        R.append(i)
    elif col == 'G':
        G.append(i)
    else:
        B.append(i)


for r in R:
    for g in G:
        for b in B:
            l = sorted([r,g,b])
            if l[1]-l[0] != l[2]-l[1]:
                ans += 1

print(ans) 


Fixed submission:
N = int(input())
S = input()

R_count = S.count('R')
G_count = S.count('G')
B_count = S.count('B')

ans = R_count * G_count * B_count

for i in range(N-2):
    for d in range(1,N):
        if i+2*d >= N:
            break
        else:
            j = i+d
            k = j+d
            
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                ans -= 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

ans = 0

for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                if j-i != k-j:
                    ans +=1
print(ans)


Fixed submission:
N = int(input())
S = input()

R_count = S.count('R')
G_count = S.count('G')
B_count = S.count('B')

ans = R_count * G_count * B_count

for i in range(N-2):
    for d in range(1,N):
        if i+2*d >= N:
            break
        else:
            j = i+d
            k = j+d
            
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                ans -= 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

ans = 0

for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                if j-i != k-j:
                    ans +=1
print(ans)

Fixed submission:
N = int(input())
S = input()

R_count = S.count('R')
G_count = S.count('G')
B_count = S.count('B')

ans = R_count * G_count * B_count

for i in range(N-2):
    for d in range(1,N):
        if i+2*d >= N:
            break
        else:
            j = i+d
            k = j+d
            
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                ans -= 1

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

N,K = map(int,input().split())
p = list(map(int,input().split()))
ex=[]

ans=[]

for i in p:
    ex.append((1+i)/2)

for i in range(N-K+1):
    ans.append(sum(ex[i:i+K]))
    
print(max(ans))





Fixed submission:
# ruisekiwa by itertools

from itertools import accumulate

N,K = map(int,input().split())
p = list(map(int,input().split()))

b1=[0]+list(accumulate(p))

ans=[]

for i in range(N-K+1):
    ans.append(b1[K+i]-b1[i])
    
print((max(ans)+K)/2)

Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
p = list(map(int,input().split()))
ex=[]
 
ans=[]
 
for i in p:
    ex.append((1/2*i*(i+1))/i)
 
for i in range(N-K+1):
    ans.append(sum(ex[i:i+K]))
    
print(max(ans))
N,K = map(int,input().split())
p = list(map(int,input().split()))
ex=[]

ans=[]

for i in p:
    ex.append((1+i)/2)

for i in range(N-K+1):
    ans.append(sum(ex[i:i+K]))
    
print(max(ans))


Fixed submission:
# ruisekiwa by itertools

from itertools import accumulate

N,K = map(int,input().split())
p = list(map(int,input().split()))

b1=[0]+list(accumulate(p))

ans=[]

for i in range(N-K+1):
    ans.append(b1[K+i]-b1[i])
    
print((max(ans)+K)/2)

Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
p = list(map(int,input().split()))
ex=[]
 
ans=[]
 
for i in p:
    ex.append((1+i)/2)
 
for i in range(N-K+1):
    ans.append(sum(ex[i:i+K]))
    
print(max(ans))
N,K = map(int,input().split())
p = list(map(int,input().split()))
ex=[]

ans=[]

for i in p:
    ex.append(()

for i in range(N-K+1):
    ans.append(sum(ex[i:i+K]))
    
print(max(ans))




Fixed submission:
# ruisekiwa by itertools

from itertools import accumulate

N,K = map(int,input().split())
p = list(map(int,input().split()))

b1=[0]+list(accumulate(p))

ans=[]

for i in range(N-K+1):
    ans.append(b1[K+i]-b1[i])
    
print((max(ans)+K)/2)

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

max_v=0

for i in range(N-K+1):
    if max_v < sum(p[i:i+K]):
        max_v = sum(p[i:i+K])
        max_i = i
    
ans = 0

for i in range(max_i,max_i+K):
    ans += (1/2*p[i]*(p[i]+1))/p[i]

print(ans)



Fixed submission:
# ruisekiwa by itertools

from itertools import accumulate

N,K = map(int,input().split())
p = list(map(int,input().split()))

b1=[0]+list(accumulate(p))

ans=[]

for i in range(N-K+1):
    ans.append(b1[K+i]-b1[i])
    
print((max(ans)+K)/2)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
p = list(map(int,input().split()))
ex=[]

ans=[]

for i in p:
    ex.append((1/2*i*(i+1))/i)

for i in range(N-K+1):
    ans.append(sum(ex[i:i+K]))
    
print(max(ans))


Fixed submission:
# ruisekiwa by itertools

from itertools import accumulate

N,K = map(int,input().split())
p = list(map(int,input().split()))

b1=[0]+list(accumulate(p))

ans=[]

for i in range(N-K+1):
    ans.append(b1[K+i]-b1[i])
    
print((max(ans)+K)/2)