Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int, input().split())
ch, cw = map(lambda x: int(x)-1, input().split())
dh, dw = map(lambda x: int(x)-1, input().split())
s = [input() for _ in range(H)]

E = [[[] for _ in range(W)] for _ in range(H)]
for h in range(H):
    for w in range(W):
        for i, j in [(0,1), (0,-1), (1,0), (-1,0)]:
            if (h+i<0 or w+j<0) or (h+i>=H or w+j>=W):
                continue
            if s[h+i][w+j] == '#':
                continue
            E[h][w].append((0, (h+i, w+j)))

        for i in range(-2, 3):
            for j in range(-2, 3):
                if i == 0 and j == 0:
                    continue
                if (h+i<0 or w+j<0) or (h+i>=H or w+j>=W):
                    continue
                if s[h+i][w+j] == '#':
                    continue
                E[h][w].append((1, (h+i, w+j)))


def dijkstra(h, w):
    import heapq
    hq = [(0, h, w)]
    heapq.heapify(hq)
    cost = [[float('inf')] * W for _ in range(H)]
    cost[h][w] = 0

    while hq:
        c, vh, vw = heapq.heappop(hq)
        if c > cost[vh][vw]:
            continue
        for d, (uh, uw) in E[vh][vw]:
            tmp = d + cost[vh][vw]
            if tmp >= cost[uh][uw]:
                continue
            cost[uh][uw] = tmp
            heapq.heappush(hq, (cost[uh][uw], uh, uw))
    return cost


dist = dijkstra(ch, cw)
ans = dist[dh][dw]
if ans == float('inf'):
    print(-1)
else:
    print(ans)

Fixed submission:
from collections import deque

H, W = map(int, input().split())
ch, cw = map(lambda x: int(x)-1, input().split())
dh, dw = map(lambda x: int(x)-1, input().split())
s = [input() for _ in range(H)]

INF = 10**9
m = [[INF]*W for _ in range(H)]
m[ch][cw] = 0

q = deque()
q.append((ch, cw, 0))

cnt = 0
while q:
    cnt += 1
    h, w, n = q.popleft()
    for i, j in [(0,1), (0,-1), (1,0), (-1,0)]:
        if (h+i<0 or w+j<0) or (h+i>=H or w+j>=W):
            continue
        if m[h+i][w+j] <= n:
            continue
        if s[h+i][w+j] == '#':
            continue
        m[h+i][w+j] = n
        q.appendleft((h+i, w+j, n))

    for i in range(-2, 3):
        for j in range(-2, 3):
            if (h+i<0 or w+j<0) or (h+i>=H or w+j>=W):
                continue
            if m[h+i][w+j] <= n+1:
                continue
            if s[h+i][w+j] == '#':
                continue
            m[h+i][w+j] = n + 1
            q.append((h+i, w+j, n+1))
if m[dh][dw] == INF:
    print(-1)
else:
    print(m[dh][dw])
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))

ng = 0
ok = max(a)

