Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import math
a, b, x = map(int, input().split())
n = a * b
x /= a
if x / n < 0.5:
    c = (2 * (n - x)) / b - a
    d = a - c
    atan = math.degrees(math.atan(d / b))
else:
    c = 2 * x / a - b
    d = b - c
    atan = math.degrees(math.atan(a / d))

print(90 - atan)

Fixed submission:
import math
a, b, x = map(int, input().split())
n = a * b
x /= a
if x / n < 0.5:
    d = 2 * x / b
    atan = math.degrees(math.atan(d / b))
    ans = 90 - atan
else:
    y = n - x
    d = 2 * y / a
    ans = math.degrees(math.atan(d / a))

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

n = int(input())
*l, = map(int, input().split())
l = sorted(l)
count = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        c = bisect.bisect_left(l[j+1:], l[i]+l[j])
        count += c
print(count)

Fixed submission:
import sys
import bisect

n = int(input())
*l, = map(int, input().split())
l.sort()
ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        c = bisect.bisect_left(l, l[i] + l[j], j+1)
        ans += c - j - 1

print(ans)

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

n = int(input())
*l, = map(int, input().split())
heapq.heapify(l)
c = 0
s = []
try:
    for i in range(n):
        while len(s) < 2:
            s.append(heapq.heappop(l))
        m = heapq.heappop(l)
        for j in range(len(s)):
            for k in range(j+1, len(s)):
                if m < s[j] + s[k]:
                    c += 1
        s.append(m)
except:
    print(c)
    sys.exit(0)
print(c)

Fixed submission:
import sys
import bisect

n = int(input())
*l, = map(int, input().split())
l.sort()
ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        c = bisect.bisect_left(l, l[i] + l[j], j+1)
        ans += c - j - 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
*l, = map(int, input().split())
c = 0
for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            s = sum([ l[i], l[j], l[k] ])
            m = max(l[i], l[j], l[k])
            if m < s-m:
                c += 1
print(c)

Fixed submission:
import sys
import bisect

n = int(input())
*l, = map(int, input().split())
l.sort()
ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        c = bisect.bisect_left(l, l[i] + l[j], j+1)
        ans += c - j - 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k, q = map(int, input().split())
l = [k] * n
for _ in range(q):
    a = int(input()) - 1
    for i in range(n):
        if i == a:
            continue
        l[i] -= 1

for j in l:
    if j > 0:
        print('Yes')
    else:
        print('No')

Fixed submission:
from collections import defaultdict
counter = defaultdict(int)
n, k, q = map(int, input().split())
for _ in range(q):
    a = int(input()) - 1
    counter[a] += 1

for i in range(n):
    if k - q + counter[i] > 0:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
*a, = sorted(map(int, input().split()), key=lambda x: -x)
for i in range(m):
    tmp = a.pop(0)
    tmp //= 2
    if not a:
        a.append(tmp)
    for j in range(min(len(a), m-i)):
        if tmp > a[j]:
            a.insert(j, tmp)
            break
    else:
        a.append(tmp)

print(sum(a))

Fixed submission:
import heapq, math

n, m = map(int, input().split())
*a, = map(lambda x: -int(x), input().split())
heapq.heapify(a)

for i in range(m):
    tmp = heapq.heappop(a)
    tmp = math.ceil(tmp / 2)
    heapq.heappush(a, tmp)

