Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import numpy as np
import math

n = int(input())
A = list(map(int, input().split()))
ans = np.prod(A)
l = int(math.log10(ans)+1)
if l >= 18:
    print(-1)
else:
    print(int(ans))
    

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
ans = 1
count = 0
if 0 in A:
    print(0)
else:
    for i in range(n):
        ans *= A[i]
        if ans > 10**18:
            count = 1
            print(-1)
            break
    if count == 0:
        print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
ans = 1
for i in range(n):
    ans *= A[i]
if ans > 10**18:
    print(-1)
else:
    print(ans)
    

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
ans = 1
count = 0
if 0 in A:
    print(0)
else:
    for i in range(n):
        ans *= A[i]
        if ans > 10**18:
            count = 1
            print(-1)
            break
    if count == 0:
        print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
T = str(input())

for i in range(len(T)):
    if T[i] == '?':
        T = T[:i] + 'D' + T[i+1:]
print(T)

Fixed submission:
T = str(input())
print(T.replace('?', 'D'))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

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

for i in np.arange(1, n+1):
    print(A.count(i))

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

ans = [0]*n
for i in A:
    ans[i-1] += 1

for i in range(n):
    print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

K = int(input())

gcd1 = np.sum(np.arange(1,K+1))
gcd2 = 0
gcd3 = 0

for a in np.arange(1,K):
    for b in np.arange(a+1,K+1):
        gcd_ab = np.gcd(a,b)
        gcd2 += gcd_ab
        for c in np.arange(b+1,K+1):
            gcd3 += np.gcd(gcd_ab,c)

print(gcd1 + 6*gcd2 + 6*gcd3)

Fixed submission:
from math import gcd
K = int(input())
sum_gcd = [0]*201
ans = 0
 
for i in range(1,K+1):
  for j in range(1,K+1):
    sum_gcd[gcd(i,j)] += 1
for i in range(1,K+1):
  for k in range(1,K+1):
    ans += sum_gcd[i]*gcd(i,k)
 
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

K = int(input())
gcd = 0

gcd1 = np.sum(np.arange(1,K+1))
gcd2 = 0
gcd3 = 0
for a in np.arange(1,K-1):
    for b in np.arange(a+1,K):
        for c in np.arange(b+1,K+1):
            gcd_bc = np.gcd(b, c)
            gcd3 += np.gcd(a, gcd_bc)

for a in np.arange(1,K):
    for b in np.arange(a+1,K+1):
        gcd2 += np.gcd(a, b)

print(gcd1 + gcd2 * 6 + gcd3 * 6)

Fixed submission:
from math import gcd
K = int(input())
sum_gcd = [0]*201
ans = 0
 
for i in range(1,K+1):
  for j in range(1,K+1):
    sum_gcd[gcd(i,j)] += 1
for i in range(1,K+1):
  for k in range(1,K+1):
    ans += sum_gcd[i]*gcd(i,k)
 
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import copy

n = int(input())
s = str(input())
r_list = []
g_list = []
b_list = []
count = 0
for i in range(len(s)):
    if s[i] == "R":
        r_list.append(i)
    elif s[i] == "G":
        g_list.append(i)
    else:
        b_list.append(i)

for r in r_list:
    for g in g_list:
        x = abs(r-g)
        if max(r,g)+x in b_list:
            count += 1
        if min(r,g)-x in b_list:
            count += 1
        if(r+g)/2 in b_list:
            count += 1
print(len(r_list)*len(g_list)*len(b_list)-count)

Fixed submission:
n = int(input())
s = list(input())
ans = (s.count("R")*s.count("G")*s.count("B"))

for i in range(n):
    for j in range(n-2*i):
        if {s[j], s[j+i], s[j+2*i]} == {"R", "G", "B"}:
            ans -= 1
print(ans)

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

n = int(input())
s = str(input())
r_list = []
g_list = []
b_list = []
count = 0
for i in range(len(s)):
    if s[i] == "R":
        r_list.append(i)
    elif s[i] == "G":
        g_list.append(i)
    else:
        b_list.append(i)

