Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
rows = []
for i in range(2):
    row = [int(x) for x in input().split()]
    rows.append(row)

N = int(input())
choice = []
for j in range(N):
    choice.append(int(input()))


for row in rows:
    match = [c for c in choice if c in row]

    if (len(match) >= 3):
        print("yes")
        break

columns = []
for k in range(3):
    column = [rows[l][k] for l in range(3)]
    columns.append(column)

for column in columns:
    match = [c for c in choice if c in column]

    if (len(match) >= 3):
        print("yes")
        break

left = []
for m in range(3):
    left.append(rows[m][m])

for x in left:
    match = [c for c in choice if c in x]

    if (len(match) >= 3):
        print("yes")
        break

right = []
for n in range(3):
    for o in range(3)[::-1]:
        right.append(rows[n][o])

for y in right:
    match = [c for c in choice if c in y]

    if (len(match) >= 3):
        print("yes")
        break


Fixed submission:
rows = []
for i in range(3):
    row = [int(x) for x in input().split()]
    rows.append(row)


columns = []
for k in range(3):
    column = [rows[l][k] for l in range(3)]
    columns.append(column)

left = []
for m in range(3):
    left.append(rows[m][m])

right = []
o = 2
for n in range(3):
    right.append(rows[n][o])
    o -= 1


N = int(input())
choice = []
for j in range(N):
    choice.append(int(input()))


matches = []
for row in rows:
    matches.append([c for c in row if c in choice])

for column in columns:
    matches.append([c for c in column if c in choice])

matches.append([c for c in left if c in choice])
matches.append([c for c in right if c in choice])


isPrinted = False
for match in matches:
    if (len(match) == 3):
        print("Yes")
        isPrinted = True
        break

if (not isPrinted):
    print("No")
Buggy python submission (verdict: Runtime Error):
[S, T] = input().split()
[A, B] = input().split()
U = input()

if U == S:
    print(f"{int(A)-1} {B}")
else:
    print(f"{A} {int(B) - 1}")

Fixed submission:
[S, T] = input().split()
[A, B] = [int(x) for x in input().split()]
U = input()

if U == S:
    print(A-1, B)
else:
    print(A, B-1)

Buggy python submission (verdict: Runtime Error):
[S, T] = input().split()
[A, B] = input().split()
U = input()
 
if U == S:
    print(f"{int(A)-1} {B}")
else:
    print(f"{A} {int(B) - 1}")

Fixed submission:
[S, T] = input().split()
[A, B] = [int(x) for x in input().split()]
U = input()

if U == S:
    print(A-1, B)
else:
    print(A, B-1)

Buggy python submission (verdict: Runtime Error):
[S, T] = input().split()
print(S)
print(T)

[A, B] = input().split()

U = input()

if U == S:
    print(f"{int(A)-1} {B}")
else:
    print(f"{A} {int(B) - 1}")


Fixed submission:
[S, T] = input().split()
[A, B] = [int(x) for x in input().split()]
U = input()

if U == S:
    print(A-1, B)
else:
    print(A, B-1)

Buggy python submission (verdict: Runtime Error):
X = input().split()
S = X[0]
T = X[1]
Y = input().split()
A = int(Y[0])
B = int(Y[1])
U = input()
 
A -= 1 if U == S else B -= 1
 
print(str(A) + " " + str(B))

Fixed submission:
[S, T] = input().split()
[A, B] = [int(x) for x in input().split()]
U = input()

if U == S:
    print(A-1, B)
else:
    print(A, B-1)

Buggy python submission (verdict: Runtime Error):
X = input().split()
S = X[0]
T = X[1]
Y = input().split()
A = int(Y[0])
B = int(Y[1])
U = input()

A -= 1 if U == S else B-= 1

print(A + " " + B)

Fixed submission:
[S, T] = input().split()
[A, B] = [int(x) for x in input().split()]
U = input()

if U == S:
    print(A-1, B)
else:
    print(A, B-1)
Buggy python submission (verdict: Runtime Error):
H, N = [int(x) for x in input().split()]
attacks = [int(x) for x in input().split()]
print("Yes" if H - sum(attacks) <= 0 else "No")

Fixed submission:
import math

H, A = [int(x) for x in input().split()]
print(math.ceil(H/A))