print(-sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
*a, = sorted(map(int, input().split()), key=lambda x: -x)
for i in range(m):
    tmp = a.pop(0)
    tmp /= 2
    if len(a) == 0:
        a.append(tmp)
    for j in range(min(len(a), m-i)):
        if tmp > a[j]:
            a.insert(j, tmp)
            break
    else:
        a.append(tmp)

print(sum(map(int, a)))

Fixed submission:
import heapq, math

n, m = map(int, input().split())
*a, = map(lambda x: -int(x), input().split())
heapq.heapify(a)

for i in range(m):
    tmp = heapq.heappop(a)
    tmp = math.ceil(tmp / 2)
    heapq.heappush(a, tmp)

print(-sum(a))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
d = []
for i in range(n):
    tmp = int(input())
    d.append(tmp)

for i in range(n):
    if i == 0:
        print(max(d[1:]))
    elif i == n - 1:
        print(max(d[:-1]))
    else:
        print(max(d[i+1:] + d[:i]))


Fixed submission:
n = int(input())
mv = 0
mi = 0
d = []
for i in range(n):
    tmp = int(input())
    if tmp > mv:
        mv = tmp
        mi = i
    else:
        d.append(tmp)

for i in range(n):
    if i == mi:
        print(max(d))
    else:
        print(mv)
Buggy python submission (verdict: Runtime Error):
from collections import deque
n, m = map(int, input().split())
a = set(int(input()) for _ in range(m))
M = 1000000007
dp = {}
dp[0] = 1
dp[1] = 1
for i in range(2, n+1):
    if i in a:
        dp[2] = 0
    else:
        dp[2] = dp[0] + dp[1]
    dp[0] = dp[1]
    dp[1] = dp[2]

print(dp[2] % M)

Fixed submission:
from collections import deque
n, m = map(int, input().split())
a = set(int(input()) for _ in range(m))
M = 1000000007
dp = {}
dp[0] = 1
for i in range(1, n+1):
    if i in a:
        dp[i] = 0
        continue
    if i - 2 < 0:
        dp[i] = dp[i-1]
    else:
        dp[i] = dp[i-1] + dp[i-2]

print(dp[n] % M)

Buggy python submission (verdict: Runtime Error):
from collections import deque
n, m = map(int, input().split())
a = set(int(input()) for _ in range(m))
M = 1_000_000_007
dp = {}
dp[0] = 1
for i in range(1, n+1):
    if i in a:
        dp[i] = 0
        continue
    if i - 2 < 0:
        dp[i] = dp[i-1]
    else:
        dp[i] = dp[i-1] + dp[i-2]

print(dp[n] % M)

Fixed submission:
from collections import deque
n, m = map(int, input().split())
a = set(int(input()) for _ in range(m))
M = 1000000007
dp = {}
dp[0] = 1
for i in range(1, n+1):
    if i in a:
        dp[i] = 0
        continue
    if i - 2 < 0:
        dp[i] = dp[i-1]
    else:
        dp[i] = dp[i-1] + dp[i-2]

print(dp[n] % M)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
ans = set()
for _ in range(m):
    l, r = map(int, input().split())
    tmp = set(range(l, r+1))
    if ans:
        ans &= tmp
    else:
        ans = tmp

print(len(ans))

Fixed submission:
n, m = map(int, input().split())
ml, mr = -1, -1
for _ in range(m):
    l, r = map(int, input().split())
    if ml == -1:
        ml = l
        mr = r
    else:
        if ml < l:
            ml = l
        if mr > r:
            mr = r
if mr - ml < 0:
    print(0)
else:
    print(mr - ml + 1)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
from collections import defaultdict, deque

n, m = map(int, input().split())
d = defaultdict(list)

queue = deque()
for i in range(m):
    p, y = map(int, input().split())
    index = bisect.bisect_left(d[p], y)
    d[p].insert(index, y)
    queue.append((p, y))

while queue:
    p, y = queue.popleft()
    index = bisect.bisect_left(d[p], y)
    print('{:06d}{:06d}'.format(p, index + 1))

Fixed submission:
from collections import defaultdict
import bisect

n, m = map(int, input().split())
d = defaultdict(list)

queue = []
for i in range(m):
    p, y = map(int, input().split())
    d[p].append((y, i))

arr = [0] * m
for k, v in d.items():
    for i, item in enumerate(sorted(v, key=lambda x: x[0])):
        arr[item[1]] = (k, i)

for k, v in arr:
    print('{:06d}{:06d}'.format(k, v + 1))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
from collections import defaultdict, deque

n, m = map(int, input().split())
d = defaultdict(list)

queue = deque()
for i in range(m):
    p, y = map(int, input().split())
    queue.append((p, y))
    index = bisect.bisect_left(d[p], y)
    d[p].insert(index, y)

while queue:
    p, y = queue.popleft()
    index = d[p].index(y)
    print('{:06d}{:06d}'.format(p, index + 1))

Fixed submission:
from collections import defaultdict
import bisect

n, m = map(int, input().split())
d = defaultdict(list)

queue = []
for i in range(m):
    p, y = map(int, input().split())
    d[p].append((y, i))

arr = [0] * m
for k, v in d.items():
    for i, item in enumerate(sorted(v, key=lambda x: x[0])):
        arr[item[1]] = (k, i)

for k, v in arr:
    print('{:06d}{:06d}'.format(k, v + 1))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
from collections import defaultdict, deque

n, m = map(int, input().split())
d = defaultdict(list)

queue = deque()
for i in range(m):
    p, y = map(int, input().split())
    d[p].append(y)
    queue.append((p, y))

while queue:
    p, y = queue.popleft()
    index = sorted(d[p]).index(y)
    print('{:06d}{:06d}'.format(p, index + 1))

Fixed submission:
from collections import defaultdict
import bisect

n, m = map(int, input().split())
d = defaultdict(list)

queue = []
for i in range(m):
    p, y = map(int, input().split())
    d[p].append((y, i))

arr = [0] * m
for k, v in d.items():
    for i, item in enumerate(sorted(v, key=lambda x: x[0])):
        arr[item[1]] = (k, i)

for k, v in arr:
    print('{:06d}{:06d}'.format(k, v + 1))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(input()) for _ in range(n)]