for r in r_list:
    for g in g_list:
        x = abs(r-g)
        b_list_copy = copy.copy(b_list)
        try:
            b_list_copy.remove(max(r,g)+x)
        except ValueError:
            pass
        try:
            b_list_copy.remove(min(r,g)-x)
        except ValueError:
            pass
        try:
            b_list_copy.remove((r+g)/2)
        except ValueError:
            pass
        count += len(b_list_copy)
        
print(count)

Fixed submission:
n = int(input())
s = list(input())
ans = (s.count("R")*s.count("G")*s.count("B"))

for i in range(n):
    for j in range(n-2*i):
        if {s[j], s[j+i], s[j+2*i]} == {"R", "G", "B"}:
            ans -= 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np

A = np.array(list(list(map(int, input().split())) for l in range(3)))
N = int(input())
b = np.array(list(int(input()) for l in range(N)))
bingo = np.zeros((3, 3))
bingo = bingo == 1

for b_i in b:
    hantei = A == b_i
    bingo = np.logical_or(bingo, hantei)

for i in range(3):
    if all(bingo[i]) or all(bingo[:,i]):
        print('Yes')
        exit()

if (bingo[0,0] and bingo[1,1] and bingo[2,2]) or (bingo[0,2] and bingo[1,1] and bingo[3,1]):
    print('Yes')
    exit()

print('No')

Fixed submission:
import numpy as np

A = np.array(list(list(map(int, input().split())) for l in range(3)))
N = int(input())
b = np.array(list(int(input()) for l in range(N)))
bingo = np.zeros((3, 3))
bingo = bingo == 1

for b_i in b:
    hantei = A == b_i
    bingo = np.logical_or(bingo, hantei)

for i in range(3):
    if all(bingo[i]) or all(bingo[:,i]):
        print('Yes')
        exit()

if (bingo[0,0] and bingo[1,1] and bingo[2,2]) or (bingo[0,2] and bingo[1,1] and bingo[2,0]):
    print('Yes')
    exit()

print('No')
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())

ans = [0]*n 

for i in range(m):
    s, c = map(int, input().split())
    if ans[s-1] == 0:
        ans[s-1] = c 
    elif not ans[s-1] == c:
        print(-1)
        break
    if i == m-1:
        if ans[0] == 0:
            print(-1)
        else:
            for j in range(n):
                a = a+ans[j]*(10**(n-j-1))
            print(a)

Fixed submission:
n, m = map(int, input().split())
x = [-1]*n
ans = 0
count = 0
for i in range(m):
    s, c = map(int, input().split())
    if (s==1) and (c==0) and(n!=1):
        count = 1
    if x[s-1]!=-1 and x[s-1]!=c:
        count = 1
    if x[s-1] != c:
        ans += c*(10**(n-s))
    x[s-1] = c

if count==1:
    print(-1)
elif n==1 and ans==0:
    print(0)
elif ans>=10**(n-1):
    print(ans)
else:
    print(ans+10**(n-1))
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p = list(map(int,input().split()))
s = [0] * n

for i in range(n-k+1):
    s[i] = sum(p[i:i+k])

print((k+max(s))/2)

Fixed submission:
n, k = map(int, input().split())
p = list(map(int,input().split()))
s = [0] * (n-k+1)
s_0 = sum(p[0:k])
s[0] = s_0
for i in range(n-k):
    s[i+1] = s[i] + p[k+i] - p[i]

print((k+max(s))/2)

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

ans_b = 0
ans_a = 0

for i in range(n-k+1):
    ans_b = sum(p[i:i+k])
    
    if ans_b > ans_a:
        ans_a = ans_b
print((k+ans_a)/2)

Fixed submission:
n, k = map(int, input().split())
p = list(map(int,input().split()))
s = [0] * (n-k+1)
s_0 = sum(p[0:k])
s[0] = s_0
for i in range(n-k):
    s[i+1] = s[i] + p[k+i] - p[i]

print((k+max(s))/2)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int, input().split()))
counter = 0
ans = 0

for i in range(0, n):
  for j in range(0, i):
    if p[i] > p[j]:
      counter += 1
  if counter == 0:
    ans += 1
  counter = 0
print(ans)   

Fixed submission:
import numpy as np

n = int(input())
P = np.array(list(map(int, input().split())))
T = np.zeros(n)
T[0] = P[0]
for i in np.arange(1,n,1):
    T[i] = min(T[i-1], P[i])