Buggy python submission (verdict: Runtime Error):
H, N = [int(x) for x in input().split()]
attacks = [int(x) for x in input().split()]
print("Yes" if H - sum(attacks) <= 0 else "No")

Fixed submission:
import math

H, A = [int(x) for x in input().split()]
print(math.ceil(H/A))
Buggy python submission (verdict: Runtime Error):
n, m = [int(x) for x in input().split()]

answers = []
for x in range(m):
    answers.append(input().split())

correct_answers = [answer[0] for answer in answers if answer[1] == "AC"]

temp = {k[0]: [] for k in answers}
for x in answers:
    temp[x[0]].append(x[1])

penalties = 0
for x in temp:
    G = temp[x][:temp[x].index("AC")]
    penalties += len(G)


print(len(set(correct_answers)), penalties)


Fixed submission:
n, m = [int(x) for x in input().split()]

answers = []
for x in range(m):
    answers.append(input().split())

correct_answers = set([answer[0] for answer in answers if answer[1] == "AC"])

temp = {k[0]: [] for k in answers}
for x in answers:
    temp[x[0]].append(x[1])

penalties = 0
for x in temp:
    if (temp[x].count("AC") > 0):
        G = temp[x][:temp[x].index("AC")]
        penalties += len(G)


print(len(correct_answers), penalties)
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()

print(T+S)

Fixed submission:
S_T = input().split()
S = S_T[0]
T = S_T[1]

print(T+S)
Buggy python submission (verdict: Time Limit Exceeded):
ABK = input().split()
A = int(ABK[0])
B = int(ABK[1])
K = int(ABK[2])

cookie_eaten = 0

while (cookie_eaten != K):
    if (A > 0):
        A -= 1
    else:
        B -= 1

    cookie_eaten += 1

print(str(A) + " " + str(B))

Fixed submission:
ABK = input().split()
A = int(ABK[0])
B = int(ABK[1])
K = int(ABK[2])

if (K >= A):
    K -= A
    B -= K
    A = 0

    if (B <= 0):
        B = 0
else:
    A -= K

print(str(A) + " " + str(B))

Buggy python submission (verdict: Runtime Error):
ABK = input()
A = int(ABK[0])
B = int(ABK[1])
K = int(ABK[2])

if (K >= A):
  print(str(K-A) + " " + str(K-A-B))
else:
  print(str(K-A) + " " + str(B))

Fixed submission:
ABK = input().split()
A = int(ABK[0])
B = int(ABK[1])
K = int(ABK[2])

if (K >= A):
    K -= A
    B -= K
    A = 0

    if (B <= 0):
        B = 0
else:
    A -= K

print(str(A) + " " + str(B))

Buggy python submission (verdict: Runtime Error):
A_B_K = input()

A = int(A_B_K[0])
B = int(A_B_K[1])
K = int(A_B_K[2])
 
result = K - (A+B)
 
if (result <=0):
  print(0)
else:
  print(result)

Fixed submission:
ABK = input().split()
A = int(ABK[0])
B = int(ABK[1])
K = int(ABK[2])

if (K >= A):
    K -= A
    B -= K
    A = 0

    if (B <= 0):
        B = 0
else:
    A -= K

print(str(A) + " " + str(B))

Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
K = int(input())

result = K - (A+B)

if (result <=0):
  print(0)
else:
  print(result)

Fixed submission:
ABK = input().split()
A = int(ABK[0])
B = int(ABK[1])
K = int(ABK[2])

if (K >= A):
    K -= A
    B -= K
    A = 0

    if (B <= 0):
        B = 0
else:
    A -= K

print(str(A) + " " + str(B))
Buggy python submission (verdict: Runtime Error):
number_of_guests = input().split()

A = int(number_of_guests[0])
B = int(number_of_guests[1])


A_divisors = []
x = 2
while True:
    if (A % x == 0):
        A /= x
        A_divisors.append(x)
    else:
        x += 1

    if (A <= 1):
        break

y = 2
B_divisors = []
while True:
    if (B % y == 0):
        B /= y
        B_divisors.append(y)
    else:
        y += 1

    if (B <= 1):
        break

A_only = [x for x in A_divisors if (x not in B_divisors)]
B_only = [y for y in B_divisors if (y not in A_divisors)]