tmp = a[0]
if a.index(2) == -1:
    print(-1)
else:
    ans = -1
    count = 0
    for i in range(n):
        count += 1
        if tmp == 2:
            ans = count
            break
        tmp = a[tmp - 1]
print(ans)

Fixed submission:
n = int(input())
a = [int(input()) for _ in range(n)]
tmp = a[0]
ans = -1
count = 0
for i in range(n):
    count += 1
    if tmp == 2:
        ans = count
        break
    tmp = a[tmp - 1]
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(input()) for _ in range(n)]
tmp = a[0]
if a.index(2) == -1:
    print(-1)
else:
    ans = -1
    count = 0
    while(tmp != 1):
        count += 1
        if tmp == 2:
            ans = count
            break
        tmp = a[tmp - 1]
print(ans)

Fixed submission:
n = int(input())
a = [int(input()) for _ in range(n)]
tmp = a[0]
ans = -1
count = 0
for i in range(n):
    count += 1
    if tmp == 2:
        ans = count
        break
    tmp = a[tmp - 1]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 1
for i in range(1, n+1):
    ans *= i

print(ans % (10**9+7))

Fixed submission:
import math
n = int(input())
ans = math.factorial(n)

print(ans % (10**9+7))
Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
count = 0
for i in range(k+1):
    for j in range(k+1):
        for l in range(k+1):
            if i + j + l == s:
                count += 1
print(count)

Fixed submission:
k, s = map(int, input().split())
count = 0
for i in range(k+1):
    if (s - i) / 2 > k:
        continue
    for j in range(k+1):
        z = s - i - j
        if 0 <= z <= k:
            count += 1

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
datas = ['dream', 'dreamer', 'erase', 'eraser']

while True:
    flag = False
    for data in datas:
        if s[::-1].startswith(data[::-1]):
            s = s[:-len(data)]
            flag = True
            break
    if not flag:
        break
if len(s):
    print('NO')
else:
    print('YES')


Fixed submission:
s = input()