while ok - ng > 1:
    cnt = 0
    l = (ok + ng) // 2
    for a in A:
        cnt += (a // l) + (a % l != 0) - 1

    if cnt <= k:
        ok = l
    else:
        ng = l
print(ok)

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

ng = 0
ok = max(A)

while ok - ng > 1:
    cnt = 0
    l = (ok + ng) // 2
    for a in A:
        cnt += (a // l) + (a % l != 0) - 1

    if cnt <= K:
        ok = l
    else:
        ng = l
print(ok)

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

N, K = map(int, input().split())
A = list(map(int, input().split()))
max_a = max(A)

for i in range(1, max_a):
    cnt = 0
    for a in A:
        cnt += math.ceil(a/i) - 1
    
    if cnt <= K:
        print(i)
        exit()
print(max_a)

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

ng = 0
ok = max(A)

while ok - ng > 1:
    cnt = 0
    l = (ok + ng) // 2
    for a in A:
        cnt += (a // l) + (a % l != 0) - 1

    if cnt <= K:
        ok = l
    else:
        ng = l
print(ok)

Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
import heapq

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

log_dict = defaultdict(int)
log_list = []
for i in a:
    log[i] += 1
    if -i not in log_list:
        log_list.append(-i)
        
heapq.heapify(log_list)


while True:
    l = heapq.heappop(log_list)
    if K > log_dict[l]:
        K -= log_dict[l]
        log_dict[l//2] += log_dict[l] * 2
        log_dict[l] = 0
        if l//2 not in log_list:
            heapq.heappush(log_list, l//2)

    else:
        print(int(log_dict/(K+1)))
        exit()
    


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

ng = 0
ok = max(A)

while ok - ng > 1:
    cnt = 0
    l = (ok + ng) // 2
    for a in A:
        cnt += (a // l) + (a % l != 0) - 1

    if cnt <= K:
        ok = l
    else:
        ng = l
print(ok)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
cnt = [0] * (N+1)

for i in range(1, N+1):
    cnt[i::i] = [j+(i*n) for n, j in enumerate(cnt[i::i],1)]

print(sum(cnt))

Fixed submission:
def calc(i):
    cnt = n // i
    return (i + i*cnt) * cnt // 2

n = int(input())

ans = 0
for i in range(1, n+1):
    ans += calc(i)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
cnt = [0] * (N+1)

for i in range(1, N+1):
    cnt[i::i] = [j+1 for j in cnt[i::i]]

ans = 0
for i, j in enumerate(cnt):
    ans += i*j
print(ans)

Fixed submission:
def calc(i):
    cnt = n // i
    return (i + i*cnt) * cnt // 2

n = int(input())

ans = 0
for i in range(1, n+1):
    ans += calc(i)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
MOD = (10**9) + 7

a = 10 ** 7 + 10 ** 6
fact = [0] * a
fact[0] = 1
for i in range(1, a):
    fact[i] = fact[i-1] * i % MOD

inv_fact = [0] * a
inv_fact[a-1] = pow(fact[a-1], MOD-2, MOD)
for i in range(a-1, 0, -1):
    inv_fact[i-1] = inv_fact[i] * i % MOD


def nCk(n, k):
    return (fact[n] * inv_fact[k] * inv_fact[n-k]) % MOD


def nPk(n, k):
    return (fact[n] * inv_fact[n-k]) % MOD


ans = 0
for i in range(N+1):
    tmp = nCk(N, i) * nPk(M, i) * (nPk(M-i, N-i))**2 % MOD
    if i % 2 == 0:
        ans += tmp
    else:
        ans -= tmp
print(ans%MOD)

Fixed submission:
N, M = map(int, input().split())
MOD = (10**9) + 7

a = 10 ** 7 + 10 ** 6
fact = [0] * a
fact[0] = 1
for i in range(1, a):
    fact[i] = fact[i-1] * i % MOD

inv_fact = [0] * a
inv_fact[a-1] = pow(fact[a-1], MOD-2, MOD)
for i in range(a-1, 0, -1):
    inv_fact[i-1] = inv_fact[i] * i % MOD


def nCk(n, k):
    return (fact[n] * inv_fact[k] * inv_fact[n-k]) % MOD


def nPk(n, k):
    return (fact[n] * inv_fact[n-k]) % MOD


ans = 0
for i in range(N+1):
    tmp = nCk(N, i) * nPk(M, i) * (nPk(M-i, N-i))**2 % MOD
    if i % 2 == 0:
        ans += tmp
    else:
        ans -= tmp
print(ans%MOD)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))
s = 0

for x in a:
    s = s ^ x

ans = ''
for x in a:
    ans = ans + str(s ^ x) + ' '
print(ans)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
s = 0

for x in a:
    s ^= x

ans = ''
for x in a:
    ans += str(s ^ x) + ' '
print(ans)

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

for x in a:
    s = s ^ x

ans = ''
for x in a:
    ans = ans + str(s ^ x) + ' '
print(ans)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
s = 0

for x in a:
    s ^= x

ans = ''
for x in a:
    ans += str(s ^ x) + ' '
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np

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

if N == 0:
  print(X)
  exit()
  
p_list = list(map(int, input().split()))

num_list = list(set([*range(1,101)]) - set(p_list))

diff = np.abs(np.array(num_list)-X)
diff_arg_min = np.argmin(diff)

print(num_list[diff_arg_min])

Fixed submission:
import numpy as np

X, N = list(map(int, input().split()))
p_list = set(sorted(list(map(int, input().split()))))

if N == 0:
  print(X)
  exit()
  
i = sorted(list(set(range(X-N, X+1)) - p_list))[-1]
j = sorted(list(set(range(X, X+N+1)) - p_list))[0]

if X-i <= j-X:
  print(i)
else:
  print(j)

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

X, N = list(map(int, input().split()))
p_list = list(map(int, input().split()))

num_list = list(set([*range(1,101)]) - set(p_list))

diff = np.abs(np.array(num_list)-X)
diff_arg_min = np.argmin(diff)

print(num_list[diff_arg_min])

Fixed submission:
import numpy as np

X, N = list(map(int, input().split()))
p_list = set(sorted(list(map(int, input().split()))))

if N == 0:
  print(X)
  exit()
  
i = sorted(list(set(range(X-N, X+1)) - p_list))[-1]
j = sorted(list(set(range(X, X+N+1)) - p_list))[0]

if X-i <= j-X:
  print(i)
else:
  print(j)
Buggy python submission (verdict: Time Limit Exceeded):
import math

N = int(input())
x_list = list(map(int, input().split()))
 
result = math.prod(x_list)
if result >1e18:
  print(-1)
else:
  print(result)



Fixed submission:
import math
 
N = int(input())
x_list = list(map(int, input().split()))
 
result = 1
if 0 in x_list:
  print(0)
  exit()
for x in x_list:
  result *= x
  if result > 1e18:
    print(-1)
    exit()
print(result)

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

result = 1
for x in x_list:
  result *= x
if result >1e18:
  print(-1)
else:
  print(result)

Fixed submission:
import math
 
N = int(input())
x_list = list(map(int, input().split()))
 
result = 1
if 0 in x_list:
  print(0)
  exit()
for x in x_list:
  result *= x
  if result > 1e18:
    print(-1)
    exit()
print(result)
Buggy python submission (verdict: Runtime Error):
x0, x1 = list(map(flaot, input().split()))
print(int(x0*x1))

Fixed submission:
from decimal import Decimal as dec

x0, x1 = list(map(dec, input().split()))
print(int(x0*x1))
Buggy python submission (verdict: Runtime Error):
from decimal import Decimal

N = Decimal(input())
t = N // 2
a_list = []
b_list = []
for i in range(N):
    ab = list(map(int, input().split()))
    a_list.append(ab[0])
    b_list.append(ab[1])

if N%2 == 1:
    a_median = a_list[t]
    b_median = b_list[t]
    print(b_median-a_median+1)
elif N%2 == 0:
    a_median = (a_list[t-1]+a_list[t])/2
    b_median = (b_list[t-1]+b_list[t])/2
    print(int(2*(b_median-a_median)+1))

Fixed submission:
N = int(input())
t = N // 2
a_list = []
b_list = []
for i in range(N):
    ab = list(map(int, input().split()))
    a_list.append(ab[0])
    b_list.append(ab[1])

a_list = sorted(a_list)
b_list = sorted(b_list)

if N%2 == 1:
    a_median = a_list[t]
    b_median = b_list[t]
    print(b_median-a_median+1)
elif N%2 == 0:
    a_median = (a_list[t-1]+a_list[t])/2
    b_median = (b_list[t-1]+b_list[t])/2
    print(int(2*(b_median-a_median)+1))

Buggy python submission (verdict: Runtime Error):
N = int(input())
t = N // 2
a_list = []
b_list = []
for i in range(N):
    ab = list(map(int, input().split()))
    a_list.append(ab[0])
    b_list.append(ab[1])

if N%2 == 1:
    a_med = a_list[t]
    b_median = b_list[t]
    print(b_list-a_list+1)
elif N%2 == 0:
    a_median = (a_list[t-1]+a_list[t])/2
    b_median = (b_list[t-1]+b_list[t])/2
    print(int(2*(b_median-a_median)+1))

Fixed submission:
N = int(input())
t = N // 2
a_list = []
b_list = []
for i in range(N):
    ab = list(map(int, input().split()))
    a_list.append(ab[0])
    b_list.append(ab[1])

a_list = sorted(a_list)
b_list = sorted(b_list)

if N%2 == 1:
    a_median = a_list[t]
    b_median = b_list[t]
    print(b_median-a_median+1)
elif N%2 == 0:
    a_median = (a_list[t-1]+a_list[t])/2
    b_median = (b_list[t-1]+b_list[t])/2
    print(int(2*(b_median-a_median)+1))

Buggy python submission (verdict: Runtime Error):
N = int(input
med = N // 2
a_list = []
b_list = []
for i in range(N):
    ab = list(map(int, input().split()))
    a_list.append(ab[0])
    b_list.append(ab[1])

if N%2 == 1:
    a_med = a_list[t]
    b_median = b_list[t]
    print(b_list-a_list+1)
elif N%2 == 0:
    a_median = (a_list[t-1]+a_list[t])/2
    b_median = (b_list[t-1]+b_list[t])/2
    print(int(2*(b_median-a_median)+1))


Fixed submission:
N = int(input())
t = N // 2
a_list = []
b_list = []
for i in range(N):
    ab = list(map(int, input().split()))
    a_list.append(ab[0])
    b_list.append(ab[1])

a_list = sorted(a_list)
b_list = sorted(b_list)

if N%2 == 1:
    a_median = a_list[t]
    b_median = b_list[t]
    print(b_median-a_median+1)
elif N%2 == 0:
    a_median = (a_list[t-1]+a_list[t])/2
    b_median = (b_list[t-1]+b_list[t])/2
    print(int(2*(b_median-a_median)+1))
Buggy python submission (verdict: Runtime Error):
N, M = list(map(int, input().split()))
paths = [list(map(int, input().split())) for _ in range(M)]

result = []
passed_room = [1]
depth = 1

while paths and depth<N:
  tmp_passed = passed_room.copy()
  
  for i, path in enumerate(paths):
   
    if path[0] in passed_room:
      if path[1] in passed_room:
        del paths[i]
        continue
      result.append((path[1], path[0]))
      tmp_passed.append(path[1])
      del paths[i]
      continue
    
    if path[1] in passed_room:
      if path[0] in passed_room:
        del paths[i]
      result.append((path[0], path[1]))
      tmp_passed.append(path[0])
      del paths[i]
      continue
  depth += 1
  passed_room  = passed_room + tmp_passed
  if len(tmp_passed) == 0:
    print('No')
    exit()
  
    
result = sorted(result)
print('Yes')
for i, j in result:
  print(j)

Fixed submission:
last_num = input()[-1]

if last_num in ['2', '4', '5', '7', '9']:
  print('hon')
elif last_num in ['0', '1', '6', '8']:
  print('pon')
elif last_num in ['3']:
  print('bon')
Buggy python submission (verdict: Runtime Error):
s, w = input()
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):
from itertools import combinations_with_replacement


def euclidean(num_list: list):
    a, b = sorted(num_list)
    while b % a != 0:
        redi = b % a
        b = a
        a = redi
    return a


K = int(input())
k_range = list(range(1, K+1))

result = 0
for comb in combinations_with_replacement(k_range, 3):
    min_abc = min(comb)
    gcd = euclidean(comb[0:2])
    gcd = euclidean([gcd, comb[2]])
    if comb[0]==comb[1] and comb[1]==comb[2]:
        coef = 1
    elif (comb[0]!=comb[1] and comb[1]!=comb[2]) and comb[2]!=comb[0]:
        coef = 6
    else:
        coef = 3
    result += i * coef
print(result)

Fixed submission:
from itertools import combinations_with_replacement

K = int(input())
k_range = list(range(1, K+1))

result = 0
for comb in combinations_with_replacement(k_range, 3):
    min_abc = min(comb)
    for i in range(min_abc, 0, -1):
        if (comb[0]%i == 0 and comb[1]%i == 0) and comb[2]%i == 0:
            if comb[0]==comb[1] and comb[1]==comb[2]:
                coef = 1
            elif (comb[0]!=comb[1] and comb[1]!=comb[2]) and comb[2]!=comb[0]:
                coef = 6
            else:
                coef = 3
            result += i * coef
            break
print(result)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations_with_replacement

K = int(input())
k_range = list(range(1, K+1))

result = 0
for comb in combinations_with_replacement(k_range, 3):
    min_abc = min(comb)
    for i in range(min_abc, 0, -1):
        if (comb[0]%i == 0 and comb[1]%i == 0) and comb[2]%i == 0:
            if comb[0]==comb[1] and comb[1]==comb[2]:
                coef = 1
            elif (comb[0]!=comb[1] and comb[1]!=comb[2]) and comb[2]!=comb[0]:
                coef = 6
            else:
                coef = 3
            result += i * coef
            break
print(result)

Fixed submission:
from itertools import combinations_with_replacement

K = int(input())
k_range = list(range(1, K+1))

result = 0
for comb in combinations_with_replacement(k_range, 3):
    min_abc = min(comb)
    for i in range(min_abc, 0, -1):
        if (comb[0]%i == 0 and comb[1]%i == 0) and comb[2]%i == 0:
            if comb[0]==comb[1] and comb[1]==comb[2]:
                coef = 1
            elif (comb[0]!=comb[1] and comb[1]!=comb[2]) and comb[2]!=comb[0]:
                coef = 6
            else:
                coef = 3
            result += i * coef
            break
print(result)
Buggy python submission (verdict: Runtime Error):
x, y, z = list(map(int, input()))
x, y = y, x
x, z = z, x
print(x, y, z)

Fixed submission:
x, y, z = list(map(int, input().split()))
x, y = y, x
x, z = z, x
print(x, y, z)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = list(map(int, input().split()))

sum_a = sum(a)
a = a.sort()
cnt = 0
for i in a:
    if i >= 1 / (4*sum_a):
        cnt += 1
if cnt >= M:
    print('Yes')
else:
    print('No')

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

sum_a = sum(a)
a = sorted(a)

cnt = 0
for i in a:
    if i >= sum_a / (4*m):
        cnt += 1
if cnt >= m:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())

for i in range(Q):
    q = input()
    if q == '1':
        S = S[::-1]
    else:
        _, f, c = q.split()
        if f == '1':
            S = c + S
        else:
            S = S + c
print(S)

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

prefix = ''
surfix = ''
cnt_reverse = 0

for i in range(Q):
    q = input()
    if q == '1':
        cnt_reverse += 1
    else:
        _, f, c = q.split()
        if (f=='1' and cnt_reverse%2==0):
            prefix = c + prefix
        elif (f=='2' and cnt_reverse%2==1):
            prefix = c + prefix
        elif (f=='1' and cnt_reverse%2==0):
            surfix = surfix + c
        else:
            surfix = surfix + c
if cnt_reverse % 2 == 0:
    S = prefix + S + surfix
else:
    S = surfix[::-1] + S[::-1] + prefix[::-1]
print(S)
Buggy python submission (verdict: Runtime Error):
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b_list = [int(input()) for _ in range(n)]

card = [[0] * 3 for _ in range(3)]
for i in range(3):
    for j in range(3):
        if a[i][j] == b_list:
            card[i][j] = 1

for i in range(3):
    if card[i][:] == [1,1,1] or card[:][i] == [1,1,1]:
        print('Yes')
        exit()
if sum([card[0][0], card[1][1], card[2][2]]) == 3 or sum([card[0][2], card[1][1], card[2][0]) == 3:
    print('Yes')
    exit()
print('No')

Fixed submission:
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b_list = [int(input()) for _ in range(n)]

card = [[0] * 3 for _ in range(3)]
for i in range(3):
    for j in range(3):
        if a[i][j] in b_list:
            card[i][j] = 1

for i in range(3):
    if sum(card[i]) == 3 or sum([card[0][i], card[1][i], card[2][i]]) == 3:
        print('Yes')
        exit()
if sum([card[0][0], card[1][1], card[2][2]]) == 3 or sum([card[0][2], card[1][1], card[2][0]]) == 3:
    print('Yes')
    exit()
print('No')
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(m)]

for i in range(10**(n-1), 10**n):
    for j, (s, c) in enumerate(sc, 1):
        if not str(i)[s-1] == str(c):
            break
        if j == m:
            print(i)
            exit()
print(-1n, m = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(m)]

if n == 1:
    num_list = list(range(10))
else:
    num_list = list(range(10**(n-1), 10**n))
        
for i in num_list:
    for j, (s, c) in enumerate(sc, 1):
        if not str(i)[s-1] == str(c):
            break
        if j == m:
            print(i)
            exit()
print(-1)

Fixed submission:
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(m)]

if n == 1:
    num_list = list(range(10))
else:
    num_list = list(range(10**(n-1), 10**n))
        
for i in num_list:
    flg = True
    for s, c in sc:
        if str(i)[s-1] != str(c):
            flg = False
            break
    if flg:
        print(i)
        exit()
print(-1)
Buggy python submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
MOD = 10**9 + 7

fact = [0] * (n+1)
inv_fact = [0] * (n+1)

fact[0] = 1
for i in range(1, n+1):
    fact[i] = fact[i-1] * i % MOD

inv_fact[n] = pow(fact[n], MOD-2, MOD)
for i in range(n, 0, -1):
    inv_fact[i-1] = inv_fact[i] * i % MOD


def nCk(n, k):
    return (fact[n] * inv_fact[k] * inv_fact[n-k]) % MOD


ans = 0
for k in range(1, n+1):
    if k == a or k == b:
        continue
    ans += nCk(n, k) % MOD
    
print(ans % MOD)

Fixed submission:
n, a, b = map(int, input().split())
MOD = 10**9 + 7

u = [1]
d = [1]
c = [1]
for i in range(1, b+1):
    u.append(u[-1] * (n-i+1) % MOD)
    d.append(d[-1] * i % MOD)
    # c.append(u[-1] // d[-1] % MOD)
    c.append(u[-1] * pow(d[-1], MOD-2, MOD) % MOD)

print((pow(2, n, MOD) - c[a] - c[b] - 1) % MOD)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
p = list(map(int, input().split()))

max_e = 0
for i in range(N-K+1):
    max_e = max(max_e, (sum(p[i:i+K])+K)/2)
print(max_e)

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

e = (sum(p[0:K])+K) / 2
max_e = e
for i in range(1, N-K+1):
    e += -(p[i-1]+1)/2 + (p[i+K-1]+1)/2
    max_e = max(max_e, e)
    
print(max_e)
Buggy python submission (verdict: Runtime Error):
cnt = 0
i = 0
while H > 0:
    H //= 2
    cnt += 2 ** i
    i += 1
print(cnt)

Fixed submission:
H = int(input())

cnt = 0
i = 0
while H > 0:
    H //= 2
    cnt += 2 ** i
    i += 1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
H, N = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]

INF = 10 ** 9
dp = [INF] * (H+1)
dp[0] = 0
for i in range(H):
    for j in range(N):
        idx = min(H, i+ab[j][0])
        dp[idx] = min(dp[idx], dp[i]+ab[j][1])
print(dp[-1])

Fixed submission:
H, N = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]

INF = 10 ** 9
dp = [INF] * (H+1)
dp[0] = 0
for i in range(H):
    for j in range(N):
        idx = min(H, i+ab[j][0])
        dp[idx] = min(dp[idx], dp[i]+ab[j][1])
print(dp[-1])
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
ps = [input().split() for _ in range(M)]

correct = [0] * N
penalty = [0] * N
for p, s in ps:
    p = int(p)
    if correct[p-1] == 1:
        continue
    if s == 'AC':
        correct[p-1] = 1
    else:
        penalty[p-1] += 1
print(sum(correct), sum([p*c for p, c in zip(penalty, correct)]))))



Fixed submission:
N, M = map(int, input().split())
ps = [input().split() for _ in range(M)]

correct = [0] * N
penalty = [0] * N
for p, s in ps:
    p = int(p)
    if correct[p-1] == 1:
        continue
    if s == 'AC':
        correct[p-1] = 1
    else:
        penalty[p-1] += 1
print(sum(correct), sum([p*c for p, c in zip(penalty, correct)]))