common_divisors = []
for z in (A_divisors + B_divisors):
    if z in A_divisors and z in B_divisors:
        if (A_divisors.count(z) >= B_divisors.count(z)):
            common_divisors.append(z**A_divisors.count(z))
        else:
            common_divisors.append(z**B_divisors.count(z))

        A_divisors = list(filter(lambda x: x != z, A_divisors))
        B_divisors = list(filter(lambda x: x != z, B_divisors))


result = 1
for x in A_only + B_only + common_divisors:
    result *= x

print(result)


Fixed submission:
A = input()
B = input()
 
choices = "123"
answer = [x for x in choices if x != A and x != B]

print(int(answer[0]))
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(lambda x:int(x),input().split())
p_n = list(map(lambda x:int(x),input().split()))

max = 0
for i in range(len(p_n)-(k-1)):
    tmp = p_n[i]
    for j in range(k-1):
        tmp = tmp + p_n[i+j+1]
    if tmp > max:
        max = tmp


print((max+k)*0.5)


Fixed submission:
#x,y = map(lambda x: int(x), input().split())
#list = list(map(lambda x: int(x), input().split()))


n,k = map(lambda x: int(x), input().split())
p_lst = list(map(lambda x: int(x), input().split()))


def cum_sum(list):
    result = []
    for i in range(len(list)):
        if i == 0:
            result.append(list[i])
        else:
            result.append(result[i-1] + list[i])
    return result


def cum_sum_exp(list):
    result = []
    for i in range(len(list)):
        if i == 0:
            result.append((list[i]+1)/2)
        else:
            result.append(result[i-1] + (list[i]+1)/2)
    return result



cum_sum_main = cum_sum_exp(p_lst)


cmp = cum_sum_main[k-1]


for i in range(k-1,n):
    if i == k-1:
        cmp = cum_sum_main[i]
    else:
        tmp = cum_sum_main[i] - cum_sum_main[i-k]

        if cmp < tmp:
            cmp = tmp



print(cmp)

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(lambda x:int(x),input().split())
p_n = list(map(lambda x:int(x),input().split()))


def culc_exp(n):
    return 0.5 * (n+1)

p_n = list(map(lambda x:culc_exp(x),p_n))

def sum_list_a_to_k(list,a,k):
    result = 0
    for i in range(k):
        result = result+list[a+i]
    return result





def max_tuple(list):
    max = 0
    for i in range(len(list)-(k-1)):
        tmp = sum_list_a_to_k(list,i,k)
        if tmp > max:
            max = tmp
    return max


print(max_tuple(p_n))


Fixed submission:
#x,y = map(lambda x: int(x), input().split())
#list = list(map(lambda x: int(x), input().split()))


n,k = map(lambda x: int(x), input().split())
p_lst = list(map(lambda x: int(x), input().split()))


def cum_sum(list):
    result = []
    for i in range(len(list)):
        if i == 0:
            result.append(list[i])
        else:
            result.append(result[i-1] + list[i])
    return result


def cum_sum_exp(list):
    result = []
    for i in range(len(list)):
        if i == 0:
            result.append((list[i]+1)/2)
        else:
            result.append(result[i-1] + (list[i]+1)/2)
    return result



cum_sum_main = cum_sum_exp(p_lst)


cmp = cum_sum_main[k-1]


for i in range(k-1,n):
    if i == k-1:
        cmp = cum_sum_main[i]
    else:
        tmp = cum_sum_main[i] - cum_sum_main[i-k]

        if cmp < tmp:
            cmp = tmp



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

a,b = map(lambda x:int(x), input().split())


print(math.ceil(a*b/math.gcd(a,b)))





Fixed submission:
import fractions
import math

a,b = map(lambda x:int(x), input().split())


print(math.ceil(a*b/fractions.gcd(a,b)))

Buggy python submission (verdict: Runtime Error):
import math

a,b = map(lambda x:int(x), input().split())

print(math.ceil(a*b/math.gcd(a,b)))






Fixed submission:
import fractions
import math

a,b = map(lambda x:int(x), input().split())


print(math.ceil(a*b/fractions.gcd(a,b)))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

a = list(map(lambda x:int(x), input().split()))

#junban = []

for i in range(n):
    jun = a.index(i+1)
    #junban.append(jun+1)
    if i != n:
        print(jun+1," ",end="")
    else:
        print(jun+1)


Fixed submission:
n = int(input())

a = list(map(lambda x:int(x), input().split()))

junban = []
for i in range(n):
    junban.append(0)

for i in range(n):
    junban[a[i]-1] = str(i+1)