while len(s) >= 5:
    if s[-5:] == 'dream':
        s = s[:-5]
        continue
    elif s[-7:] == 'dreamer':
        s = s[:-7]
        continue
    elif s[-5:] == 'erase':
        s = s[:-5]
        continue
    elif s[-6:] == 'eraser':
        s = s[:-6]
        continue
    else:
        break
if len(s):
    print('NO')
else:
    print('YES')
Buggy python submission (verdict: Runtime Error):
import sys
import defaultdict

args = sys.argv
dd = defaultdict(int)

for arg in args:
    dd[arg] += 1

if dd[5] == 2 and dd[7] == 1:
    print('YES')
else:
    print('NO')


Fixed submission:
from collections import defaultdict

dd = defaultdict(int)
for i in input().split():
    dd[i] += 1

if dd['5'] == 2 and dd['7'] == 1:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())

if a >= 10 or b >= 10:
    print(-1)
else:
    print(a * b)


Fixed submission:
a, b = map(int, input().split())

if a >= 10 or b >= 10:
    print(-1)
else:
    print(a * b)

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
if a >= 10 or b >= 10:
    print(-1)
else:
    print(a * b)


Fixed submission:
a, b = map(int, input().split())

if a >= 10 or b >= 10:
    print(-1)
else:
    print(a * b)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

s = list(input())
ans = []

for j in range(len(s)):
    if (s[j]) == "B":
        l = len(ans)
        if l == 0:
            continue
        else:
            del ans[j-1]
    else:
        ans.append(s[j])

print("".join(ans))

Fixed submission:
# -*- coding: utf-8 -*-

s = list(input())
ans = []

for j in range(len(s)):
    # print("j=%d word=%s length=%d ans=%s" % (j, s[j], len(ans), "".join(ans)))
    if (s[j]) == "B":
        l = len(ans)
        if l == 0:
            continue
        else:
            del ans[-1]
    else:
        ans.append(s[j])

print("".join(ans))
Buggy python submission (verdict: Runtime Error):

from heapq import heappush, heappop, heapify


obj = input().strip().split(' ')
N, M = map(int, obj)

obj = input().strip().split(' ')
val_list = [-1 * item for item in list(map(int, obj))]

heapify(val_list)

