Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from collections import Counter

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

ans_sum = 0

counter = Counter(a_li)
print(counter)

for i in counter:
    ans_sum += i*(i - 1)//2

for a in a_li:
    count = counter[a]
    if count == 1:
        print(ans_sum)
    else:
        print(ans_sum - count*(count - 1) // 2 + (count - 1)*(count - 2) // 2)

Fixed submission:
from collections import Counter

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

ans_sum = 0

counter = Counter(a_li)

for i in counter.values():
    ans_sum += i*(i - 1) // 2

for a in a_li:
    count = counter[a]
    if count == 1:
        print(ans_sum)
    else:
        print(ans_sum - count*(count - 1) // 2 + (count - 1)*(count - 2) // 2)

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

ans_sum = 0

for i in range(n):
    count = a_li.count(i + 1)
    count = count*(count - 1) // 2
    ans_sum += count

for a in a_li:
    count = a_li.count(a)
    if count == 1:
        print(ans_sum)
    else:
        print(ans_sum - count*(count - 1) // 2 + (count - 1)*(count - 2) // 2)

Fixed submission:
from collections import Counter

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

ans_sum = 0

counter = Counter(a_li)

for i in counter.values():
    ans_sum += i*(i - 1) // 2

for a in a_li:
    count = counter[a]
    if count == 1:
        print(ans_sum)
    else:
        print(ans_sum - count*(count - 1) // 2 + (count - 1)*(count - 2) // 2)

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

ans_sum = 0

for i in range(n):
    count = a_li.count(i + 1)
    count = count*(count - 1) // 2
    ans_sum += count

for a in a_li:
    count = a_li.count(a)
    if count == 1:
        print(ans_sum)
    else:
        print(ans_sum - count*(count - 1) // 2 + (count - 1)*(count - 2) // 2)

Fixed submission:
from collections import Counter

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

ans_sum = 0

counter = Counter(a_li)

for i in counter.values():
    ans_sum += i*(i - 1) // 2

for a in a_li:
    count = counter[a]
    if count == 1:
        print(ans_sum)
    else:
        print(ans_sum - count*(count - 1) // 2 + (count - 1)*(count - 2) // 2)
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
ans = 'Yes' if c - a - b > format(2*(a*b)**0.5, '.1f') else 'No'
print(ans)

Fixed submission:
a, b, c = map(int, input().split())
ans = 'Yes' if (c - a - b)**2 > 4*(a*b) and c - a - b > 0 else 'No'
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import deque
n = int(input())

num_to_alp = {0:'a', 1:'b', 2:'c', 3:'d', 4:'e', 5:'f', 6:'g', 7:'h', 8:'i', 9:'j'}
alp_to_num = {'a':0, 'b':1, 'c':2, 'd':3, 'e':4, 'f':5, 'g':6, 'h':7, 'i':8, 'j':9}
words = deque([deque([0])])

def next_letters(x):
    letters = deque([])
    for i in range(x + 2):
        letters.append(i)
    return letters

while len(words[0]) < n:
    word = words.popleft()
    letters = next_letters(max(word[-1], max(word) - 1))
    for l in letters:
        l = deque([l])
        words.append(word + l)

for word in words:
    word = [num_to_alp[i] for i in word]
    print(''.join(word))

Fixed submission:
from collections import deque
n = int(input())

num_to_alp = {0:'a', 1:'b', 2:'c', 3:'d', 4:'e', 5:'f', 6:'g', 7:'h', 8:'i', 9:'j'}
alp_to_num = {'a':0, 'b':1, 'c':2, 'd':3, 'e':4, 'f':5, 'g':6, 'h':7, 'i':8, 'j':9}
words = deque([[0]])

def next_letters(x):
    letters = deque([])
    for i in range(x + 2):
        letters.append(i)
    return letters

while len(words[0]) < n:
    word = words.popleft()
    letters = next_letters(max(word))
    for l in letters:
        l = [l]
        words.append(word + l)

for word in words:
    word = [num_to_alp[i] for i in word]
    print(''.join(word))
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
s_li = [list(map(int, input().split())) for i in range(m)]

if n != 1:
    ans = ['1']
    ans.extend(['0'] * (n - 1))
else:
    ans = ['0']
    flag = [0] * n

for s, c in s_li:
    if flag[s - 1] == 0:
        ans[s - 1] = '{}'.format(c)
        flag[s - 1] = 1
    elif flag[s - 1] == 1 and int(ans[s - 1]) == c:
        continue
    else:
        ans = ['-1']
        break

ans = int(('').join(ans))

if n != 1 and (ans // 10**(n - 1)) == 0:
    ans = -1

print(ans)

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

if n != 1:
    ans = ['1']
    ans.extend(['0'] * (n - 1))
else:
    ans = ['0']
flag = [0] * n

for s, c in s_li:
    if flag[s - 1] == 0:
        ans[s - 1] = '{}'.format(c)
        flag[s - 1] = 1
    elif flag[s - 1] == 1 and int(ans[s - 1]) == c:
        continue
    else:
        ans = ['-1']
        break

ans = int(('').join(ans))

if n != 1 and (ans // 10**(n - 1)) == 0:
    ans = -1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def mod_pow(x, n, mod):
    if n == 0:
        return 1
    if n % 2 == 1:
        return x * mod_pow(x, n - 1, mod) % mod
    else:
        return mod_pow(x, n // 2, mod) ** 2 % mod

def choose(n, m, mod):
    x, y = 1, 1
    for i in range(m):
        x *= (n - i) % mod
        y *= (i + 1) % mod
    return x * mod_pow(y, mod - 2, mod) % mod

n, a, b = map(int, input().split())
mod = 10 ** 9 + 7

ans = (mod_pow(2, n, mod) - 1 - choose(n, a, mod) - choose(n, b, mod)) % mod
print(ans)

Fixed submission:
def choose(n, m, mod):
    x, y = 1, 1
    for i in range(m):
        x = x * (n - i) % mod
        y = y * (i + 1) % mod
    return x * pow(y, mod - 2, mod) % mod

n, a, b = map(int, input().split())
mod = 10 ** 9 + 7

ans = (pow(2, n, mod) - 1 - choose(n, a, mod) - choose(n, b, mod)) % mod
print(ans)
Buggy python submission (verdict: Runtime Error):
from bisect import bisect_left

def binsearch(l, r, fn):
    while r - l > 1:
        m = (l + r) // 2
        if fn(m):
            l = m
        else:
            r = m
    return l

n, k = map(int, input().split())
A = sorted(list(map(int, input().split())))
p = bisect_left(A, 0)
an = A[:p]
ap = A[p:]

if k < p * (n - p):
    def helper(x):
        t = 0
        r = 0
        for p in ap:
            while t < len(an) and an[t] * p <= x:
                t += 1
            r += t
        return r < k
    l = binsearch(ap[-1] * an[0] - 1, 1, helper)
else:
    k -= p * (n - p)
    an.reverse()
    def helper(x):
        r = 0
        for a in [ap, an]:
            t = len(a) - 1
            for i, p in enumerate(a):
                if t <= i:
                    break
                while t > i and a[t] * p > x:
                    t -= 1
                r += t - i
            return r < k
        m = ap[-1]
        if an:
            m = max(m, -an[-1])
        l = binsearch(-1, m * m, helper)
print(l + 1)

Fixed submission:
a, b, c = map(int, input().split())
ans = 'Yes' if len(set([a, b, c])) == 2 else 'No'
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import deque
n = input()
k = int(input())
a = [int(n[i]) for i in range(min(k, len(n)))]
n = len(n)

if k > n:
    ans = 0
elif k == 1:
    # n 桁目に非負整数
    ans += a[0]
    # n 桁目以外に非負整数
    ans += (n - 1)*9
elif k == 2:
    # 上と同様
    ans += a[1] + (n - 2)*9
    # n 桁目の最大ではない非負整数と n-1 桁目以降に 1 つ非負整数
    ans += (a[0] - 1)*(n - 1)*9
    # n-1 桁目以降の中から 2 つ非負整数
    ans += (n - 1)*(n - 2)*9*9//2
else:
    # 上と同様
    ans += a[2] + (n - 3)*9 + (n - 2)*(n - 3)*9*9//2
    if a[1] != 0:
        ans += (a[1] - 1)*(n - 2)*9
    # n 桁目の最大でない非負整数と n-1 桁目以降に 2 つ非負整数
    ans += (a[0] - 1)*(n - 1)*(n - 2)*9*9//2
    # n-1 桁目以降から 3 つ非負整数
    ans += (n - 1)*(n - 2)*(n - 3)*9*9*9//6
print(ans)

Fixed submission:
from collections import deque
n = input()
a = [int(i) for i in list(n)]
k = int(input())
n = len(n)
ans = 0

if k > n:
    ans = 0
elif k == 1:
    # n 桁目に非負整数
    ans += a[0]
    # n 桁目以外に非負整数
    ans += (n - 1)*9
elif k == 2:
    # 上と同様
    for i in range(1, n):
        if a[i] != 0:
            j = i
            break
    else:
        j = n - 1
    ans += a[j] + (n - j - 1)*9
    # n 桁目の最大ではない非負整数と n-1 桁目以降に 1 つ非負整数
    ans += (a[0] - 1)*(n - 1)*9
    # n-1 桁目以降の中から 2 つ非負整数
    ans += (n - 1)*(n - 2)*9*9//2
else:
    # 上と同様
    j, l= -1, n - 1
    for i in range(1, n):
        if a[i] != 0:
            if j == -1:
                j = i
            else:
                l = i
                break
    if j != -1 and j != n - 1:
        ans += a[l] + (n - l - 1)*9 + (a[j] - 1)*(n - j - 1)*9 + (n - j - 1)*(n - j - 2)*9*9//2
    # n 桁目の最大でない非負整数と n-1 桁目以降に 2 つ非負整数
    ans += (a[0] - 1)*(n - 1)*(n - 2)*9*9//2
    # n-1 桁目以降から 3 つ非負整数
    ans += (n - 1)*(n - 2)*(n - 3)*9*9*9//6
print(ans)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
p_li, s_li = [], []
for _ in range(m):
    p, s = input().split()
    p_li.append(int(p))
    s_li.append(s)

ac = [0] * n
wa = [0] * n
for i in range(m):
    p, s = p_li[i] - 1, s_li[i]
    if s == 'AC':
        ac[p] += 1
    elif ac[p] == 0:
        wa[p] += 1
    else:
        continue
n_ac, n_wa = 0, 0
for i in range(n):
    if ac[i] != 0:
        n_ac += 1
        n_wa += wa[i]
print('{} {}'.format(ans[0], ans[1]))

Fixed submission:
n, m = map(int, input().split())
p_li, s_li = [], []
for _ in range(m):
    p, s = input().split()
    p_li.append(int(p))
    s_li.append(s)

ac = [0] * n
wa = [0] * n
for i in range(m):
    p, s = p_li[i] - 1, s_li[i]
    if s == 'AC':
        ac[p] += 1
    elif ac[p] == 0:
        wa[p] += 1
    else:
        continue
n_ac, n_wa = 0, 0
for i in range(n):
    if ac[i] != 0:
        n_ac += 1
        n_wa += wa[i]
print('{} {}'.format(n_ac, n_wa))
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a_li = list(map(int, input().split()))
a_li = [a // 2 for a in a_li]

from math import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)

def even_or_odd(a):
    parity = 'even' if a % 2 == 0 else 'odd'
    return parity

a_lcm = 1
parity = even_or_odd(a_li[0])
flag = False
for a in a_li:
    if parity != even_or_odd(a):
        flag = True
        break
    a_lcm = lcm(a, a_lcm)

if flag:
    ans = 0
elif parity == 'even':
    if a_lcm % 2 == 0:
        ans = m // a_lcm
    else:
        ans = 0
else:
    ans = m // a_lcm
    if a_lcm % 2 == 0:
        ans = ans // 2
    else:
        ans = ans // 2 + 1 if ans % 2 == 1 else ans // 2
print(ans)


Fixed submission:
n, m = map(int, input().split())
a_li = list(map(int, input().split()))
# すべてのaを2で割る
a_li = [a // 2 for a in a_li]

from fractions import gcd

def lcm(x, y):
    return (x * y) // gcd(x, y)

def count_div_2(a):
    cnt = 0
    while a % 2 == 0:
        a = a // 2
        cnt += 1
    return cnt

# a_lcm: aの最小公倍数, parity: すべてのaの偶奇性, cnt_div: すべてのaの2で割れる回数
a_lcm = 1
cnt_div = count_div_2(a_li[0])

# a_lcmを求める
flag = False
for a in a_li:
    a_lcm = lcm(a, a_lcm)
    # 偶奇が不一致、またはa_lcmがm以上の場合答えなし
    if cnt_div != count_div_2(a) or a_lcm > m:
        flag = True
        break

# 先程弾いた場合以外で答えを出す
if flag:
    ans = 0
else:
    ans = m // a_lcm
    ans = ans // 2 + ans % 2

print(ans)
Buggy python submission (verdict: Runtime Error):
import sys

n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()

win_choice = {'s':'r', 'p':'s', 'r':'p'}
janken_point = {'r':r, 's':s, 'p':p}

dp = []
# a: 相手の手, x:自分が出せない手
def point(a, x=None):
    if x == win_choice[a]: return 0
    else: return janken_point[win_choice[a]]

def total_score(i, cnt, x=None):
    if cnt == 0:
        return 0
    else:
        a = t[(cnt - 1) * k + i]
        a_next = t[(cnt - 2) * k + i] if cnt > 1 else None
        choice = win_choice[a]
        if a == a_next and point(a, x) != 0:
            return point(a, x) + total_score(i, cnt - 1, choice)
        else:
            return point(a, x) + total_score(i, cnt - 1)

sys.setrecursionlimit(n + 1)
r = [0] * k
for i in range(n):
    i = i % k
    r[i] += 1

score = 0
for i in range(k):
    cnt = r[i]
    score += total_score(i, cnt)

print(score)

Fixed submission:
import sys

n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()

win_choice = {'s':'r', 'p':'s', 'r':'p'}
janken_point = {'r':r, 's':s, 'p':p}

dp = []
# a: 相手の手, x:自分が出せない手
def point(a, x=None):
    if x == win_choice[a]: return 0
    else: return janken_point[win_choice[a]]

score = 0
flag = [('0', 1)] * k
for i in range(n):
    if flag[i % k][0] != t[i]:
        score += point(t[i])
        flag[i % k] = (t[i], -1)
    elif flag[i % k][0] == t[i] and flag[i % k][1] == 1:
        score += point(t[i])
        flag[i % k] = (t[i], -1)
    else:
        flag[i % k] = (t[i], 1)

print(score)

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()

win_choice = {'s':'r', 'p':'s', 'r':'p'}
janken_point = {'r':r, 's':s, 'p':p}

# a: 相手の手, x:自分が出せない手
def point(a, x=None):
    if x == win_choice[a]: return 0
    else: return janken_point[win_choice[a]]

def total_score(i, cnt, x=None):
    if cnt == 0:
        return 0
    else:
        a = t[(cnt - 1) * k + i]
        choice = win_choice[a]
        return max(point(a, x) + total_score(i, cnt - 1, choice), total_score(i, cnt - 1))

r = [0] * k
for i in range(n):
    i = i % k
    r[i] += 1

score = 0
for i in range(k):
    cnt = r[i]
    score += total_score(i, cnt)

print(score)

Fixed submission:
import sys

n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()

win_choice = {'s':'r', 'p':'s', 'r':'p'}
janken_point = {'r':r, 's':s, 'p':p}

dp = []
# a: 相手の手, x:自分が出せない手
def point(a, x=None):
    if x == win_choice[a]: return 0
    else: return janken_point[win_choice[a]]

score = 0
flag = [('0', 1)] * k
for i in range(n):
    if flag[i % k][0] != t[i]:
        score += point(t[i])
        flag[i % k] = (t[i], -1)
    elif flag[i % k][0] == t[i] and flag[i % k][1] == 1:
        score += point(t[i])
        flag[i % k] = (t[i], -1)
    else:
        flag[i % k] = (t[i], 1)

print(score)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import sys
n = int(input())
a = np.array(sys.stdin.read().split(), dtype=np.int64)
mod = 10 ** 9 + 7
ans = [0] * 60
for x in a:
    x = bin(x)[2:].zfill(60)
    for i in range(60):
        ans[i] += int(x[i])
for i in range(60):
    ans[i] = ans[i] * (n - ans[i]) % mod
    ans[i] = ans[i] * pow(2, 59 - i, mod) % mod
ans_sum = 0
for x in ans:
    ans_sum = (ans_sum + x) % mod
print(ans_sum)

Fixed submission:
import numpy as np
import sys
n = int(input())
a = np.array(sys.stdin.read().split(), dtype=np.int64)
mod = 10 ** 9 + 7
ans = 0
for i in range(63):
    b = (a >> i) & 1
    x = np.count_nonzero(b)
    x = x * (n - x)
    ans += x * pow(2, i, mod) % mod
print(ans % mod)

Buggy python submission (verdict: Runtime Error):
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())), dtype=np.int64)
mod = 10 ** 9 + 7
ans = [0] * 60
for x in a:
    x = bin(x)[2:].zfill(60)
    for i in range(60):
        ans[i] += int(x[i])
for i in range(60):
    ans[i] = ans[i] * (n - ans[i]) % mod
    ans[i] = ans[i] * pow(2, 59 - i, mod) % mod
ans_sum = 0
for x in ans:
    ans_sum = (ans_sum + x) % mod
print(ans_sum)

Fixed submission:
import numpy as np
import sys
n = int(input())
a = np.array(sys.stdin.read().split(), dtype=np.int64)
mod = 10 ** 9 + 7
ans = 0
for i in range(63):
    b = (a >> i) & 1
    x = np.count_nonzero(b)
    x = x * (n - x)
    ans += x * pow(2, i, mod) % mod
print(ans % mod)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())), dtype=np.int64)
mod = 10 ** 9 + 7
ans = [0] * 60
for x in a:
    x = bin(x)[2:].zfill(60)
    for i in range(60):
        ans[i] += int(x[i])
for i in range(60):
    ans[i] = ans[i] * (n - ans[i]) % mod
    ans[i] = ans[i] * pow(2, 59 - i, mod) % mod
ans_sum = 0
for x in ans:
    ans_sum = (ans_sum + x) % mod
print(ans_sum)

Fixed submission:
import numpy as np
import sys
n = int(input())
a = np.array(sys.stdin.read().split(), dtype=np.int64)
mod = 10 ** 9 + 7
ans = 0
for i in range(63):
    b = (a >> i) & 1
    x = np.count_nonzero(b)
    x = x * (n - x)
    ans += x * pow(2, i, mod) % mod
print(ans % mod)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
ans = [0] * 60
for x in a:
    x = bin(x)[2:].zfill(60)
    for i in range(60):
        ans[i] += int(x[i])
for i in range(60):
    ans[i] = ans[i] * (n - ans[i]) % mod
    ans[i] = ans[i] * pow(2, 59 - i, mod) % mod
ans_sum = 0
for x in ans:
    ans_sum = (ans_sum + x) % mod
print(ans_sum)

Fixed submission:
import numpy as np
import sys
n = int(input())
a = np.array(sys.stdin.read().split(), dtype=np.int64)
mod = 10 ** 9 + 7
ans = 0
for i in range(63):
    b = (a >> i) & 1
    x = np.count_nonzero(b)
    x = x * (n - x)
    ans += x * pow(2, i, mod) % mod
print(ans % mod)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int, input().split()))
l.sort()

def check(x, a):
    if a < x:
        return True
    else:
        return False

def bin_search(x, ok, ng, l):
    while ng - ok > 1:
        mid = (ng + ok) // 2
        if check(x, l[mid]):
            ok = mid
        else:
            ng = mid
    return ok + 1

ans = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        ans += bin_search(l[i] + l[j], -1, n - j - 1, l[j + 1:])
print(ans)

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

def check(x, a):
    if a < x:
        return True
    else:
        return False

def bin_search(x, ok, ng, l):
    while ng - ok > 1:
        mid = (ng + ok) // 2
        if check(x, l[mid]):
            ok = mid
        else:
            ng = mid
    return ok + 1

ans = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        ans += bin_search(l[i] + l[j], -1, n - j - 1, l[j + 1:])
print(ans)
Buggy python submission (verdict: Runtime Error):
from fracions import gcd
from collections import deque

a, b = map(int, input().split())
x = gcd(a, b)
y = int(x ** 0.5)
cd = deque([])
if x ** 0.5 % 1 == 0:
    cd.append(y)
    y -= 1
prime = []
for i in range(y, 0, -1):
    if x % i == 0:
        cd.appendleft(i)
        cd.append(x // i)

def prime_check(x, prime):
    for y in prime:
        if x % y == 0:
            return False
    return True

for x in cd:
    if prime_check(x, prime) and x != 1:
        prime.append(x)
print(len(prime) + 1)

Fixed submission:
from fractions import gcd
from collections import deque

a, b = map(int, input().split())
x = gcd(a, b)
y = int(x ** 0.5)
cd = deque([])
if x ** 0.5 % 1 == 0:
    cd.append(y)
    y -= 1
prime = []
for i in range(y, 0, -1):
    if x % i == 0:
        cd.appendleft(i)
        cd.append(x // i)

def prime_check(x, prime):
    for y in prime:
        if x % y == 0:
            return False
    return True

for x in cd:
    if prime_check(x, prime) and x != 1:
        prime.append(x)
print(len(prime) + 1)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
cnt = 0
while cnt < m:
    x = a.pop()
    x = x // 2
    cnt += 1
    if len(a) == 0 or x > a[-1]:
        a.append(x)
    else:
        bisect.insort_left(a, x)
print(sum(a))

Fixed submission:
import heapq
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [-1 * i for i in a]
heapq.heapify(a)
cnt = 0
while cnt < m:
    x = heapq.heappop(a) * -1
    x = x // 2
    cnt += 1
    heapq.heappush(a, x * -1)
print(sum(a) * -1)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
cnt = 0
while cnt < m:
    x = a.pop()
    x = x // 2
    cnt += 1
    if len(a) == 0 or x > a[-1]:
        a.append(x)
    else:
        bisect.insort_left(a, x)
print(sum(a))

Fixed submission:
import heapq
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [-1 * i for i in a]
heapq.heapify(a)
cnt = 0
while cnt < m:
    x = heapq.heappop(a) * -1
    x = x // 2
    cnt += 1
    heapq.heappush(a, x * -1)
print(sum(a) * -1)

Buggy python submission (verdict: Runtime Error):
from collections import deque
import bisect
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = deque(sorted(a))
cnt = 0
while cnt < m:
    x = a.pop()
    x = x // 2
    cnt += 1
    if len(a) == 0 or x > a[-1]:
        a.append(x)
    else:
        bisect.insort_left(a, x)
print(sum(a))

Fixed submission:
import heapq
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [-1 * i for i in a]
heapq.heapify(a)
cnt = 0
while cnt < m:
    x = heapq.heappop(a) * -1
    x = x // 2
    cnt += 1
    heapq.heappush(a, x * -1)
print(sum(a) * -1)
Buggy python submission (verdict: Runtime Error):
n = input()
print(n ** 3)

Fixed submission:
n = int(input())
print(n ** 3)
Buggy python submission (verdict: Runtime Error):
n = int(input())
h_list = list(int, input().split())

ans, cnt = 0, 0
tmp = 0
for h in h_list:
    if h > tmp:
        ans = max(cnt, ans)
        cnt = 0
    else:
      cnt += 1
      tmp = h
print(max(cnt, ans))


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

ans, cnt = 0, 0
tmp = 0
for h in h_list:
    if h > tmp:
        ans = max(cnt, ans)
        cnt = 0
    else: cnt += 1
    tmp = h
        
print(max(cnt, ans))

Buggy python submission (verdict: Runtime Error):
n = int(input())
h_list = list(int, input().split())

ans, cnt = 0, 0
tmp = 0
for h in h_list:
    if h > tmp:
        ans = max(cnt, ans)
        cnt = 0
    else: cnt += 1
print(max(cnt, ans))

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

ans, cnt = 0, 0
tmp = 0
for h in h_list:
    if h > tmp:
        ans = max(cnt, ans)
        cnt = 0
    else: cnt += 1
    tmp = h
        
print(max(cnt, ans))
Buggy python submission (verdict: Runtime Error):
from math import gcd
a, b, c, d = map(int, input().split())

e = (c * d) // gcd(c, d)

c_min = a + (c - a % c) if (a % c) != 0 else a
c_max = b - b % c
d_min = a + (d - a % d) if (a % d) != 0 else a
d_max = b - b % d
e_min = a + (e - a % e) if (a % e) != 0 else a
e_max = b - b % e

n_c = (c_max - c_min) // c + 1 if c_min <= c_max else 0
n_d = (d_max - d_min) // d + 1 if d_min <= d_max else 0
n_e = (e_max - e_min) // e + 1 if e_min <= e_max else 0

ans = b - a + 1 - n_c - n_d + n_e

print(ans)


Fixed submission:
from fractions import gcd
a, b, c, d = map(int, input().split())

e = (c * d) // gcd(c, d)

c_min = a + (c - a % c) if (a % c) != 0 else a
c_max = b - b % c
d_min = a + (d - a % d) if (a % d) != 0 else a
d_max = b - b % d
e_min = a + (e - a % e) if (a % e) != 0 else a
e_max = b - b % e

n_c = (c_max - c_min) // c + 1 if c_min <= c_max else 0
n_d = (d_max - d_min) // d + 1 if d_min <= d_max else 0
n_e = (e_max - e_min) // e + 1 if e_min <= e_max else 0

ans = b - a + 1 - n_c - n_d + n_e

print(ans)