print(" ".join(junban))

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

a = list(map(lambda x:int(x), input().split()))

junban = []

for i in range(n):
    jun = a.index(i+1)
    #junban.append(jun+1)
    if i != n:
        print(jun+1," ",end="")
    else:
        print(jun+1)




Fixed submission:
n = int(input())

a = list(map(lambda x:int(x), input().split()))

junban = []
for i in range(n):
    junban.append(0)

for i in range(n):
    junban[a[i]-1] = str(i+1)



print(" ".join(junban))

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

a = list(map(lambda x:int(x), input().split()))

junban = []

for i in range(n):
    jun = a.index(i+1)
    junban.append(str(jun+1))

print(" ".join(junban))


Fixed submission:
n = int(input())

a = list(map(lambda x:int(x), input().split()))

junban = []
for i in range(n):
    junban.append(0)

for i in range(n):
    junban[a[i]-1] = str(i+1)



print(" ".join(junban))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

arr = []
max_num = 0
label = 1
for i in range(n):
    inp = int(input())
    if inp >= max_num:
       max_num = inp
       label = i
    arr.append(inp)


arr_sub = arr[:]
arr_sub.pop(label)
#print(arr)
#print(max(arr))
#print(max(arr_sub))



for i in range(n):
    if i != label:
        print(max(arr))
    else:
        print(max(arr_sub))




Fixed submission:
n = int(input())

arr = []
max_num = 0
label = 1
for i in range(n):
    inp = int(input())
    if inp >= max_num:
       max_num = inp
       label = i
    arr.append(inp)



arr_sub = arr[:]
arr_sub.pop(label)
second_max = max(arr_sub)


for i in range(n):
    if i != label:
        print(max_num)
    else:
        print(second_max)
Buggy python submission (verdict: Runtime Error):
inp = input().split()
n = int(inp[0])
m = int(inp[1])
favorite = [] #　i番目の人が好きなものの集合のリスト
for i in range(n):
    tmp = []
    tmp_inp = input().split()
    k = int(tmp_inp[0])
    for i in range(k):
        tmp.append(int(tmp_inp[i+1]))
    hyou.append(set(tmp))


def intersect_set(list):  # 集合のリストを受け取って、それらの積集合を返す
    result = list[0]
    for i in range(len(list)-1):
        result = result.intersection(list[i+1])
    return result

print(len(intersect_set(hyou)))


Fixed submission:
inp = input().split()
n = int(inp[0])
m = int(inp[1])
hyou = []
for i in range(n):
    tmp = []
    tmp_inp = input().split()
    k = int(tmp_inp[0])
    for i in range(k):
        tmp.append(int(tmp_inp[i+1]))
    hyou.append(set(tmp))


def intersect_set(list):
    result = list[0]
    for i in range(len(list)-1):
        result = result.intersection(list[i+1])
    return result

print(len(intersect_set(hyou)))
Buggy python submission (verdict: Time Limit Exceeded):
in_1 = input().split()
n = int(in_1[0])
k = int(in_1[1])

trees_height = []
for i in range(n):
    trees_height.append(int(input()))

trees_height.sort()


def sub_minmax(list):
    return max(list)-min(list)

subs = []

for i in range(n+1-k):
    subs.append(sub_minmax(trees_height[i:i+k]))

print(min(subs))



Fixed submission:
in_1 = input().split()
n = int(in_1[0])
k = int(in_1[1])

trees_height = []
for i in range(n):
    trees_height.append(int(input()))

trees_height.sort()


def sub_minmax(list):
    return max(list)-min(list)

subs = []

for i in range(n+1-k):
    subs.append(trees_height[i+k-1]-trees_height[i])


print(min(subs))

Buggy python submission (verdict: Time Limit Exceeded):

in_1 = input().split()
n = int(in_1[0])
k = int(in_1[1])

trees_height = []
for i in range(n):
    trees_height.append(int(input()))

trees_height.sort()


def sub_minmax(list):
    return max(list)-min(list)

subs = []

for i in range(n+1-k):
    subs.append(sub_minmax(trees_height[i:i+k]))


print(min(subs))


Fixed submission:
in_1 = input().split()
n = int(in_1[0])
k = int(in_1[1])

trees_height = []
for i in range(n):
    trees_height.append(int(input()))

trees_height.sort()