for _ in range(M):
    val = (-1) * ((heappop(val_list) * (-1)) // 2)
    heappush(val_list, val)

print(-1 * sum(val_list))


Fixed submission:
#!/usr/bin/env python
# -*- coding:utf-8 -*-


S = input().strip()

if S == 'Sunny':
    print('Cloudy')

if S == 'Cloudy':
    print('Rainy')

if S == 'Rainy':
    print('Sunny')

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding:utf-8 -*-


obj = input().strip().split(' ')
N, K, Q = map(int, obj)

winner_list = []
for _ in range(Q):
    A_i = int(input().strip())
    winner_list.append(A_i)

point_list = [K for _ in range(N)]

for A_i in winner_list:
    point_list = [k if i == A_i else k - 1 for i in range(1, N + 1)]

is_win = [True if point_list[i] > 0 else False for i in range(N) ]

for i in range(N):
    if is_win[i]:
        print('Yes')
    else:
        print('No')


Fixed submission:
#!/usr/bin/env python
# -*- coding:utf-8 -*-


S = input().strip()

if S == 'Sunny':
    print('Cloudy')

if S == 'Cloudy':
    print('Rainy')

if S == 'Rainy':
    print('Sunny')
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# -*- coding:utf-8 -*-


obj = input().strip().split(' ')
N, K, Q = map(int, obj)

winner_list = []
for _ in range(Q):
    A_i = int(input().strip())
    winner_list.append(A_i)

point_list = [K for _ in range(N)]

for A_i in winner_list:
    point_list = [k if i+1 == A_i else k - 1 for i, k in enumerate(point_list)]

is_win = [True if point_list[i] > 0 else False for i in range(N) ]

for i in range(N):
    if is_win[i]:
        print('Yes')
    else:
        print('No')


Fixed submission:
#!/usr/bin/env python
# -*- coding:utf-8 -*-


obj = input().strip().split(' ')
N, K, Q = map(int, obj)

win_count = [0] * N
for _ in range(Q):
    A_i = int(input().strip())
    win_count[A_i - 1] += 1

is_ok = [True if Q - cnt < K else False for cnt in win_count]

for i in range(N):
    if is_ok[i]:
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding:utf-8 -*-


obj = input().strip().split(' ')
N, K, Q = map(int, obj)

winner_list = []
for _ in range(Q):
    A_i = int(input().strip())
    winner_list.append(A_i)

point_list = [K for _ in range(N)]

for A_i in winner_list:
    point_list = [k if i == A_i else k - 1 for i in range(1, N + 1)]

is_win = [True if point_list[i] > 0 else False for i in range(N) ]

for i in range(N):
    if is_win[i]:
        print('Yes')
    else:
        print('No')


Fixed submission:
#!/usr/bin/env python
# -*- coding:utf-8 -*-


obj = input().strip().split(' ')
N, K, Q = map(int, obj)

win_count = [0] * N
for _ in range(Q):
    A_i = int(input().strip())
    win_count[A_i - 1] += 1

is_ok = [True if Q - cnt < K else False for cnt in win_count]

for i in range(N):
    if is_ok[i]:
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# -*- coding:utf-8 -*-


obj = input().strip().split(' ')
N, K, Q = map(int, obj)

winner_list = []
for _ in range(Q):
    A_i = int(input().strip())
    winner_list.append(A_i)

point_list = [K for _ in range(N)]

for A_i in winner_list:
    for i in range(1, N + 1):
        if i != A_i:
            point_list[i - 1] -= 1

is_win = [True if point_list[i] > 0 else False for i in range(N) ]

for i in range(N):
    if is_win[i]:
        print('Yes')
    else:
        print('No')


Fixed submission:
#!/usr/bin/env python
# -*- coding:utf-8 -*-


obj = input().strip().split(' ')
N, K, Q = map(int, obj)

win_count = [0] * N
for _ in range(Q):
    A_i = int(input().strip())
    win_count[A_i - 1] += 1

is_ok = [True if Q - cnt < K else False for cnt in win_count]

for i in range(N):
    if is_ok[i]:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Runtime Error):
obj = input().strip().split(' ')
N, M = map(int, obj)

obj = input().strip().split(' ')
val_list = [-1 * item for item in list(map(int, obj))]

heapify(val_list)

