Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
n = int(input())
x, y = [], []
for _i in range(n):
    s = input()
    p = 0
    m = 0
    for j in range(len(s)):
        if s[j]=="(":
            p += 1
        else:
            p -= 1
            m, _m = sorted([p, m])
    if p > 0:
        x.append([m, p])
    else:
        y.append([m-p, -p])

x.sort(reverse=True)
y.sort(reverse=True)
r = 0
for s, t in x:
    if r+s < 0:
        print("No")
        sys.exit()
    r += t
result = 0
for s, t in y:
    if result+s < 0:
        print("No")
        sys.exit()
    result += t
if r-result == 0:
    print("Yes")
else:
    print("No")

Fixed submission:
import sys
n = int(input())
x, y = [], []
for _i in range(n):
    s = input()
    p = 0
    m = [0]
    for j in range(len(s)):
        if s[j]=="(":
            p += 1
        else:
            p -= 1
            m.append(p)
    if p > 0:
        x.append([min(m), p])
    else:
        y.append([min(m)-p, -p])

x.sort(reverse=True)
y.sort(reverse=True)
r = 0
for s, t in x:
    if r+s < 0:
        print("No")
        sys.exit()
    r += t
result = 0
for s, t in y:
    if result+s < 0:
        print("No")
        sys.exit()
    result += t
if r-result == 0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import sys
x = int(input())
result = [1,1]
for i in range(10**8+1):
    for j in range(10**8+1):
        if x == pow(i, 5)+pow(j, 5):
            result = [i, -j]
            print(*result)
            sys.exit()
print(*result)

Fixed submission:
import sys
x = int(input())
result = [1,1]
for i in range(-1000,1000):
    for j in range(-1000,1000):
        if x == pow(i, 5)-pow(j, 5):
            result = [i, j]
            print(*result)
            sys.exit()
print(*result)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
i, j = [], []
for s in range(n):
    num = s+1
    i.append(a[s]+num)
    j.append(num-a[s])
result = 0
for p in range(n-1):
    result += j[p+1:].count(i[p])
print(result)

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
i, j = [], []
for s in range(n):
    num = s+1
    i.append(a[s]+num)
    j.append(num-a[s])
x = Counter(j)
result = 0
for p in range(n-1):
    if i[p] in x:
        result += x[i[p]]
    x[j[p]] += 1 
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
a, b, n = map(int, input().split())

if b == 1:
    r = [0]
else:
    i = 0
    r = []
    while b*i-1 <= n:
        r.append(int((a*(b*i-1))/b)-a*int((b*i-1)/b))
print(max(r))

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

if b == 1:
    r = [0]
else:
    i = 0
    r = [int((a*n)/b)-a*int(n/b)]
    while b*i-1 <= n:
        r.append(int((a*(b*i-1))/b)-a*int((b*i-1)/b))
        i += 1
print(max(r))

Buggy python submission (verdict: Runtime Error):
a, b, n = map(int, input().split())

if b == 1:
    r = [0]
else:
    i = 0
    while b*i-1 <= n:
        r.append(int((a*(b*i-1))/b)-a*int((b*i-1)/b))
print(max(r))

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

if b == 1:
    r = [0]
else:
    i = 0
    r = [int((a*n)/b)-a*int(n/b)]
    while b*i-1 <= n:
        r.append(int((a*(b*i-1))/b)-a*int((b*i-1)/b))
        i += 1
print(max(r))

