Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

R, G, B, N = map(int, input().split())

r = N // R
g = N // G
b = N // B

c = 0
for i in range(r + 1):
    for j in range(g + 1):
        t = N - i * R - j * G
        if t == 0:
            c += 1
            continue
            
        if t < 0:
            continue
            
        if t % B == 0:
            c += 1
                
print(c)

Fixed submission:
import sys
input = sys.stdin.readline

R, G, B, N = map(int, input().split())

r = N // R

c = 0
for i in range(r + 1):
    p = N - i * R
    for j in range(int(p // G) + 1):
        t = p - j * G
        if t == 0:
            c += 1
            break
            
        if t % B == 0:
            c += 1
                
print(c)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

s = list(input())
l = {}

for v in s:
    if l.get(v):
        l[v] += 1
    else:
        l[v] = 1
        
print(min(l["0"], l["1"]) * 2)

Fixed submission:
import sys
input = sys.stdin.readline

s = list(input())
l = {
    "0": 0,
    "1": 0,
}

for v in s:
    if l.get(v):
        l[v] += 1
    else:
        l[v] = 1
        
print(min(l["0"], l["1"]) * 2)

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

s = list(input().replace("¥n", ""))
l = {
    "0": 0,
    "1": 0
}

for v in s:
    l[v] += 1
        
print(min(l["0"], l["1"]) * 2)

Fixed submission:
import sys
input = sys.stdin.readline

s = list(input())
l = {
    "0": 0,
    "1": 0,
}

for v in s:
    if l.get(v):
        l[v] += 1
    else:
        l[v] = 1
        
print(min(l["0"], l["1"]) * 2)
Buggy python submission (verdict: Runtime Error):
import sys
from collections import defaultdict
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, M, = map(int, input().split())
S = list(input().strip())
T = list(input().strip())

def gcd(x, y):
    if y > x:
        x, y = y, x
    if x % y == 0:
        return y
    return gcd(y, x % y)

l = N * M // gcd(N, M)

m = [None] * l

for i in range(N):
    m[i * (l // N)] = S[i]

for i in range(M):
    index = i * (l // M)
    if m[index] == None:
        m[index] = T[i]
    elif m[index] == T[i]:
        pass
    else:
        print(-1)
        exit()

print(l)

Fixed submission:
import sys
from collections import defaultdict
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, M, = map(int, input().split())
S = list(input().strip())
T = list(input().strip())

def gcd(x, y):
    if y > x:
        x, y = y, x
    if x % y == 0:
        return y
    return gcd(y, x % y)

l = N * M // gcd(N, M)

# m = [None] * l
m = {}

for i in range(N):
    m[i * (l // N)] = S[i]

for i in range(M):
    index = i * (l // M)
    if m.get(index) == None:
        m[index] = T[i]
    elif m[index] == T[i]:
        pass
    else:
        print(-1)
        exit()

print(l)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import defaultdict, deque
import bisect
from heapq import *
from math import factorial, ceil, floor
sys.setrecursionlimit(200000)
input = sys.stdin.readline

# N, M, = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

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

m = set()
p = 0
for a in range(1, N + 1): # 10 3
    for b in range(K - (a % K), N + 1, K):
        for c in range(K - (b % K), N + 1, K):
            p += 1
            if (c + a) % K == 0:
                m.add((a, b, c))

print(len(m))
# very slow

Fixed submission:
import sys
from collections import defaultdict, deque
import bisect
from heapq import *
from math import factorial, ceil, floor
sys.setrecursionlimit(200000)
input = sys.stdin.readline

# N, M, = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

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

m = [0] * K
for v in range(1, N + 1):
    m[v % K] += 1

ans = 0
for v in range(1, K + 1):
    b = (K - v) % K
    c = (K - v) % K
    if (b + c) % K != 0:
        continue
    ans += m[v % K] * m[b] * m[c]
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
import math
input = sys.stdin.readline

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

for i in range(len(l)):
    l[i] = i - l[i] + 1

l.sort()
t = l[math.ceil(len(l) / 2)]

for i in range(len(l)):
    l[i] = abs(l[i] - t)
    
print(sum(l))

Fixed submission:
import sys
input = sys.stdin.readline

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

for i in range(len(l)):
    l[i] = i - l[i] + 1

l.sort()
t = l[int(len(l) / 2)]

for i in range(len(l)):
    l[i] = abs(l[i] - t)
    
print(sum(l))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

N = int(input())
L = [int(v) for v in input().split()]

f = True
c = 0
while f:
    f = False
    
    for i in range(N):
        if f == False and L[i] % 2 == 0:
            c += 1
            L[i] = L[i] // 2
            f = True
            break
            
print(c)

Fixed submission:
import sys
input = sys.stdin.readline

N = int(input())
L = [int(v) for v in input().split()]

c = 0
for v in L:
    if v % 2 == 0:
        while v % 2 == 0:
            v = v // 2
            c += 1
            
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, = map(int, input().split())
L = [int(v) for v in input().split()]
L.sort()

import math
m = {}
def f(n):
    if m.get(n) != None:
        return m[n]
    a = math.factorial(n)
    m[n] = a
    return a
def comb(n, r):
    return f(n) // f(r) // f(n - r)

ans = 0
t = 0
for i in range(N - 1):
    a = comb(L[-1], L[i])
    if ans < a:
        ans = a
        t = i

print(L[-1], L[t])

Fixed submission:
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, = map(int, input().split())
L = [int(v) for v in input().split()]
L.sort()

ans = 0
for i in range(N):
    if ans < min(L[i], L[-1] - L[i]):
        ans = L[i]

print(L[i], ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import defaultdict, deque
import bisect
from heapq import *
from math import factorial, ceil
sys.setrecursionlimit(200000)
input = sys.stdin.readline

# N, M, = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

L = [int(v) for v in input().split()]

for v in range(L[0], L[1] + 1):
    if v <= L[0] + L[2] - 1 or v >= L[1] - L[2] + 1:
        print(v)


Fixed submission:
import sys
from collections import defaultdict, deque
import bisect
from heapq import *
from math import factorial, ceil
sys.setrecursionlimit(200000)
input = sys.stdin.readline

# N, M, = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

L = [int(v) for v in input().split()]

if L[1] - L[0] <= L[2]:
    L[2] = L[1] - L[0]

    for v in range(L[0], L[1] + 1):
        print(v)
    exit()

s = set()
for v in range(L[0], L[0] + L[2]):
    s.add(v)
for v in range(L[1] - L[2] + 1, L[1] + 1):
    s.add(v)

for v in sorted(s):
    print(v)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

H, W, D = map(int, input().split())
L = [[int(v) - 1 for v in input().split()] for _ in range(H)]
Q = int(input())
QL = [[int(v) - 1 for v in input().split()] for _ in range(Q)]

m = [None] * (H * W)
for i in range(H):
    for j in range(W):
        m[L[i][j]] = (i, j)

dp = [None] * (H * W)
for i in range(D):
    dp[i] = 0
    for j in range(i + D, H * W, D):
        x, y = m[j - D]
        nx, ny = m[j]
        
        dp[j] = abs(x - nx) + abs(y - ny)

for qx, qy in QL:
    ans = 0
    for q in range(qx + D, qy + D, D):
        ans += dp[q]
    print(ans)


Fixed submission:
import sys
input = sys.stdin.readline

H, W, D = map(int, input().split())
L = [[int(v) - 1 for v in input().split()] for _ in range(H)]
Q = int(input())
QL = [[int(v) - 1 for v in input().split()] for _ in range(Q)]

m = [None] * (H * W)
for i in range(H):
    for j in range(W):
        m[L[i][j]] = (i, j)

dp = [None] * (H * W)
for i in range(D):
    dp[i] = 0
    for j in range(i + D, H * W, D):
        x, y = m[j - D]
        nx, ny = m[j]
        
        dp[j] = dp[j - D] + abs(x - nx) + abs(y - ny)

for qx, qy in QL:
    print(dp[qy] - dp[qx])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

H, W, D = map(int, input().split())
L = [[int(v) for v in input().split()] for _ in range(H)]
Q = int(input())
QL = [[int(v) for v in input().split()] for _ in range(Q)]

m = [None] * (H * W)
for i in range(H):
    for j in range(W):
        m[L[i][j] - 1] = (i, j)
        
for l, r in QL:
    ans = 0
    c = l - 1
    x, y = m[c]
    while c != r - 1:
        c += D
        nx, ny = m[c]
        
        ans += abs(x - nx) + abs(y - ny)
        x, y = nx, ny
        
    print(ans)

Fixed submission:
import sys
input = sys.stdin.readline

H, W, D = map(int, input().split())
L = [[int(v) - 1 for v in input().split()] for _ in range(H)]
Q = int(input())
QL = [[int(v) - 1 for v in input().split()] for _ in range(Q)]

m = [None] * (H * W)
for i in range(H):
    for j in range(W):
        m[L[i][j]] = (i, j)

dp = [None] * (H * W)
for i in range(D):
    dp[i] = 0
    for j in range(i + D, H * W, D):
        x, y = m[j - D]
        nx, ny = m[j]
        
        dp[j] = dp[j - D] + abs(x - nx) + abs(y - ny)

for qx, qy in QL:
    print(dp[qy] - dp[qx])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, M, = map(int, input().split())
L = [list(input().strip()) for _ in range(N)]

m = [[10 ** 18 for _ in range(M)] for _ in range(N)]

def bfs(x, y, c):
    if L[x][y] == "#":
        return

    if m[x][y] <= c:
        return

    m[x][y] = c

    if x + 1 < N:
        bfs(x + 1, y, c + 1)

    if y + 1 < M:
        bfs(x, y + 1, c + 1)

    if x - 1 >= 0:
        bfs(x - 1, y, c + 1)

    if y - 1 >= 0:
        bfs(x, y - 1, c + 1)

bfs(0, 0, 0)

if m[-1][-1] == 10 ** 18:
    print(-1)
    exit()

def dfs(x, y, c):
    if x == 0 and y == 0:
        L[x][y] = "o"
        return True
    for (_x, _y) in [(-1, 0), (0, -1), (1, 0), (0, 1)]:
        if x + _x < N and x + _x >= 0 and y + _y < M and y + _y >= 0:
            if c - 1 == m[x + _x][y + _y]:
                if dfs(x + _x, y + _y, c - 1):
                    L[x][y] = "o"
                    return True
    return False

dfs(N - 1, M - 1, m[-1][-1])

ans = 0
for i in range(N):
    for j in range(M):
        if L[i][j] == ".":
            ans += 1

print(ans)

Fixed submission:
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, M, = map(int, input().split())
L = [list(input().strip()) for _ in range(N)]

m = [[10 ** 18 for _ in range(M)] for _ in range(N)]

def bfs(x, y, c):
    if L[x][y] == "#":
        return

    if m[x][y] <= c:
        return

    m[x][y] = c

    if x + 1 < N:
        bfs(x + 1, y, c + 1)

    if y + 1 < M:
        bfs(x, y + 1, c + 1)

    if x - 1 >= 0:
        bfs(x - 1, y, c + 1)

    if y - 1 >= 0:
        bfs(x, y - 1, c + 1)

bfs(0, 0, 0)

if m[-1][-1] == 10 ** 18:
    print(-1)
    exit()

def dfs(x, y, c):
    if x == 0 and y == 0:
        L[x][y] = "o"
        return True
    for (_x, _y) in [(-1, 0), (0, -1), (1, 0), (0, 1)]:
        if x + _x < N and x + _x >= 0 and y + _y < M and y + _y >= 0:
            if c - 1 == m[x + _x][y + _y]:
                if dfs(x + _x, y + _y, c - 1):
                    L[x][y] = "o"
                    return True
    return False

dfs(N - 1, M - 1, m[-1][-1])

ans = 0
for v in L:
    ans += len([0 for c in v if c == "."])

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import defaultdict, deque
import bisect
from heapq import *
from math import factorial
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

L = [[int(v) for v in input().split()] for _ in range(N - 1)]
Q, K = map(int, input().split())
QL = [[int(v) for v in input().split()] for _ in range(Q)]

m = {}
for a, b, c in L:
    if m.get(a) == None:
        m[a] = {}
    if m.get(b) == None:
        m[b] = {}

    m[a][b] = c
    m[b][a] = c

def dfs(now, a, l, al):
    ans = 10 ** 18
    if now == a:
        return l
    for k, v in m[now].items():
        if k in al:
            continue
        re = dfs(k, a, l + v, al + [k])
        ans = min(ans, re)
    return ans

for i in range(N):
    a = dfs(K, i + 1, 0, [])
    m[K][i + 1] = a

for x, y in QL:
    print(m[K][x] + m[K][y])

Fixed submission:
import sys
from collections import defaultdict
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, = map(int, input().split())
L = [[int(v) for v in input().split()] for _ in range(N - 1)]
Q, K = map(int, input().split())
QL = [[int(v) - 1 for v in input().split()] for _ in range(Q)]

m = [set() for _ in range(N)]
c = {}
for x, y, z in L:
    m[x - 1].add(y - 1)
    m[y - 1].add(x - 1)

    if c.get(x - 1) == None:
        c[x - 1] = {}

    if c.get(y - 1) == None:
        c[y - 1] = {}

    c[x - 1][y - 1] = z
    c[y - 1][x - 1] = z

s = [None] * N
s[K - 1] = 0

def f(index, b):
    for v in m[index]:
        if s[v] == None:
            s[v] = b + c[index][v]
            f(v, s[v])
        else:
            if s[v] > b + c[index][v]:
                s[v] = b + c[index][v]
                f(v, s[v])

f(K - 1, 0)

for x, y in QL:
    print(s[x] + s[y])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

N, A, B, = map(int, input().split())
L = [int(input()) for _ in range(N)]

L.sort()

ans = (L[-1] // B) + 1

def f(n):
    c = n
    for v in L:
        if v > n * B:
            v -= n * B
            t = v // (A - B)
            if v % (A - B) != 0:
                t += 1
            c -= t
    return c >= 0

first = 1
for _ in range(50):
    t = (first + ans) // 2
    if f(t):
        ans = t
    else:
        first = t

print(ans)

Fixed submission:
import sys
input = sys.stdin.readline

N, A, B, = map(int, input().split())
L = [int(input()) for _ in range(N)]

L.sort()

ans = (L[-1] // B) + 1

def f(n):
    c = n
    for v in L:
        if v > n * B:
            v -= n * B
            t = v // (A - B)
            if v % (A - B) != 0:
                t += 1
            c -= t
    return c >= 0

first = 1
for _ in range(40):
    t = (first + ans) // 2
    if f(t):
        ans = t
    else:
        first = t

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n, k = map(int, input().split())
m = {}
ml = list()

for i in range(n):
    a, b = map(int, input().split())
    if a not in ml:
        ml.append(a)
        
    if m.get(a):
        m[a] += b
    else:
        m[a] = b

ml.sort()
for v in ml:
    if k > m[v]:
        k -= m[v]
    else:
        print(v)
        break

Fixed submission:
import sys
input = sys.stdin.readline

n, k = map(int, input().split())
m = {}
ml = set()

for i in range(n):
    a, b = map(int, input().split())
    ml.add(a)
        
    if m.get(a):
        m[a] += b
    else:
        m[a] = b

mm = list(ml)
mm.sort()
for v in mm:
    if k > m[v]:
        k -= m[v]
    else:
        print(v)
        break
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

N = int(input())
L = [list(map(int, input().split())) for _ in range(N)]

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

l, r = 1, 1

for x, y in L:
    c = 1
    while True:
        xx = x * c
        yy = y * c
            
        if l <= xx and r <= yy:
            l, r = xx, yy
            break
        else:
            c += 1

print(l + r)

Fixed submission:
import sys
input = sys.stdin.readline

N = int(input())
L = [list(map(int, input().split())) for _ in range(N)]

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

l, r = 1, 1

for x, y in L:
    c = max(l // x, r // y)
    while True:
        xx = x * c
        yy = y * c
            
        if l <= xx and r <= yy:
            l, r = xx, yy
            break
        else:
            c += 1

print(l + r)
Buggy python submission (verdict: Runtime Error):
import sys
from collections import defaultdict
sys.setrecursionlimit(200000)
input = sys.stdin.readline

# N, = map(int, input().split())
S = [ord("z") - ord(v) + 1 for v in input().strip()]
N, = map(int, input().split())

for i in range(len(S)):
    if S[i] <= N:
        N -= S[i]
        S[i] = 26

S[-1] -= N

print("".join([chr(ord("z") - v + 1) for v in S]))

Fixed submission:
import sys
from collections import defaultdict
sys.setrecursionlimit(200000)
input = sys.stdin.readline

# N, = map(int, input().split())
S = [ord(v) - ord("a") for v in input().strip()]
N, = map(int, input().split())

for i in range(len(S)):
    c = 26 - S[i]
    if S[i] == 0:
        continue
    if c <= N:
        N -= c
        S[i] = 0

S[-1] += N % 26

print("".join([chr(ord("a") + v) for v in S]))
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
L = [int(v) for v in input().split()]
no = [v for v in range(10) if v not in L]

s = list(map(int, str(N)))

for i in range(len(s)):
    if i == 0:
        if s[i] in L:
            s[i] = min([v for v in no if v != 0 and v > s[i]])
    else:
        if s[i] in L:
            s[i] = min([v for v in no if v > s[i]])
            
print("".join(map(str, s)))

Fixed submission:
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
L = [v for v in input().split()]

for n in range(N, 200000):
    s = list(str(n))
    
    f = False
    for c in s:
        if c in L:
            f = True
    if f:
        continue
            
    print("".join(s))
    exit()
Buggy python submission (verdict: Runtime Error):
n=int(input())
A=[int(i) for i in input().split()]
prod=1
for i in range(0,N):
  prod=prod*A[i]
  if(prod>1000000000000000000):
    prod=-1
    break
print(prod)

Fixed submission:
n=int(input())
A=[int(i) for i in input().split()]
A.sort()
prod=1
for i in range(0,n):
  prod=prod*A[i]
  #print(prod)
  if(prod==0):
      break
  if(prod>1000000000000000000):
    prod=-1
    break
print(prod)
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
h=[int(i) for i in input().split()]
dp=[0]
for i in range(1,N):
    dp.append(1000000000)
for i in range(0,N):
    li=[j+i for j in range(1,K+1)]
    #print(li)
    for j in li:
        if(j<N):
            dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]))
#print(dp)
print(dp[N-1])

Fixed submission:
N,K=map(int,input().split())
h=[int(i) for i in input().split()]
dp=[0]
for i in range(1,N):
    dp.append(1000000000)
for i in range(0,N):
    li=[j+i for j in range(1,K+1)]
    #print(li)
    for j in li:
        if(j<N):
            dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]))
#print(dp)
print(dp[N-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
h=[int(i) for i in input().split()]
dp=[0]
for i in range(1,N):
    dp.append(1000000000)
for i in range(0,N):
    for j in range(1,K+1):
        if(j+i<N):
            dp[j+i]=min(dp[j+i],dp[i]+abs(h[i]-h[j+i]))
#print(dp)
print(dp[N-1])

Fixed submission:
N,K=map(int,input().split())
h=[int(i) for i in input().split()]
dp=[0]
for i in range(1,N):
    dp.append(1000000000)
for i in range(0,N):
    li=[j+i for j in range(1,K+1)]
    #print(li)
    for j in li:
        if(j<N):
            dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]))
#print(dp)
print(dp[N-1])
Buggy python submission (verdict: Time Limit Exceeded):
from math import sqrt
from decimal import *

a, b, c = map(int, input().split())
getcontext().prec = 50000
if (Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt()): print('Yes')
else: print('No')


Fixed submission:
from math import sqrt
a, b, c = map(int, input().split())
l = (a ** 2) + (b ** 2) + (c ** 2)
r = 2 * (a * b + b * c + c * a)

if (c-a-b > 0 and l > r): print('Yes')
elif(sqrt(c) == sqrt(a) + sqrt(b)): print('No')
else: print('No')

Buggy python submission (verdict: Time Limit Exceeded):
from math import sqrt
from decimal import *

a, b, c = map(int, input().split())
getcontext().prec = 100000
if (Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt()): print('Yes')
else: print('No')


Fixed submission:
from math import sqrt
a, b, c = map(int, input().split())
l = (a ** 2) + (b ** 2) + (c ** 2)
r = 2 * (a * b + b * c + c * a)

if (c-a-b > 0 and l > r): print('Yes')
elif(sqrt(c) == sqrt(a) + sqrt(b)): print('No')
else: print('No')
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
p = list(map(int, input().split()))
fac = [0] * 3010
fac[0] = 1
if (N >= 1):
    for i in range(1, 1010): fac[i] = i + 1 + fac[i - 1]
# 期待値
#print(p, fac[:max(p)])
exp = [0] * 3010
for i in range(N):
    exp[i] = fac[p[i] - 1] / p[i]
# print(exp)

Ans = 0
ans = [0] * 3000
ans[0] = sum(exp[:K])
for i in range(1, N - K + 1):
    if(i + K == N + 1): break
    ans[i] = ans[i - 1] - exp[i - 1] + exp[i + K - 1]
    # print(ans[i])
    #print(exp[i: i + K])
print(max(ans))


Fixed submission:
N, K = map(int, input().split())
p = list(map(int, input().split()))
fac = [0] * 735477
fac[0] = 1
if (N >= 1):
    for i in range(1, 1010): fac[i] = i + 1 + fac[i - 1]
# 期待値
#print(p, fac[:max(p)])
exp = [0] * 735477
for i in range(N):
    exp[i] = fac[p[i] - 1] / p[i]
# print(exp)

Ans = 0
ans = [0] * 735477
ans[0] = sum(exp[:K])
for i in range(1, N - K + 1):
    if(i + K == N + 1): break
    ans[i] = ans[i - 1] - exp[i - 1] + exp[i + K - 1]
    # print(ans[i])
    #print(exp[i: i + K])
print(max(ans))

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
p = list(map(int, input().split()))
fac = [0] * 1010
fac[0] = 1
if (N >= 1):
    for i in range(1, 1010): fac[i] = i + 1 + fac[i - 1]
# 期待値
#print(p, fac[:max(p)])
exp = [0] * 1010
for i in range(N):
    exp[i] = fac[p[i] - 1] / p[i]
#print(exp)

Ans = 0
ans = [0] * N
ans[0] = sum(exp[:K])
for i in range(1, N - K + 1):
    if(i + K == N + 1): break
    ans[i] = ans[i - 1] - exp[i - 1] + exp[i + K - 1]
    #print(ans[i])
    #print(exp[i: i + K])
print(max(ans))


Fixed submission:
N, K = map(int, input().split())
p = list(map(int, input().split()))
fac = [0] * 735477
fac[0] = 1
if (N >= 1):
    for i in range(1, 1010): fac[i] = i + 1 + fac[i - 1]
# 期待値
#print(p, fac[:max(p)])
exp = [0] * 735477
for i in range(N):
    exp[i] = fac[p[i] - 1] / p[i]
# print(exp)

Ans = 0
ans = [0] * 735477
ans[0] = sum(exp[:K])
for i in range(1, N - K + 1):
    if(i + K == N + 1): break
    ans[i] = ans[i - 1] - exp[i - 1] + exp[i + K - 1]
    # print(ans[i])
    #print(exp[i: i + K])
print(max(ans))