Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def multiply2(A):
    res = 1
    for item in A:
        res *= item
    if res > 10**18:
        return '-1'
    else:
        return res

if __name__ == "__main__":
    N = int(input())
    A = []
    A = list(map(int, input().split()))
    print(multiply2(A))

Fixed submission:
def multiply2(A):
    res = 1
    if 0 in A:
        return 0
    for item in A:
        res *= item
        if res > 10**18:
            return -1
    return res

if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    print(multiply2(A))
Buggy python submission (verdict: Runtime Error):
def management(N,array):
	res = [0]*N
	for i in range(N):
      res[array[i]] += 1
    for j in range(len(res)):
      print(res[j])
     
    
    
N = int(input())
array = list(map(int,input().split())
managememt(N,array))

Fixed submission:
import math
 
def round(R):
  return 2*R*math.pi
 
R = int(input())
print(round(R))

Buggy python submission (verdict: Runtime Error):
def management(N,array):
	res = [0]
	for i in range(N):
      res[array[i]] += 1
    for j in range(len(res)):
      print(res[j])
     
    
    
N = int(input())
array = list(map(int,input().split())
managememt(N,array))

Fixed submission:
import math
 
def round(R):
  return 2*R*math.pi
 
R = int(input())
print(round(R))

Buggy python submission (verdict: Runtime Error):
import math
 
def round(R):
  return 2*R*pi

R = int(input())
round(R)

Fixed submission:
import math
 
def round(R):
  return 2*R*math.pi
 
R = int(input())
print(round(R))

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

def round(R):
  return 2*R*pi

round(R)

Fixed submission:
import math
 
def round(R):
  return 2*R*math.pi
 
R = int(input())
print(round(R))
Buggy python submission (verdict: Runtime Error):
def management(N,array):
	res = []
	for i in range(N):
      res[array[i]] += 1
    for j in range(len(res)):
      print(res[j])
     
    
    
N = int(input())
array = list(map(int,input().split())
managememt(N,array))

Fixed submission:
def management(N,array):
  res = [0]*N
  for i in range(len(array)):
    res[array[i]-1] += 1
  for j in range(len(res)):
    print(res[j])

if __name__ == '__main__':
  N = int(input())
  array = list(map(int,input().split()))
  management(N,array)

Buggy python submission (verdict: Runtime Error):
def management(N,array):
	res = []
	for i in range(N):
      res[array[i]] += 1
    for j in range(len(res)):
      print(res[j])
     
    
    
N = int(input())
array = list(map(int,input().split())
mamagememt(N,array))

Fixed submission:
def management(N,array):
  res = [0]*N
  for i in range(len(array)):
    res[array[i]-1] += 1
  for j in range(len(res)):
    print(res[j])

if __name__ == '__main__':
  N = int(input())
  array = list(map(int,input().split()))
  management(N,array)
Buggy python submission (verdict: Runtime Error):
import bisect

def snuke_festival(N,arr):
    n_pair = 0
    for item in arr[1]:
        up_pair = bisect.bisect(arr[0],item)
        dowm_pair = bisect.bisect_right(arr[2],item)
        n_pair += up_pair*down_pair
    return n_pair


if __name__ == "__main__":
    N  =int(input())
    arr = []
    for i in range(3):
        arr.append(list(map(int,input().split())))
    arr_sorted = []
    for j in range(3):
        arr_sorted.append(arr[j].sort())
    print(snuke_festival(N,arr))

Fixed submission:
import bisect

def snuke_festival(N,arr):
    n_pair = 0
    for item in arr[1]:
        up_pair = bisect.bisect_left(arr[0],item)
        down_pair = bisect.bisect_right(arr[2],item)
        n_pair += up_pair*(N-down_pair)
    return n_pair


if __name__ == "__main__":
    N  =int(input())
    arr = []
    for i in range(3):
        arr.append(list(map(int,input().split())))
    arr_sorted = []
    for j in range(3):
        arr_sorted.append(arr[j].sort())
    print(snuke_festival(N,arr))

Buggy python submission (verdict: Time Limit Exceeded):
def snuke_festival(N,arr):
    n_pair = 0
    for i in range(N):
        for j in range(N):
            if arr[0][i] < arr[1][j]:
                for k in range(N):
                    if arr[1][j] < arr[2][k]:
                        n_pair += 1
    return n_pair