def sub_minmax(list):
    return max(list)-min(list)

subs = []

for i in range(n+1-k):
    subs.append(trees_height[i+k-1]-trees_height[i])


print(min(subs))
Buggy python submission (verdict: Runtime Error):
n = int(input())
for i in range(9):
    if 111*i >= n:
        result = i
        break

print(result*111)


Fixed submission:
n = int(input())
for i in range(9):
    if 111*(i+1) >= n:
        print(111*(i+1))
        break
Buggy python submission (verdict: Runtime Error):
19 123 143

Fixed submission:
inp = list(map(lambda x:int(x), input().split()))

if inp[2] <= inp[0] + inp[1]:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import heapdict

n = int(input())
la = list(map(int, input().split()))

ct = [0] * (2*10**5+1)
ans = [0] * (n+1)
ld = [0] * (n+1)

for i in range(len(la)):
    ct[la[i]] += 1

sa = set(la)

for j in sa:
    ans[j] = ct[j] * (ct[j]-1) // 2
    ld[j] = ans[j] - ((ct[j]-2) * (ct[j]-1) // 2)

total = sum(ans)

# print(ct[0:10])
# print(ans)

for k in range(n):
    knum = la[k]
    print(total - ld[knum])


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

ct = [0] * (2*10**5+1)
ans = [0] * (n+1)
ld = [0] * (n+1)

for i in range(len(la)):
    ct[la[i]] += 1

sa = set(la)

for j in sa:
    ans[j] = ct[j] * (ct[j]-1) // 2
    ld[j] = ans[j] - ((ct[j]-2) * (ct[j]-1) // 2)

total = sum(ans)

# print(ct[0:10])
# print(ans)

for k in range(n):
    knum = la[k]
    print(total - ld[knum])

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

ct = [0] * (2*10**5+1)
ans = [0] * (n+1)

for i in range(len(la)):
    ct[la[i]] += 1

sa = set(la)

for j in sa:
    ans[j] = ct[j] * (ct[j]-1) // 2

# print(ct[0:10])
# print(ans)

for k in range(n):
    knum = la[k]
    ans[knum] = (ct[knum] - 1) * (ct[knum] - 2) // 2
    print(sum(ans))
    ans[knum] = (ct[knum] - 1) * ct[knum] // 2


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

ct = [0] * (2*10**5+1)
ans = [0] * (n+1)
ld = [0] * (n+1)

for i in range(len(la)):
    ct[la[i]] += 1

sa = set(la)

for j in sa:
    ans[j] = ct[j] * (ct[j]-1) // 2
    ld[j] = ans[j] - ((ct[j]-2) * (ct[j]-1) // 2)

total = sum(ans)

# print(ct[0:10])
# print(ans)

for k in range(n):
    knum = la[k]
    print(total - ld[knum])
Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())

if h == 1 or w == 1:
    print(1)
else:
    hc = (w+1) // 2
    hc2 = w // 2
    d, m = divmod(h, 2)
    ans = d * (hc + hc2) + m * hc

print(ans)


Fixed submission:
h, w = map(int, input().split())

if h == 1 or w == 1:
    print(1)
else:
    hc = (w+1) // 2
    hc2 = w // 2
    d, m = divmod(h, 2)
    ans = d * (hc + hc2) + m * hc
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ll = list(map(int, input().split()))
ll.sort()

ans = 0

i = 0
j = 1
k = 2

while i < n-2:
    while j < n-1:
        while k < n:
            if ll[i] + ll[j] <= ll[k]:
                break
            else:
                # print([ll[i], ll[j], ll[k]])
                k += 1
                ans += 1
        j += 1
        k = j + 1
    i += 1
    j = i + 1
    k = j + 1

print(ans)


Fixed submission:
n = int(input())
ll = list(map(int, input().split()))
ll.sort(reverse=True)

ans = 0

for i in range(n-2):
    j = i + 1
    k = n - 1
    while k > j:
        if ll[i] < ll[j] + ll[k]:
            ans += k - j
            j += 1
        else:
            k -= 1

print(ans)

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

ans = 0

for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            tl = [ll[i], ll[j], ll[k]]
            tl.sort()
            if tl[0] + tl[1] > tl[2]:
                ans += 1

print(ans)


Fixed submission:
n = int(input())
ll = list(map(int, input().split()))
ll.sort(reverse=True)

ans = 0

for i in range(n-2):
    j = i + 1
    k = n - 1
    while k > j:
        if ll[i] < ll[j] + ll[k]:
            ans += k - j
            j += 1
        else:
            k -= 1

print(ans)
Buggy python submission (verdict: Runtime Error):
import fraction as m

a, b = map(int, input().split())

lcd = []
cd = m.gcd(a, b)
lcd.append(cd)

t1 = a
t2 = b
cd1 = cd
cd2 = cd

if cd > 1:
    while True:
        m1 = t1 % cd1
        m2 = t2 % cd2
        if m1 > 0 and m2 > 0:
            break
        if m1 == 0:
            c = t1 // cd1
            lcd.append(c)
            t1 = c
        if m2 == 0:
            c = t2 // cd2
            lcd.append(c)
            t2 = c

    lcd = list(set(lcd))
    lcd.append(1)
    lcd.sort()

ans = 0

lns = len(lcd)
i = 0
while i < lns:
    j = i + 1
    while j < lns:
        if m.gcd(lcd[i], lcd[j]) > 1:
            lcd.pop(j)
            lns = len(lcd)
        j += 1
    lns = len(lcd)
    i += 1

print(len(lcd))

Fixed submission:
import fractions as m

a, b = map(int, input().split())

lcd = []
cd = m.gcd(a, b)

while cd % 2 == 0:
    lcd.append(2)
    cd //= 2

f = 3
while f * f <= cd:
    if cd % f == 0:
        lcd.append(f)
        cd //= f
    else:
        f += 2
if cd != 1:
    lcd.append(cd)

lcd.append(1)

lcd = list(set(lcd))

print(len(lcd))
Buggy python submission (verdict: Runtime Error):
import heapq as h

# input
n, m = map(int, input().split())
la = list(map(lambda x: int(x)*-1, input().split()))

h.heapify(la)

while m > 0:
    max = abs(la[0])
    h.heapreplace(la, (max // 2)*-1)
    m -= 1

print(abs(sum(la)))


Fixed submission:
# input string
s = input()

if s == "Sunny":
    print("Cloudy")
elif s == "Cloudy":
    print("Rainy")
elif s == "Rainy":
    print("Sunny")
Buggy python submission (verdict: Time Limit Exceeded):
# input
n, m = map(int, input().split())
la = sorted(list(map(int, input().split())), reverse=True)

while m > 0:
    d = 0
    for i in range(n):
        if i < n-1 and la[i] >= la[i+1]:
            if la[i+1] > 0:
                d = la[i] // la[i+1]
            else:
                d = 1
            if d > m:
                d = m
                la[i] = la[i] // (2**d)
            else:
                la[i] = la[i] // (2**d)
            #print(la)
            for j in range(i, n-1):
                if la[j] <= la[j+1]:
                    tmp = la[j]
                    la[j] = la[j+1]
                    la[j+1] = tmp
                else:
                    break
            break
        else:
            la[i] = la[i] // 2
            d = 1
            break
    #la.sort(reverse=True)
    #print(la)
    # sprint(d)
    m -= d

print(sum(la))


Fixed submission:
import heapq as h

# input
n, m = map(int, input().split())
la = list(map(lambda x: int(x)*-1, input().split()))

h.heapify(la)

while m > 0:
    max = abs(la[0])
    h.heapreplace(la, (max // 2)*-1)
    m -= 1

print(abs(sum(la)))

Buggy python submission (verdict: Time Limit Exceeded):
# input
n, m = map(int, input().split())
la = sorted(list(map(int, input().split())), reverse=True)

while m > 0:
    d = 0
    for i in range(n):
        if i < n-1 and la[i] > la[i+1]:
            if la[i+1] > 0:
                d = la[i] // la[i+1]
            else:
                d = 1
            if d > m:
                d = m
                la[i] = la[i] // (2**d)
            else:
                la[i] = la[i] // (2**d)
            break
        else:
            la[i] = la[i] // 2
            d = 1
            break
    la.sort(reverse=True)
    #print(la)
    #print(d)
    m -= d

print(sum(la))


Fixed submission:
import heapq as h

# input
n, m = map(int, input().split())
la = list(map(lambda x: int(x)*-1, input().split()))

h.heapify(la)

while m > 0:
    max = abs(la[0])
    h.heapreplace(la, (max // 2)*-1)
    m -= 1

print(abs(sum(la)))