print(np.sum(P==T))
Buggy python submission (verdict: Runtime Error):
import math
n, m = map(int, input().split())
false_count = [1]*n
ans_false_count = [0]*n
ans_success_count = [0]*n

for i in range(m):
    p, s = input().split()
    p = int(p)
    s = str(s)

    if s=='WA':
        false_count[p-1] = false_count[p-1]*2 
    else:
        ans_false_count[p-1] += false_count[p-1]
        ans_success_count[p-1] = 1
        false_count[p-1] = 0

for j in range(n):
    if false_count[j] != 0:
        false_count = math.log(false_count[j],2)
    if ans_false_count [j] != 0:
        ans_false_count[j] = math.log(ans_false_count[j],2)

new_ans_false_count = false_count + ans_false_count
print(sum(ans_success_count), int(sum(new_ans_false_count)))    

Fixed submission:
import math
n, m = map(int, input().split())
false_count = [1]*n
ans_false_count = [0]*n
ans_success_count = [0]*n

for i in range(m):
    p, s = input().split()
    p = int(p)
    s = str(s)

    if s=='WA':
        false_count[p-1] = int(false_count[p-1]*2)
    else:
        ans_false_count[p-1] += int(false_count[p-1])
        ans_success_count[p-1] = 1
        false_count[p-1] = 0

for j in range(n):
    if ans_false_count [j] != 0:
        ans_false_count[j] = math.log(ans_false_count[j],2)

new_ans_false_count = ans_false_count
print(sum(ans_success_count), int(sum(new_ans_false_count)))

Buggy python submission (verdict: Runtime Error):
import math
n, m = map(int, input().split())
false_count = [1]*n
ans_false_count = [0]*n
ans_success_count = [0]*n

for i in range(m):
    p, s = input().split()
    p = int(p)
    s = str(s)

    if s=='WA':
        false_count[p-1] = false_count[p-1]*2 
    else:
        ans_false_count[p-1] += false_count[p-1]
        ans_success_count[p-1] = 1
        false_count[p-1] = 0

false_count = [math.log(i,2) for i in false_count] 

new_ans_false_count = false_count + ans_false_count
print(sum(ans_success_count), int(sum(new_ans_false_count)))    

Fixed submission:
import math
n, m = map(int, input().split())
false_count = [1]*n
ans_false_count = [0]*n
ans_success_count = [0]*n

for i in range(m):
    p, s = input().split()
    p = int(p)
    s = str(s)

    if s=='WA':
        false_count[p-1] = int(false_count[p-1]*2)
    else:
        ans_false_count[p-1] += int(false_count[p-1])
        ans_success_count[p-1] = 1
        false_count[p-1] = 0

for j in range(n):
    if ans_false_count [j] != 0:
        ans_false_count[j] = math.log(ans_false_count[j],2)

new_ans_false_count = ans_false_count
print(sum(ans_success_count), int(sum(new_ans_false_count)))
Buggy python submission (verdict: Runtime Error):
import itertools

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

nlist = list(itertools.permutations(i for i in range(1,n+1)))

ans = abs(index(nlist,p) - index(nlist,q))


Fixed submission:
import itertools

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

nlist = list(itertools.permutations(i for i in range(1,n+1)))

ans = abs(nlist.index(p) - nlist.index(q))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())

while True:
    for i in range(2,int(x**0.5)+1):
        if x%i==0:
            x = x + 1
            break
        else:
            if i == int(x**0.5):
                print(x)
                exit()
            

Fixed submission:
x = int(input())

while True:
    for i in range(2,int(x**0.5)+1):
        if x%i==0:
            x = x + 1
            break
    else:
        print(x)
        exit()

Buggy python submission (verdict: Runtime Error):
x = int(input())

while True:
    for i in range(2,int(x**0.5)+1):
        if x%i==0:
            x = x + 1
            break()
        else:
            if i == x-1:
                print(x)
                exit()
            

Fixed submission:
x = int(input())

while True:
    for i in range(2,int(x**0.5)+1):
        if x%i==0:
            x = x + 1
            break
    else:
        print(x)
        exit()

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