for _ in range(M):
    val = (-1) * ((heappop(val_list) * (-1)) // 2)
    heappush(val_list, val)

print(-1 * sum(val_list))


Fixed submission:
from heapq import heappush, heappop, heapify

obj = input().strip().split(' ')
N, M = map(int, obj)

obj = input().strip().split(' ')
val_list = [-1 * item for item in list(map(int, obj))]

heapify(val_list)

for _ in range(M):
    val = (-1) * ((heappop(val_list) * (-1)) // 2)
    heappush(val_list, val)

print(-1 * sum(val_list))

Buggy python submission (verdict: Time Limit Exceeded):
obj = input().strip().split(' ')
N, M = map(int, obj)

obj = input().strip().split(' ')
A_list = map(int, obj)

val_list = sorted(A_list, reverse=True)

can_insert = False
for _ in range(M):
    val = val_list.pop(0) // 2
    for i, v in enumerate(val_list):
        if val >= v:
            val_list.insert(i, val)
            can_insert = True
            break
    if not can_insert:
        val_list.append(val)

print(sum(val_list))


Fixed submission:
from heapq import heappush, heappop, heapify

obj = input().strip().split(' ')
N, M = map(int, obj)

obj = input().strip().split(' ')
val_list = [-1 * item for item in list(map(int, obj))]

heapify(val_list)

for _ in range(M):
    val = (-1) * ((heappop(val_list) * (-1)) // 2)
    heappush(val_list, val)

print(-1 * sum(val_list))

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# -*- coding:utf-8 -*-


obj = input().strip().split(' ')
N, M = map(int, obj)

obj = input().strip().split(' ')
A_list = map(int, obj)

val_list = sorted(A_list, reverse=True)


for _ in range(M):
    val_list[0] = val_list[0] // 2
    i = 0
    while i < N - 1 and val_list[i] < val_list[i + 1]:
        tmp = val_list[i]
        val_list[i] = val_list[i + 1]
        val_list[i + 1] = tmp
        i += 1

print(sum(val_list))


Fixed submission:
from heapq import heappush, heappop, heapify

obj = input().strip().split(' ')
N, M = map(int, obj)

obj = input().strip().split(' ')
val_list = [-1 * item for item in list(map(int, obj))]

heapify(val_list)

for _ in range(M):
    val = (-1) * ((heappop(val_list) * (-1)) // 2)
    heappush(val_list, val)

print(-1 * sum(val_list))

Buggy python submission (verdict: Time Limit Exceeded):
obj = input().strip().split(' ')
N, M = map(int, obj)

obj = input().strip().split(' ')
A_list = map(int, obj)

out_list = [item for item in A_list]

for _ in range(M):
    i = out_list.index(max(out_list))
    out_list[i] = out_list[i] // 2

print(sum(out_list))


Fixed submission:
from heapq import heappush, heappop, heapify

obj = input().strip().split(' ')
N, M = map(int, obj)

obj = input().strip().split(' ')
val_list = [-1 * item for item in list(map(int, obj))]

heapify(val_list)

for _ in range(M):
    val = (-1) * ((heappop(val_list) * (-1)) // 2)
    heappush(val_list, val)

print(-1 * sum(val_list))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input().strip())
S = input().strip()

dp = [[0 for j in range(N+1)] for i in range(N+1)]

for i in range(N - 1, -1, -1):
    for j in range(N - 1, -1, -1):
        if S[i] != S[j]:
            dp[i][j] = 0
        else:
            dp[i][j] = dp[i + 1][j + 1] + 1

max_length = 0
for i in range(N):
    for j in range(N):
        if i < j:
            length = min(j - i, dp[i][j])
            max_length = max(length, max_length)

print(max_length)


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

dp = [[0 for j in range(N+1)] for i in range(N+1)]

for i in range(N - 1, -1, -1):
    for j in range(N - 1, -1, -1):
        if S[i] != S[j]:
            dp[i][j] = 0
        else:
            dp[i][j] = dp[i + 1][j + 1] + 1

max_length = 0
for i in range(N):
    for j in range(N):
        if i < j:
            length = min(j - i, dp[i][j])
            max_length = max(length, max_length)

print(max_length)

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

max_length = 0

for i in range(N):
    for length in range(N - i):
        if S[i:i+length] in S[i+length:]:
            if length > max_length:
                max_length = length

print(max_length)


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

dp = [[0 for j in range(N+1)] for i in range(N+1)]

for i in range(N - 1, -1, -1):
    for j in range(N - 1, -1, -1):
        if S[i] != S[j]:
            dp[i][j] = 0
        else:
            dp[i][j] = dp[i + 1][j + 1] + 1

max_length = 0
for i in range(N):
    for j in range(N):
        if i < j:
            length = min(j - i, dp[i][j])
            max_length = max(length, max_length)

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

for _ in range(M):
    i = max(range(len(A)), key=A.__getitem__)
    A[i] /= 2
A = list(map(int, A))
print(sum(A))


Fixed submission:
import heapq

N, M = map(int, input().split())
A = list(map(float, input().split()))

heap = [-Ai for Ai in A]
heapq.heapify(heap)
for _ in range(M):
    heapq.heapreplace(heap, heap[0]/2)
A = [int(-p) for p in heap]
print(sum(A))