if __name__ == "__main__":
    N  =int(input())
    arr = []
    for i in range(3):
        arr.append(list(map(int,input().split())))
    arr_sorted = []
    for j in range(3):
        arr_sorted.append(arr[j].sort())
    print(snuke_festival(N,arr))

Fixed submission:
import bisect

def snuke_festival(N,arr):
    n_pair = 0
    for item in arr[1]:
        up_pair = bisect.bisect_left(arr[0],item)
        down_pair = bisect.bisect_right(arr[2],item)
        n_pair += up_pair*(N-down_pair)
    return n_pair


if __name__ == "__main__":
    N  =int(input())
    arr = []
    for i in range(3):
        arr.append(list(map(int,input().split())))
    arr_sorted = []
    for j in range(3):
        arr_sorted.append(arr[j].sort())
    print(snuke_festival(N,arr))

Buggy python submission (verdict: Time Limit Exceeded):
def snuke_festival(N,arr):
    n_pair = 0
    for i in range(N):
        for j in range(N):
            if arr[0][i] < arr[1][j]:
                for k in range(N):
                    if arr[1][j] < arr[2][k]:
                        n_pair += 1
    return n_pair


if __name__ == "__main__":
    N  =int(input())
    arr = []
    for i in range(3):
        arr.append(list(map(int,input().split())))

    print(snuke_festival(N,arr))

Fixed submission:
import bisect

def snuke_festival(N,arr):
    n_pair = 0
    for item in arr[1]:
        up_pair = bisect.bisect_left(arr[0],item)
        down_pair = bisect.bisect_right(arr[2],item)
        n_pair += up_pair*(N-down_pair)
    return n_pair


if __name__ == "__main__":
    N  =int(input())
    arr = []
    for i in range(3):
        arr.append(list(map(int,input().split())))
    arr_sorted = []
    for j in range(3):
        arr_sorted.append(arr[j].sort())
    print(snuke_festival(N,arr))
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:
# coding: utf-8
# Your code here!

def main():
    N = int(input())
    A = list(map(int,input().split()))
    
    if 0 in A:
        print(0)
        return
        
    ans = 1
    for i in range(N):
        ans *= A[i]
        if ans > 1000000000000000000:
            print(-1)
            return
    
    print(ans)

main()
Buggy python submission (verdict: Runtime Error):
from math import ceil,floor
from fractions import gcd

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

A,B,C,D = map(int,input().split())