while True:
    for i in range(2,x):
        if x%i==0:
            x = x + 1
            break
        else:
            if i == x-1:
                print(x)
                exit()
            

Fixed submission:
x = int(input())

while True:
    for i in range(2,int(x**0.5)+1):
        if x%i==0:
            x = x + 1
            break
    else:
        print(x)
        exit()

Buggy python submission (verdict: Runtime Error):
import fractions as gcd

a, b = map(int, input().split())
print(a*b // gcd(a,b))

Fixed submission:
x = int(input())

while True:
    for i in range(2,int(x**0.5)+1):
        if x%i==0:
            x = x + 1
            break
    else:
        print(x)
        exit()
Buggy python submission (verdict: Runtime Error):
import fractions as gcd

a, b = map(int, input().split())
print(a*b // gcd(a,b))

Fixed submission:
from fractions import gcd
a,b=map(int,input().split())
 
result=int(a*b//gcd(a,b))
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n, k, q = map(int, input().split())
point = np.array([k]*n)
for i in range(q):
    A = np.array([1]*n)
    number = int(input())-1
    A[number] = 0
    point -= A

for i in range(n):
    if point[i] > 0:
        print('Yes')
    else:
        print("No")


Fixed submission:
import numpy as np

n, k, q = map(int, input().split())
point = np.array([k]*n)
minus = np.array([-q]*n)
for i in range(q):
    A = int(input())
    minus[A-1] +=1
point = point + minus

for i in range(n):
    if point[i] > 0:
        print('Yes')
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
S = [str(sorted(input())) for _ in range(N)]

print(sum(map(lambda x: x * (x - 1) // 2, Counter(S).values())))

Fixed submission:
from collections import Counter
n = int(input())
S = [str(sorted(input())) for _ in range(n)]

print(sum(map(lambda x: x * (x - 1) // 2, Counter(S).values())))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
num = []
count = 0
for i in range(n):
    s = str(input())
    
    num.append(sorted(list(map(ord, list(s)))))
    
    

for i in range(n):
    for j in list(range(i+1,n)):
        if num[i] == num[j]:
            count += 1
print(count)

Fixed submission:
from collections import Counter
n = int(input())
S = [str(sorted(input())) for _ in range(n)]

print(sum(map(lambda x: x * (x - 1) // 2, Counter(S).values())))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [0]*n
num = [[0]*26 for i in range(n)]
count = 0
for i in range(n):
    s[i] = str(input())
    for j in range(10):
        mozi = ord(s[i][j])
        num[i][mozi-97] += 1

for i in range(n):
    for j in list(range(i+1,n)):
        if num[i] == num[j]:
            count += 1    
print(count)

Fixed submission:
from collections import Counter
n = int(input())
S = [str(sorted(input())) for _ in range(n)]

print(sum(map(lambda x: x * (x - 1) // 2, Counter(S).values())))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(int(input()) for i in range(n))

for i in range(n):
    A_copy = A.copy()
    A_copy.pop(i)
    print(max(A_copy))

Fixed submission:
import numpy as np

n = int(input())
A = np.array(list(int(input()) for i in range(n)))
A_sort = np.sort(A)
A_1 = A_sort[n-1]
A_2 = A_sort[n-2]


for i in range(n):
    if A[i] != A_1:
        print(A_1)
    else:
        print(A_2)
Buggy python submission (verdict: Runtime Error):
import numpy as np

L, R = map(int, input().split())
range_L_R = np.array(list(range(L, R+1)))
range_L_R = range_L_R % 2019


if ((R>=673) and (L<=672)) or ((R>=675) and (L<=673)) or 0 in range_L_R:
    print(0)
else:
    print(L*(L+1) % 2019) 

Fixed submission:
L, R = map(int, input().split())

ans = 2018

if R-L>=2019:
    print(0)
else:
    for i in list(range(L, R)):
        for j in list(range(i+1, R+1)):
            ans = min(ans, i*j % 2019)
    print(ans)
Buggy python submission (verdict: Runtime Error):
s = str(input())
ans = 0

for i in 2**(len(s)-1):
    x = s[0]

    for j in range(len(s)-1):
        if (i>>j) & 1:
            x += '+'
        x += s[j+1]
        
    ans += sum(map(int,x.split('+')))
print(ans)

Fixed submission:
s = str(input())
ans = 0

for i in range(2**(len(s)-1)):
    x = s[0]

    for j in range(len(s)-1):
        if (i>>j) & 1:
            x += '+'
        x += s[j+1]
        
    ans += sum(map(int,x.split('+')))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
n = int(input())
P = [int(x) for x in input().split(" ")]

def check(i):
    flag = True
    for j in range(i):
        if P[j] < P[i-1]:
            flag = False
            break
    if flag:
        return 1
    else:
        return 0
ans = 0
for i in range(1,n+1):
    ans += check(i)
print(ans)

Fixed submission:
# coding: utf-8
n = int(input())
P = [int(x) for x in input().split(" ")]
mx = P[0]
ans = 1
for i in range(1,n):
    if mx > P[i]:
        ans += 1
        mx = P[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
n, m = [int(x) for x in input().split(" ")]
ans = 0
pen = 0
prbstate = {}
fins = {}
A = []
for i in range(m):
    A.append(input().split(" "))

for a in A:
    if a[1] == "AC":
        fins.setdefault(a[0], "AC")

for i in range(m):
    p, s = A[i]
    prbstate.setdefault(p, 0)
    if s == "AC":
        prbstate[p] = 1
    if s == "WA" and prbstate[p] == 0 and fins[p] == "AC":
        pen += 1
for x in prbstate.values():
    ans += x
print(ans, pen)

Fixed submission:
# coding: utf-8
n, m = [int(x) for x in input().split(" ")]
ans = 0
pens = 0
prbstate = {}
fins = {}
A = []
for i in range(m):
    A.append(input().split(" "))
for a in A:
    if a[1] == "AC":
        fins.setdefault(a[0], 1)
for x in fins.values():
    ans += x
for i in range(m):
    p, s = A[i]
    prbstate.setdefault(p, 0)
    fins.setdefault(p, 0)
    if s == "AC":
        prbstate[p] += 1
    if s == "WA" and prbstate[p] < 1 and fins[p] == 1:
        pens += 1
print(ans, pens)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
import math
A, B = [int(x) for x in input().split(" ")]
 
print(int((A*B) / math.gcd(A, B)))

Fixed submission:
# coding: utf-8
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

 #最小公倍数
def lcm(a,b):
  return a*b//gcd(a,b)
 
A, B = [int(x) for x in input().split(" ")]
 
print(lcm(A, B))

Buggy python submission (verdict: Runtime Error):
# coding: utf-8
import math
A, B = [int(x) for x in input().split(" ")]

print((A*B) // math.gcd(A, B))


Fixed submission:
# coding: utf-8
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

 #最小公倍数
def lcm(a,b):
  return a*b//gcd(a,b)
 
A, B = [int(x) for x in input().split(" ")]
 
print(lcm(A, B))

Buggy python submission (verdict: Runtime Error):
# coding: utf-8
import math
A, B = [int(x) for x in input().split(" ")]

print((A*B) // math.gcd(A, B))

Fixed submission:
# coding: utf-8
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

 #最小公倍数
def lcm(a,b):
  return a*b//gcd(a,b)
 
A, B = [int(x) for x in input().split(" ")]
 
print(lcm(A, B))

Buggy python submission (verdict: Runtime Error):
# coding: utf-8
import math

A, B = [int(x) for x in input().split(" ")]

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

print(lcm(A, B))

Fixed submission:
# coding: utf-8
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

 #最小公倍数
def lcm(a,b):
  return a*b//gcd(a,b)
 
A, B = [int(x) for x in input().split(" ")]
 
print(lcm(A, B))
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

N = int(input())
A = [int(x) for x in input().split(" ")]

k = 0
l = -1

for i in range(1, N+1):
    templ = l
    for j in range(k, N):
        if A[j] == i:
            k = j
            l = i
    if templ == l:
        break

if l == -1:
    print(-1)
else:
    print(N - l)

Fixed submission:
# coding: utf-8
N = int(input())
A = [int(x) for x in input().split(" ")]

# j 番目からリストの最後までの間で x があるか確かめ、ある場合は最小のインデックスを返し、ない場合は "n" を返す
def search(A, j, N, x):
    for i in range(j, N):
        if A[i] == x:
            return i
    return "n"


k = 0
tempk = -1
for i in range(1, N+1):
    k = search(A, k, N, i)
    if k == "n":
        break
    else:
        tempk = k

if tempk == -1:
    print(tempk)
else:
    print(N - A[tempk])
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
import math

a, b, x = [int(y) for y in input().split(" ")]

if a * a * b <= 2 * x:
    t = (a * a * a / (a * a * b - x)) / 2
    print(90 - math.degrees(math.atan(t)))
else:
    t = 2 * (x / (a * b * b))
    print(90 - math.degrees(math.atan(t)))

Fixed submission:
# coding: utf-8
import math

a, b, x = [int(y) for y in input().split(" ")]

if a * a * b == x:
    print(0)
else:
    if a * a * b <= 2 * x:
        t = (a * a * a / (a * a * b - x)) / 2
        print(90 - math.degrees(math.atan(t)))
    else:
        t = 2 * (x / (a * b * b))
        print(90 - math.degrees(math.atan(t)))
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
N, M = [int(x) for x in input().split(" ")]
prices = [int(x) for x in input().split(" ")]
prices.sort()
for i in range(M):
    prices[-1] //= 2
    if prices[-1] < prices[-2]:
        prices.sort()
sum = 0
for num in prices:
    sum += num
print(sum)

Fixed submission:
# coding: utf-8
import heapq

N, M = [int(x) for x in input().split(" ")]

prices = [-int(x) for x in input().split(" ")]

heapq.heapify(prices)

for i in range(M):
    maxp = heapq.heappop(prices)
    heapq.heappush(prices, -((-maxp) // 2))

total = 0
for x in prices:
    total += -x

print(total)

Buggy python submission (verdict: Runtime Error):
# coding: utf-8
N, M = [int(x) for x in input().split(" ")]
As = [int(x) for x in input().split(" ")]
As.sort()
for i in range(M):
    As[-1] //= 2
    if As[-1] < As[-2]:
        As.sort()
sum = 0
for num in As:
    sum += num
print(sum)

Fixed submission:
# coding: utf-8
import heapq

N, M = [int(x) for x in input().split(" ")]

prices = [-int(x) for x in input().split(" ")]

heapq.heapify(prices)

for i in range(M):
    maxp = heapq.heappop(prices)
    heapq.heappush(prices, -((-maxp) // 2))

total = 0
for x in prices:
    total += -x

print(total)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
N, M = [int(x) for x in input().split(" ")]
As = [int(x) for x in input().split(" ")]
As.sort()
for i in range(M):
    As[-1] //= 2
    As.sort()
sum = 0
for num in As:
    sum += num
print(sum)

Fixed submission:
# coding: utf-8
import heapq

N, M = [int(x) for x in input().split(" ")]

prices = [-int(x) for x in input().split(" ")]

heapq.heapify(prices)

for i in range(M):
    maxp = heapq.heappop(prices)
    heapq.heappush(prices, -((-maxp) // 2))

total = 0
for x in prices:
    total += -x

print(total)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
N, M = [int(x) for x in input().split(" ")]
As = [int(x) for x in input().split(" ")]
As.sort(reverse=True)
#print(As)
for i in range(M):
    As[0] = int(As[0] / 2)
    As.sort(reverse=True)
sum = 0
for num in As:
    sum += num
print(sum)

Fixed submission:
# coding: utf-8
import heapq

N, M = [int(x) for x in input().split(" ")]

prices = [-int(x) for x in input().split(" ")]

heapq.heapify(prices)

for i in range(M):
    maxp = heapq.heappop(prices)
    heapq.heappush(prices, -((-maxp) // 2))

total = 0
for x in prices:
    total += -x

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

ans = 0
for i in range(n-1):
  for j in range(i+1, n):
    ans += a[i] * a[j]
    
ans %= 10 ** 9 + 7
print(ans)

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

sum = sum(a) - a[0]

ans = 0
for i in range(n):
  ans += a[i] * sum
  if (i == n-1):
    break
  else:
  	sum -= a[i+1]
  
ans %= 10 ** 9 + 7  
print(ans)