Buggy python submission (verdict: Time Limit Exceeded):
a, b, n = map(int, input().split())
result = []
for i in range(10**8):
    result.append((a*n)//b - a*(n//b))
    n -= 1
    if n < 0:
        break
print(max(result))

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

if b == 1:
    r = [0]
else:
    i = 0
    r = [int((a*n)/b)-a*int(n/b)]
    while b*i-1 <= n:
        r.append(int((a*(b*i-1))/b)-a*int((b*i-1)/b))
        i += 1
print(max(r))
Buggy python submission (verdict: Runtime Error):
use std::io::stdin;
fn main() {
    let mut st = String::new();
    stdin().read_line(&mut st).unwrap();
    let s:Vec<char> = st.trim().chars().collect();
    let mut ten = 1;
    let mut c:usize = 0;
    let mut r:[i64;2020] = [0;2020];
    let m = s.len() as usize;
    for i in 1..m+1 {
        let mut x = s[m-i] as usize;
        x -= 48;
        c = (c+(x*ten)%2019)%2019;
        r[c] += 1;
        ten = (ten*10)%2019;
    };
    let mut result:i64 = 0;
    for i in 0..2019 {
        if &1 < &r[i] {
            result += (r[i]-1)*r[i]/2
        };
    };
    result += r[0];
    println!("{}", result);
}

Fixed submission:
s = input()
x = list(map(int, list(s)))
x = x[::-1]
dic = [0 for _ in range(2020)]
ten = 1
y = 0
for i in range(len(s)):
    y = (y+ten*x[i])%2019
    dic[y] += 1
    ten = (ten*10)%2019
result = 0
for i in range(2019):
    result += max([dic[i]*(dic[i]-1)//2, 0])
result += dic[0]
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
c = [[0,0,0] for _ in range(n+1)]
if n<3:
    result = 0
else:
    for i in range(1, n+1):
        if s[-i]=="R":
            c[i][0] += 1
        elif s[-i]=="G":
            c[i][1] += 1
        else:
            c[i][2] += 1
        for j in range(3):
            c[i][j] += c[i-1][j]
    c = c[::-1]
    s = s+"0"*(n+1)
    result = 0
    for i in range(n-1):
        if s[i]=="R":
            for j in range(i+1, n):
                if s[j]=="G":
                    result += c[j][2] - ("B"==s[2*j-i])
                elif s[j]=="B":
                    result += c[j][1] - ("G"==s[2*j-i])
        if s[i]=="G":
            for j in range(i+1, n):
                if s[j]=="R":
                    result += c[j][2] - ("B"==s[2*j-i])
                elif s[j]=="B":
                    result += c[j][0] - ("R"==s[2*j-i])
        if s[i]=="B":
            for j in range(i+1, n):
                if s[j]=="G":
                    result += c[j][0] - ("R"==s[2*j-i])
                elif s[j]=="R":
                    result += c[j][1] - ("G"==s[2*j-i])
print(result)

Fixed submission:
n = int(input())
s = input()
c = [[0,0,0] for _ in range(n+1)]
if n<3:
    result = 0
else:
    for i in range(1, n+1):
        if s[-i]=="R":
            c[i][0] += 1
        elif s[-i]=="G":
            c[i][1] += 1
        else:
            c[i][2] += 1
        for j in range(3):
            c[i][j] += c[i-1][j]
    c = c[::-1]
    s = s+"0"*(n+1)
    result = 0
    for i in range(n-1):
        if s[i]=="R":
            for j in range(i+1, n):
                if s[j]=="G":
                    result += c[j][2] - ("B"==s[2*j-i])
                elif s[j]=="B":
                    result += c[j][1] - ("G"==s[2*j-i])
        if s[i]=="G":
            for j in range(i+1, n):
                if s[j]=="R":
                    result += c[j][2] - ("B"==s[2*j-i])
                elif s[j]=="B":
                    result += c[j][0] - ("R"==s[2*j-i])
        if s[i]=="B":
            for j in range(i+1, n):
                if s[j]=="G":
                    result += c[j][0] - ("R"==s[2*j-i])
                elif s[j]=="R":
                    result += c[j][1] - ("G"==s[2*j-i])
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
mod = 10**9+7
result = 0
memo = [0 for _ in range(k+1)]
for i in range(k, 0, -1):
    z = 1
    y = k//i
    for j in range(n):
        z = (z*y)%mod
    j = 2
    while j*i <= k:
        z -= memo[j*i]
        j += 1
    memo[i] = z
    result = (result+z*i)%mod
print(result)

Fixed submission:
n, k = map(int, input().split())
mod = 10**9+7
result = 0
memo = [0 for _ in range(k+1)]
for i in range(k, 0, -1):
    y = k//i
    z = pow(y, n, mod)
    j = 2
    while j*i<=k:
        z -= memo[j*i]
        z %= mod
        j += 1
    memo[i] = z
    result = (result+z*i)%mod
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
import heapq
x, y, a, b, c = map(int,input().split())

p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
p = p[:x]
q = q[:y]

p = [-i for i in p]
q = [-i for i in q]
r = [-i for i in r]


result = [0]
for i in range(min(x+y+1, c+1)):
    hq = p+q+r[:i]
    heapq.heapify(hq)
    for j in range(x+y):
        result[-1] -= heapq.heappop(hq)
    result.append(0)
print(max(result))

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

p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
rr = [0]
for i in r:
    rr.append(rr[-1]+i)
p = p[:x]
q = q[:y]
pq = sorted(p+q)
ppqq = [sum(pq)]
for i in pq:
    ppqq.append(ppqq[-1]-i)
result = []
for i in range(min(x+y, c+1)):
    result.append(ppqq[i]+rr[i])
print(max(result))
Buggy python submission (verdict: Runtime Error):
l = int(input())

result = []
for i in range(1,10**3):
    for j in range(i, 10**3):
        if l-i-j > 0:
            result.append(i*j*(l-i-j))
print(max(result))

Fixed submission:
l = int(input())

print((l**3)/27)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = list(Counter(a).items())

for i in range(n):
    r = 0
    for x, y in c:
        if x == a[i]:
            r += max(((y-1)*(y-2)//2), 0)
        else:
            r += (y-1)*y //2
    print(r)

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
x = []
r = 0
for x, y in c.items():
    r += (y-1)*y//2

for i in range(n):
    print(r-(c[a[i]]-1))
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
for i in range(q):
    que = list(input().split())
    if que[0] == "1":
        s = s[::-1]
    else:
        if que[1]=="1":
            s = que[2]+s
        else:
            s = s+que[2]
print(s)


Fixed submission:
from collections import deque
s = deque(list(input()))
q = int(input())
que = [list(input().split()) for _ in range(q)]
counter = 0
for i in que:
    if i[0] == "1":
        counter += 1
    else:
        if (counter+int(i[1]))%2==1:
            s.appendleft(i[-1])
        else:
            s.append(i[-1])
if counter%2==0:
    print("".join(list(s)))
else:
    print("".join(list(s)[::-1]))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
for i in range(q):
    que = list(input().split())
    if que[0] == "1":
        s = s[::-1]
    else:
        if que[1]=="1":
            s = que[2]+s
        else:
            s = s+que[2]
print(s)

Fixed submission:
from collections import deque
s = deque(list(input()))
q = int(input())
que = [list(input().split()) for _ in range(q)]
counter = 0
for i in que:
    if i[0] == "1":
        counter += 1
    else:
        if (counter+int(i[1]))%2==1:
            s.appendleft(i[-1])
        else:
            s.append(i[-1])
if counter%2==0:
    print("".join(list(s)))
else:
    print("".join(list(s)[::-1]))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

s = [str(input()) for i in range(n)]

from collections import Counter
c = Counter(s)

result = [i[0] for i in c.items() if i[1]==max(c.values())]
result.sort()


for i in range(len(result)):
    print(result[i])

Fixed submission:
n = int(input())
 
s = [str(input()) for i in range(n)]
 
from collections import Counter
c = Counter(s)

max_num = max(c.values())

result = [i[0] for i in c.items() if i[1]==max_num]
result.sort()
 
for i in range(len(result)):
    print(result[i])

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

s = [str(input()) for i in range(n)]

from collections import Counter
c = Counter(s)

result = [i[0] for i in c.items() if i[1]==max(c.values())]
result = sorted(result)

for i in range(len(result)):
    print(result[i])

Fixed submission:
n = int(input())
 
s = [str(input()) for i in range(n)]
 
from collections import Counter
c = Counter(s)

max_num = max(c.values())

result = [i[0] for i in c.items() if i[1]==max_num]
result.sort()
 
for i in range(len(result)):
    print(result[i])
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())

p = list(map(int, input().split()))

def kitaiti(num):
    result = (num+1)*num/(num*2)
    return result
r = [kitaiti(p[i]) for i in range(n)]

result = []
for i in range(n-k+1):
    result.append(sum(r[i:i+k]))
print(max(result))

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

p = list(map(int, input().split()))

def kitaiti(num):
    result = (num+1)*num/(num*2)
    return result
r = [kitaiti(p[i]) for i in range(n)]

result = [sum(r[:k])]
for i in range(k, n):
    result.append(result[-1]-r[i-k]+r[i])
print(max(result))
Buggy python submission (verdict: Runtime Error):
import numpy as np
h, n = map(int, input().split())
ab = np.array([list(map(int, input().split())) for _ in range(n)])

a = ab[:, 0]
b = ab[:, 1]

dp = np.zeros(10**9, dtype=np.int)

for i in range(1,h+1):
    dp[i] = min(dp[i-a]+b)

print(dp[h])

Fixed submission:
h, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
dp = [10**5 for _ in range(h+1)]
dp[0] = 0
for i in range(1,h+1):
    dp[i] = min([dp[max(0, i-pw)]+ma for pw, ma in ab])
print(dp[h])

Buggy python submission (verdict: Time Limit Exceeded):
h, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

dp = [10**9 for _ in range(h+1)]
dp[0] = 0
for i in range(1, h+1):
    for a, b in ab:
        if a < i:
            dp[i] = min(dp[i], dp[i-a]+b)
        else:
            dp[i] = min(dp[i], b)
print(dp[h])

Fixed submission:
h, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
dp = [10**5 for _ in range(h+1)]
dp[0] = 0
for i in range(1,h+1):
    dp[i] = min([dp[max(0, i-pw)]+ma for pw, ma in ab])
print(dp[h])

Buggy python submission (verdict: Time Limit Exceeded):
h, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
dp = [-1 for _ in range(h+1)]
dp[0] = 0
for i in range(1,h+1):
    dp[i] = min([dp[max(0, i-pw)]+ma for pw, ma in ab])
print(dp[h])

Fixed submission:
h, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
dp = [10**5 for _ in range(h+1)]
dp[0] = 0
for i in range(1,h+1):
    dp[i] = min([dp[max(0, i-pw)]+ma for pw, ma in ab])
print(dp[h])

Buggy python submission (verdict: Time Limit Exceeded):
h, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
dp = [10**5 for _ in range(h+1)]
dp[0] = 0
for i in range(1,h+1):
    dp[i] = min([dp[max(0, i-pw)]+ma for pw, ma in ab])
print(dp[h])

Fixed submission:
h, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
dp = [10**5 for _ in range(h+1)]
dp[0] = 0
for i in range(1,h+1):
    dp[i] = min([dp[max(0, i-pw)]+ma for pw, ma in ab])
print(dp[h])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
result = 0
for i in range(1000):
    x = format(i, "03")
    p = 0
    for j in range(n):
        if s[j]==x[p]:
            p += 1
            if p==3:
                result += 1
                break
print(result)

Fixed submission:
n = int(input())
s = list(input())[::-1]
result = 0
for i in range(1000):
    x = format(i, "03")
    j = 0
    p = 0
    while p < n:
        if s[p]==x[j]:
            j += 1
            if j == 3:
                result += 1
                break
        p += 1

print(result)

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = list(map(int, list(input())))
numbers = [0 for _i in range(1000)]
right, left = [[0 for _j in range(10)] for _i in range(n)], [[0 for _j in range(10)] for _i in range(n)]
for i in range(1, n):
    left[i] = left[i-1].copy()
    left[i][s[i-1]] += 1
for i in range(2, n+1):
    right[-i] = right[-i+1].copy()
    right[-i][s[-i+1]] += 1

for i in range(n):
    for x in range(10):
        for y in range(10):
            if right[i][x]>0 and left[i][y]>0:
                numbers[100*x+10*s[i]+y] = 1
print(sum(numbers))

Fixed submission:
n = int(input())
s = list(input())[::-1]
result = 0
for i in range(1000):
    x = format(i, "03")
    j = 0
    p = 0
    while p < n:
        if s[p]==x[j]:
            j += 1
            if j == 3:
                result += 1
                break
        p += 1

print(result)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(input())[::-1]
result = 0
for i in range(1000):
    x = format(i, "03")
    j = 0
    p = 0
    while p < n:
        if s[p]==x[j]:
            j += 1
            if j == 3:
                result += 1
                break
        p += 1

print(result)

Fixed submission:
n = int(input())
s = list(input())[::-1]
result = 0
for i in range(1000):
    x = format(i, "03")
    j = 0
    p = 0
    while p < n:
        if s[p]==x[j]:
            j += 1
            if j == 3:
                result += 1
                break
        p += 1

print(result)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(input())[::-1]
result = 0
for i in range(1000):
    x = format(i, "03")
    j = 0
    p = 0
    while j < 3 and p < n:
        if s[p]==x[j]:
            j += 1
        p += 1
    if j==3:
        result += 1
print(result)

Fixed submission:
n = int(input())
s = list(input())[::-1]
result = 0
for i in range(1000):
    x = format(i, "03")
    j = 0
    p = 0
    while p < n:
        if s[p]==x[j]:
            j += 1
            if j == 3:
                result += 1
                break
        p += 1

print(result)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
h = []
for i in range(n):
    h.append(abs(sum(a[:i])-sum(a[i:])))
print(min(h))

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

result = [[a[0], sum(a[1:])]]
for i in range(1, n):
    result.append([result[-1][0]+a[i], result[-1][1]-a[i]])
h = []
for i in range(len(result)):
    h.append(abs(result[i][0]-result[i][1]))
print(min(h))

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
s = sum(a)
r = 0
counter = 0
while r < s//2:
    r += a[counter]
    counter += 1
x = sum(a[:counter])
y = sum(a[counter+1:])
if x <= y:
    x += a[counter]
else:
    y += a[counter]
print(abs(x-y))

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

result = [[a[0], sum(a[1:])]]
for i in range(1, n):
    result.append([result[-1][0]+a[i], result[-1][1]-a[i]])
h = []
for i in range(len(result)):
    h.append(abs(result[i][0]-result[i][1]))
print(min(h))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split(' ')))
result = []
for i in range(n):
    result.append(a.index(i+1)+1)
print(*result)

Fixed submission:
n = int(input())
a = list(map(int, input().split(' ')))
result = [(a[i], i) for i in range(n)]
result.sort()
out = [result[i][1]+1 for i in range(n)]
print(*out)
Buggy python submission (verdict: Runtime Error):
import math
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
a, b = map(int, input().split(' '))
gc = math.gcd(a, b)
r = []
r = factorization(gc)
if len(r) == 1:
    print(1)
else:
    print(len(r)+1)

Fixed submission:
def gcd(a, b):
    while b!=0:
        a, b = b, a%b
    return a


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
a, b = map(int, input().split(' '))
gc = gcd(a, b)
r = []
r = factorization(gc)
if r[0][0] == 1:
    print(1)
else:
    print(len(r)+1)
Buggy python submission (verdict: Runtime Error):
def main():
    n ,m = map(int, input().split(' '))
    inf = 10**9
    bit_dp = [inf for _ in range(2**(n))]
    bit_dp[0] = 0
    for i in range(m):
        a, b = map(int, input().split(' '))
        c = list(map(int, input().split(' ')))
        bit_n = 0
        for i in c:
            bit_n |= 1 << i-1
        for i in range(2**(n)):
            if bit_dp[i|bit_n] > bit_dp[i] + a:
            bit_dp[i|bit_n] = bit_dp[i] + a
    if bit_dp[-1] >= inf:
        print(-1)
    else:
        print(bit_dp[-1])
if __name__ == '__main__':
    main()

Fixed submission:
n, m = map(int, input().split(' '))
dp = [10**9 for _ in range(2**n)]
dp[0] = 0
for i in range(m):
    a, b = map(int, input().split(' '))
    c = list(map(int, input().split(' ')))
    num = 0
    for j in range(b):
        num += 1 << (c[j]-1)
    for s in range(2**n):
        if dp[s|num] >= dp[s] + a:
            dp[s|num] = dp[s] + a
if dp[-1] == 10**9:
    print(-1)
else:
    print(dp[-1])
Buggy python submission (verdict: Runtime Error):
def main():
    from heapq import heapify, heappush, heappop
    from math import floor
    n, m = list(map(int, input().split(' ')))
    a = list(map(int, input().split(' ')))
    a = [x*(-1) for x in a]
    heapify(a)
    for _ in range(m):
        x = floor(-heappop(a)/2)*(-1)
        heappush(a, x)
     
    print(-sum(a))
main()

Fixed submission:
s = str(input())
if s == 'Sunny':
    print('Cloudy')
elif s == 'Cloudy':
    print('Rainy')
else:
    print('Sunny')
Buggy python submission (verdict: Time Limit Exceeded):
import math
#math.floor
n, m = list(map(int, input().split(' ')))
a = list(map(int, input().split(' ')))
for i in range(m):
    a[a.index(max(a))] = a[a.index(max(a))]/2
result = 0
for i in a:
    result += math.floor(i)
print(result)

Fixed submission:
from heapq import heapify, heappush, heappop
from math import floor
n, m = list(map(int, input().split(' ')))
a = list(map(int, input().split(' ')))
a = [x*(-1) for x in a]
heapify(a)
for _ in range(m):
    x = floor(-heappop(a)/2)*(-1)
    heappush(a, x)

print(-sum(a))

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

n, m = list(map(int, input().split(' ')))
a = list(map(int, input().split(' ')))
for i in range(m):
    b = a.pop(a.index(max(a)))
    b *= 1/2
    a.append(b)
result = 0
for i in a:
    result += math.floor(i)
print(result)

Fixed submission:
from heapq import heapify, heappush, heappop
from math import floor
n, m = list(map(int, input().split(' ')))
a = list(map(int, input().split(' ')))
a = [x*(-1) for x in a]
heapify(a)
for _ in range(m):
    x = floor(-heappop(a)/2)*(-1)
    heappush(a, x)

print(-sum(a))
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
j = 1
y = s[1:]
x = s[0]
result = [0]
end = n//2 + 2
for i in range(end):
    while (j < end) and (x in y):
        x = x+s[j]
        y = s[:i]+s[j+1:]
        j += 1
    result.append(j-i-1)
    y = s[:i+1] + s[j+1:]
    x = x[1:]
print(max(result))

Fixed submission:
n = int(input())
s = input()
j = 1
result = [0]
end = n//2 + 1
for i in range(n):
    while (j < n-1) and (s[i:j] in s[:i]+"0"+s[j:]):
        j += 1
    result.append(j-i-1)
print(max(result))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
result = 0
for i in range(1, n):
    result += i
print(result)

Fixed submission:
n = int(input())
print((n*(n-1))//2)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
mod=10**9+7
print(sum((r+((sum(a[i]>j for j in a[i:])*(k*(k+1)//2)%mod)+(sum(a[i]>j for j in a[:i+1])*(k*(k-1)//2)%mod))%mod)%mod for i in range(n)))

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

mod = 10**9 + 7
x = (k*(k+1)//2)%mod
y = (k*(k-1)//2)%mod

r = 0
for i in range(n):
    right = sum(a[i] > j for j in a[i:])
    left = sum(a[i] > j for j in a[:i+1])
    r = (r+((right*x) + (left*y))%mod)%mod
print(r)