ans = B-A+1
ans -= (B//C - ceil(A/C) + 1)
ans -= (B//D - ceil(A/D) + 1)
ans += (B//lcm(C,D) - ceil(A/lcm(C,D)) + 1)

print(ans)

Fixed submission:
S = input()

def main():
    for i in range(1,len(S)):
        if S[i] == S[i-1]:
            return "Bad"
    return "Good"

print(main())
Buggy python submission (verdict: Runtime Error):
from math import ceil,floor
from math import gcd

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

A,B,C,D = map(int,input().split())

ans = B-A+1
ans -= B//C - ceil(A/C) + 1
ans -= B//D - ceil(A/D) + 1
ans += B//lcm(C,D) - ceil(A/lcm(C,D)) + 1

print(ans)

Fixed submission:
from math import ceil,floor
from fractions import gcd

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

A,B,C,D = map(int,input().split())

ans = B-A+1
ans -= B//C - (A-1)//C
ans -= B//D - (A-1)//D
ans += B//lcm(C,D) - (A-1)//lcm(C,D)

print(ans)

Buggy python submission (verdict: Runtime Error):
from math import ceil,floor
from math import gcd

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

A,B,C,D = map(int,input().split())

ans = B-A+1
ans -= (B//C - ceil(A/C) + 1)
ans -= (B//D - ceil(A/D) + 1)
ans += (B//lcm(C,D) - ceil(A/lcm(C,D)) + 1)

print(ans)

Fixed submission:
from math import ceil,floor
from fractions import gcd

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

A,B,C,D = map(int,input().split())

ans = B-A+1
ans -= B//C - (A-1)//C
ans -= B//D - (A-1)//D
ans += B//lcm(C,D) - (A-1)//lcm(C,D)

print(ans)
Buggy python submission (verdict: Runtime Error):
b = int(input())

dict = {"A":"T","C":"G","T":"A","G":"C"}

print(dict[b])

Fixed submission:
b = input()
 
dict = {"A":"T","C":"G","T":"A","G":"C"}
 
print(dict[b])
Buggy python submission (verdict: Runtime Error):
s = input()

for i in range(3):
  if s[i] == "1":
    s[i] = "9"
  else:
    s[i] = "1"

Fixed submission:
s = list(input())
 
for i in range(3):
  if s[i] == "1":
    s[i] = "9"
  else:
    s[i] = "1"

print("".join(s))
Buggy python submission (verdict: Runtime Error):
S = input()
max_c = 0
for i in S:
    if i != 'R':
        count = 0
    else:
        count = count + 1
    
    if max_c < count:
        max_c = count
    
print(max_c)

Fixed submission:
S = input()
count = 0
max_c = 0

for i in S:
    if i != 'R':
        count = 0
    else:
        count = count + 1
    
    if max_c < count:
        max_c = count
    
print(max_c)

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

for i in S:
    if i != 'R':
        count = 0
    else:
        count = count + 1
    
    if max_c < count:
        max_c = count
    
print(max_c)

Fixed submission:
S = input()
count = 0
max_c = 0

for i in S:
    if i != 'R':
        count = 0
    else:
        count = count + 1
    
    if max_c < count:
        max_c = count
    
print(max_c)
Buggy python submission (verdict: Runtime Error):
d,t,s = map(int,input())

if d > t * s :
    print('No')
else:
    print('Yes')

Fixed submission:
d,t,s = map(int,input().split())

if d > t * s :
    print('No')
else:
    print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

def gcd (a,b):
  if a < b: a, b = b, a
  while b:
    a,b = b, a % b
  return a
print (sum([gcd(gcd(x,y),z) for x in range(1,N+1)  for y in range(1,N+1)  for z in range(1,N+1)]))


Fixed submission:
N = int(input())
L = [[1]* 201 for _ in range(201)] 

def gcd (a,b):
  if a < b:
    a, b = b, a
  A, B = a, b
  if L[a][b] != 1:
    return L[a][b]
  while b:
    a,b = b, a % b
  L[A][B] = a
  return a

ans = 0
for x in range(1,N+1):
  for y in range(1,N+1):
    for z in range(1,N+1):
      t = gcd(x,y)
      u = gcd(t,z)
      ans += u
print (ans)
Buggy python submission (verdict: Time Limit Exceeded):
K, N = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
for i in range(N-1):
  for j in range(i+1,N):
    a = abs(A[i]-A[j])
    ans = max(ans, min(a, K-a))
print (K-ans)

Fixed submission:
K, N = map(int, input().split())
A = list(map(int, input().split()))
ans = min(A[-1]-A[0],K-(A[-1]-A[0]))
for i in range(N-1):
  ans = max(ans,A[i+1]-A[i])
print (K-ans)

Buggy python submission (verdict: Time Limit Exceeded):
K, N = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
for i in range(N-1):
  for j in range(i+1,N):
    a = abs(A[i]-A[j])
    ans = max(ans, min(a, K-a))
print (K-ans)

Fixed submission:
K, N = map(int, input().split())
A = list(map(int, input().split()))
ans = min(A[-1]-A[0],K-(A[-1]-A[0]))
for i in range(N-1):
  ans = max(ans,A[i+1]-A[i])
print (K-ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np
K, N = map(int, input().split())
A = list(map(int, input().split()))
D = np.zeros((N,N))
for i in range(N-1):
  for j in range(i+1,N):
    a = abs(A[i]-A[j])
    D[i][j] = min(a, K-a)
print (K-np.max(D))

Fixed submission:
K, N = map(int, input().split())
A = list(map(int, input().split()))
ans = min(A[-1]-A[0],K-(A[-1]-A[0]))
for i in range(N-1):
  ans = max(ans,A[i+1]-A[i])
print (K-ans)

Buggy python submission (verdict: Time Limit Exceeded):
K, N = map(int, input().split())
A = list(map(int, input().split()))
L = [min(abs(A[i]-A[j]), K -abs(A[i]-A[j])) for i in range(N-1) for j in range(i+1,N)]
print (K-max(L))

Fixed submission:
K, N = map(int, input().split())
A = list(map(int, input().split()))
ans = min(A[-1]-A[0],K-(A[-1]-A[0]))
for i in range(N-1):
  ans = max(ans,A[i+1]-A[i])
print (K-ans)

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

ans = 10 ** 12
for i in range(N):
  d = 0
  for j in range(N):
    a = abs(A[i]-A[j])
    d += min(a, K-a)
  ans = min(ans, d)
print (ans)


Fixed submission:
K, N = map(int, input().split())
A = list(map(int, input().split()))
ans = min(A[-1]-A[0],K-(A[-1]-A[0]))
for i in range(N-1):
  ans = max(ans,A[i+1]-A[i])
print (K-ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np
K, N = map(int, input().split())
A = list(map(int, input().split()))
D = np.zeros((N,N))
for i in range(N-1):
  for j in range(i+1,N):
    a = abs(A[i]-A[j])
    D[i][j] = min(a, K-a)
    D[j][i] = min(a, K-a)
ans = 10 ** 12
print (int(min(np.sum(D, axis=0))))


Fixed submission:
K, N = map(int, input().split())
A = list(map(int, input().split()))
ans = min(A[-1]-A[0],K-(A[-1]-A[0]))
for i in range(N-1):
  ans = max(ans,A[i+1]-A[i])
print (K-ans)

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

ans = 10 ** 12
for i in range(N):
  d = 0
  for j in range(N):
    a = abs(A[i]-A[j])
    d += min(a, K-a)
  ans = min(ans, d)
print (ans)


Fixed submission:
K, N = map(int, input().split())
A = list(map(int, input().split()))
ans = min(A[-1]-A[0],K-(A[-1]-A[0]))
for i in range(N-1):
  ans = max(ans,A[i+1]-A[i])
print (K-ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N,X,Y = map(int, input().split())
X -= 1
Y -= 1
D = np.zeros((N,N))
for i in range(N-1):
  for j in range(i+1,N):
    D[i][j] = min(abs(i-j),abs(X-i)+abs(Y-j)+1,abs(Y-i)+abs(X-j)+1) 
for k in range(1,N):
  print (np.count_nonzero(D == k))

Fixed submission:
from collections import defaultdict as dd
N,X,Y = map(int, input().split())
D = dd(int)
for i in range(1,N):
  for j in range(i+1,N+1):
    D[min(abs(i-j),abs(X-i)+abs(Y-j)+1,abs(Y-i)+abs(X-j)+1)] += 1 
for k in range(1,N):
  print (D[k])

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from scipy.sparse.csgraph import csgraph_from_dense,dijkstra,floyd_warshall
N,X,Y = map(int, input().split())
D = np.zeros((N,N))
for i in range(N-1):
  D[i][i+1]=1
  D[i+1][i]=1
D[X-1][Y-1]=1
D[Y-1][X-1]=1
A = floyd_warshall(D)
for k in range(1,N): print (np.sum(A==k)//2)


Fixed submission:
from collections import defaultdict as dd
N,X,Y = map(int, input().split())
D = dd(int)
for i in range(1,N):
  for j in range(i+1,N+1):
    D[min(abs(i-j),abs(X-i)+abs(Y-j)+1,abs(Y-i)+abs(X-j)+1)] += 1 
for k in range(1,N):
  print (D[k])
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
p = list(map(int, input().split()))

ans = 0
for i in range(N-K+1):
  ans = max(ans, sum(p[i:i+K]))
print ((ans+K)/2)

Fixed submission:
N, K = map(int, input().split())
p = list(map(int, input().split()))

tmp = sum(p[0:K])
ans = tmp
for i in range(N-K):
  tmp = tmp + p[i+K]-p[i]
  ans = max(ans, tmp)
print ((ans+K)/2)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int,input().split()))

ans = 0
for i in range(N):
  for j in range(i):
    f = True
    if P[i] >= P[j]:
      f = False
      break
  else:
    ans += 1
print (ans)


Fixed submission:
N = int(input())
P = list(map(int,input().split()))

ans = 0
m_n = N
for i in range(N):
  if m_n >= P[i]:ans += 1
  m_n = min(m_n,P[i])
print (ans)
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())

if A+B = 3:
  print (3)
elif A+B=4:
  print (2)
else:
  print (1)


Fixed submission:
A = int(input())
B = int(input())

if A+B == 3:
  print (3)
elif A+B == 4:
  print (2)
else:
  print (1)
Buggy python submission (verdict: Runtime Error):
//aaaaa
aaaaaa//

Fixed submission:
S = input()

ans = 0
for i in range(len(S)//2):
  if S[i] != S[len(S)-i-1]: ans += 1
print (ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
L = []

for i in range(1,int(N ** 0.5)):
  if N % i == 0:
    L.append(i + N // i)
print (min(L)-2)


Fixed submission:
N = int(input())
L = []

for i in range(1,int(N ** 0.5)+1):
  if N % i == 0:
    L.append(i + N // i)
print (min(L)-2)
Buggy python submission (verdict: Runtime Error):
N = int(input())
d = list(map(int, input().split()))
ans = 0
for i in range(N-1):
  for j in range(i:N):
    ans += d[i] * d[j]
print (ans)

Fixed submission:
N = int(input())
d = list(map(int, input().split()))

print ((sum(d) ** 2 - sum(map(lambda x: x ** 2, d))) //2)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N = int(input())
L = sorted(list(map(int, input().split())))
D = list(itertools.combinations(L,3))
M = [1 for a,b,c in D if a + b > c ]
print (sum(M))

Fixed submission:
import bisect
N = int(input())
L = sorted(list(map(int, input().split())))

ans = 0
for i in range(N-1,1,-1):
  for j in range(i-1,0,-1):
    t = bisect.bisect(L, L[i]-L[j])
    if j-t>0: ans+=j-t
print (ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = sorted(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(N-1,j,-1):
      if L[i] + L[j] > L[k]:
        ans += k-j
        break
print (ans)

Fixed submission:
import bisect
N = int(input())
L = sorted(list(map(int, input().split())))

ans = 0
for i in range(N-1,1,-1):
  for j in range(i-1,0,-1):
    t = bisect.bisect(L, L[i]-L[j])
    if j-t>0: ans+=j-t
print (ans)

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

N = int(input())
L = sorted(list(map(int, input().split())))

ans = 0
for x in itertools.combinations(L,3):
  if x[0] + x[1] >  x[2]:
    ans += 1
print (ans)

Fixed submission:
import bisect
N = int(input())
L = sorted(list(map(int, input().split())))

ans = 0
for i in range(N-1,1,-1):
  for j in range(i-1,0,-1):
    t = bisect.bisect(L, L[i]-L[j])
    if j-t>0: ans+=j-t
print (ans)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
h = list(map(int, input().split()))
print (len([1 for x in h if h >= K]))

Fixed submission:
N, K = map(int, input().split())
h = list(map(int, input().split()))

L = [1 for i in range(N) if h[i] >= K]
print (len(L))
Buggy python submission (verdict: Runtime Error):
import math
import sys
A, B = map(int, input().split())

def gcd(a, b):
  if b > a:
    a, b = b,a
  a, b = b, a % b
  if b == 0:
    return a
  else:
    return gcd(a, b)

def make_divisors(n):
  divisors = []
  for i in range(2, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
  divisors.append(N // divisors[-1])
  return divisors

N = gcd(A, B)
if N == 1:
  print (1)
  sys.exit()

D = make_divisors(N)
L = []
for i in D:
  for j in L:
    if i % j == 0:
      break
  else:
    L.append(i)
print (len(L)+1)

Fixed submission:
import math
import sys
A, B = map(int, input().split())

def gcd(a, b):
  if b > a:
    a, b = b,a
  a, b = b, a % b
  if b == 0:
    return a
  else:
    return gcd(a, b)

def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
  divisors.append(N // divisors[-1])
  return divisors

N = gcd(A, B)
if N == 1:
  print (1)
  sys.exit()

D = make_divisors(N)
L = []
for i in D[1:]:
  for j in L:
    if i % j == 0:
      break
  else:
    L.append(i)
print (len(L)+1)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())

C = []
dp = [10 ** 9 for i in range (1 << N)]
dp [0] = 0
for i in range(M):
  a, b = map(int, input().split())
  c = list(map(lambda x: int(x) - 1, input().split()))
  b = 0
  for i in c:
    b |= 1 << i
  C.append((b,a))
for s in range(1 << N):
  for c in range(M):
    t = s | C[c][0]
    dp[t] = min(dp[t], dp[s] + C[c][1])
print (dp[-1] if dp[-1] != 10 ** 9 else -1)

Fixed submission:
N, M = map(int, input().split())

C = []
dp = [10 ** 9 for i in range (1 << N)]
dp [0] = 0
for i in range(M):
  a, b = map(int, input().split())
  c = list(map(lambda x: int(x) - 1, input().split()))
  b = 0
  for i in c:
    b |= 1 << i
  C.append((b,a))
for s in range(1 << N):
  for c in range(M):
    t = s | C[c][0]
    dp[t] = min(dp[t], dp[s] + C[c][1])
print (dp[-1] if dp[-1] != 10 ** 9 else -1)

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

C = []
dp = [10 ** 9 for i in range (1 << N)]
dp [0] = 0
for i in range(M):
  a, b = map(int, input().split())
  c = list(map(lambda x: int(x) - 1, input().split()))
  b = 0
  for i in c:
    b |= 1 << i
  C.append((b,a))
for s in range(1 << N):
  for c in range(M):
    t = s | C[c][0]
    cost = dp[s] + C[c][1]
    dp[t] = min(dp[t], cost)
print (dp[-1] if dp[-1] != 10 ** 9 else -1)

Fixed submission:
N, M = map(int, input().split())

C = []
dp = [10 ** 9 for i in range (1 << N)]
dp [0] = 0
for i in range(M):
  a, b = map(int, input().split())
  c = list(map(lambda x: int(x) - 1, input().split()))
  b = 0
  for i in c:
    b |= 1 << i
  C.append((b,a))
for s in range(1 << N):
  for c in range(M):
    t = s | C[c][0]
    dp[t] = min(dp[t], dp[s] + C[c][1])
print (dp[-1] if dp[-1] != 10 ** 9 else -1)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N, M = map(int, input().split())
A = list(map(int, input().split()))

while M:
  m = A.index(max(A))
  A[m] //= 2
  M -= 1
print (sum(A))


Fixed submission:
import heapq
N, M = map(int, input().split())
A = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(A)

while M:
  m = heapq.heappop(A) * (-1)
  heapq.heappush(A, (-1) * (m // 2))
  M -= 1
print (sum(A) * (-1))

Buggy python submission (verdict: Runtime Error):
import bisect
import sys
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))

if N == 1:
  print (int(A[0] // 2 ** M))
  sys.exit()
while M:
  A[-1] //= 2
  if A[-1] < A[-2]:
    d = A[-1]
    b = bisect.bisect(A,d) 
    A[b+1:] = A[b:-1]
    A[b] = d
  M -= 1
print (sum(A))


Fixed submission:
import heapq
N, M = map(int, input().split())
A = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(A)

while M:
  m = heapq.heappop(A) * (-1)
  heapq.heappush(A, (-1) * (m // 2))
  M -= 1
print (sum(A) * (-1))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = []
for i in range(N):
  S.append(input())

cnt = 0
for i in range(N):
  for j in range(i + 1, N):
    a = list((S[i]))
    b = list((S[j]))
    
    for k in range(10):
      if a[k] in b:
        b.remove(a[k])
      else:
        break
    else:
      cnt += 1
print (cnt)

Fixed submission:
import math

N = int(input())
S = []
for i in range(N):
  S.append(''.join(sorted(input())))

from collections import Counter
Sc = Counter(S)

def com(n, r):
  return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

cnt = 0
for i in Sc.values():
  if i >= 2:
    cnt += com(i,2)
  
print (cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = []
for i in range(N):
  S.append(input())

cnt = 0
for i in range(N):
  for j in range(i + 1, N):
#    print (i, j, end=" ")
    a = sorted(list(S[i]))
    b = sorted(list(S[j]))
#    print (a, b)
    
    for k in range(10):
      if a[k] != b[k]:
        break
    else:
      cnt += 1
    
print (cnt)

Fixed submission:
import math

N = int(input())
S = []
for i in range(N):
  S.append(''.join(sorted(input())))

from collections import Counter
Sc = Counter(S)

def com(n, r):
  return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

cnt = 0
for i in Sc.values():
  if i >= 2:
    cnt += com(i,2)
  
print (cnt)