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

N, M = map(int, input().split())
A = [map(int, input().split()) for _ in range(N)]
B = [map(int, input().split()) for _ in range(M)]

for (x, y) in A:
    d = np.array([])
    for q in B:
        print("q = ", q)
        print("*q=", *q,)
        a, b = q
        d = np.append(d, abs(x-a) + abs(y-b))
    print(np.argmin(d) + 1)

Fixed submission:
import numpy as np

N, M = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
B = [list(map(int, input().split())) for _ in range(M)]

for (x, y) in A:
    d = np.array([])
    for (a, b) in B:
        d = np.append(d, abs(x-a) + abs(y-b))
    print(np.argmin(d) + 1)
Buggy python submission (verdict: Runtime Error):
string = input()
string_list = [s for s in string]

def find(s, slist):
  index = []
  for i, st in enumerate(slist):
    if st == s:
      index.append(i)

index_of_a = find("A", string_list)
index_of_z = find("Z", string_list)

print(index_of_z[-1] - index_of_a[0]+1)

Fixed submission:
string = input()
string_list = [s for s in string]
 
def find(s, slist):
  index = []
  for i, st in enumerate(slist):
    if st == s:
      index.append(i)
  return index
 
index_of_a = find("A", string_list)
index_of_z = find("Z", string_list)
 
print(index_of_z[-1] - index_of_a[0]+1)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
import bisect
import numpy as np

num = 0
for x in range(K+1):
    tmp = min(S-x, K) - max(0, S-K-x)
    if tmp >= 0:
        num += tmp + 1


print(num)

Fixed submission:
K, S = map(int, input().split())
number = 0
for x in range(K+1):
  for y in range(K+1):
    z = S - (x + y)
    if 0 <= z <= K:
      number += 1
print(number)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
import bisect
import numpy as np

K, S = map(int, input().split())
sets = []
for x in range(K+1):
    for y in range(S-K-x, S-x+1):
        if y >= 0 and y <= K:
            z = S - (x + y)
            sets.append((x, y, z))

print(len(sets))

Fixed submission:
K, S = map(int, input().split())
number = 0
for x in range(K+1):
  for y in range(K+1):
    z = S - (x + y)
    if 0 <= z <= K:
      number += 1
print(number)

Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())
number = 0
for x in range(K+1):
  for y in range(x, K+1):
    for z in range(y, K+1):
      if x + y + z == S:
        if x == y and x == z:
          number += 1
        elif x == y or y == z or z == y:
          number += 3
        else:
          number += 6
print(number)


Fixed submission:
K, S = map(int, input().split())
number = 0
for x in range(K+1):
  for y in range(K+1):
    z = S - (x + y)
    if 0 <= z <= K:
      number += 1
print(number)

Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())
number = 0
for x in range(K+1):
  for y in range(K+1):
    for z in range(K+1):
      if x + y + z == S:
        number += 1
print(number)

Fixed submission:
K, S = map(int, input().split())
number = 0
for x in range(K+1):
  for y in range(K+1):
    z = S - (x + y)
    if 0 <= z <= K:
      number += 1
print(number)
Buggy python submission (verdict: Runtime Error):
A. B, C = input().split()
B = [b for b in B]
print("A{}C".format(B[0]))

Fixed submission:
A, B, C = input().split()
print("A{}C".format(B[0]))

Buggy python submission (verdict: Runtime Error):
A. B, C = input().split()
print("A{}C".format(B[0]))

Fixed submission:
A, B, C = input().split()
print("A{}C".format(B[0]))
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = 0
for i in range(1, N+1):
  S += i
print(S)

Fixed submission:
IN = input()
OUT = []

for order in IN:
    if order == "B" and len(OUT) != 0:
        OUT.pop()
    elif order == "0" or order == "1":
        OUT.append(order)

print("".join(OUT))

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = 0
for i in range(1, N+1):
  S += 1
print(S)

Fixed submission:
IN = input()
OUT = []

for order in IN:
    if order == "B" and len(OUT) != 0:
        OUT.pop()
    elif order == "0" or order == "1":
        OUT.append(order)

print("".join(OUT))
Buggy python submission (verdict: Runtime Error):
A,B=int(input().split())
print(A*B)

Fixed submission:
a,b=map(int,input().split())
print(a*b)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,k=map(int,input().split())



arr_a=[1 for i in range(a)] 
arr_b=[0 for i in range(b)]
arr_c=[-1 for i in range(c)]
arr=arr_a+arr_b+arr_c

print(sum(arr[:k]))





Fixed submission:
a,b,c,k=map(int,input().split())
if k<=a:
    print(k)
elif a<k<=b+a:
    print(a)
elif k>a+b:
     print(a+(-1)*(k-a-b))
Buggy python submission (verdict: Time Limit Exceeded):
import math
k=int(input())
ans=0
for x in range(1,k+1):
    for y in range(1,k+1):
        for z in range(1,k+1):
           if math.gcd(x,y)==1:
               ans+=1
           elif math.gcd(math.gcd(x,y),z)==1:
               ans+=1
           else:
              ans+=math.gcd(math.gcd(x,y),z)
print(ans)

Fixed submission:
import numpy as np
K=int(input())
x = np.arange(1, K + 1)
nums = np.gcd.outer(np.gcd.outer(x, x), x)
print(nums.sum())

Buggy python submission (verdict: Runtime Error):
k=int(input())
    ans=0
    for x in range(1,k+1):
        for y in range(1,k+1):
            for z in range(1,k+1):
               if math.gcd(x,y)==1:
                   ans+=1
               
               elif math.gcd(math.gcd(x,y),z)==1: 
                   ans+=1
               else: 
                       ans+=math.gcd(math.gcd(x,y),z)
    print(ans)

Fixed submission:
import numpy as np
K=int(input())
x = np.arange(1, K + 1)
nums = np.gcd.outer(np.gcd.outer(x, x), x)
print(nums.sum())
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=list(map(int,input().split()))
count=0
for i in range(int(n)):
    if a[i]<sum(a)//(4*int(m)):
        count=count
    else:
        count+=1
if count>=int(m):
    print("Yes")
else:
    print("No")
        

Fixed submission:
x,y,z=map(str,input().split())
print(z+" "+x+" "+y)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
n,k=map(int,input().split())
if n%k==0:
    print(0)
    sys.exit()
while abs(n-k)<n:
    n=abs(n-k)
    
    if n==0:
        print(n)
        sys.exit()
else:
    print(n)

Fixed submission:
import sys
n,k=map(int,input().split())
if n%k==0:
    print(0)
    sys.exit()
if n%k<abs(k-n%k):
    print(n%k)
else:
    print(abs(k-n%k))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
n,k=map(int,input().split())
if k==1:
    print(0)
    sys.exit()
while abs(n-k)<n:
    n=abs(n-k)
    
    if n==0:
        print(n)
        sys.exit()
else:
    print(n)

Fixed submission:
import sys
n,k=map(int,input().split())
if n%k==0:
    print(0)
    sys.exit()
if n%k<abs(k-n%k):
    print(n%k)
else:
    print(abs(k-n%k))
Buggy python submission (verdict: Runtime Error):
n,a,b=map(int,input().split())

print(n//(a+b)*a+mi,min(a,n%(a+b))
    


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

print(n//(a+b)*a+min(a,n%(a+b)))
Buggy python submission (verdict: Runtime Error):
C=int(input())
li=[a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z]
print(li[C+1])

Fixed submission:
C=input()
li=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
count=li.index(C)
count=count+1
print(li[count])
Buggy python submission (verdict: Runtime Error):
r=input()
print(r**2)

Fixed submission:
r=int(input())
print(r**2)

Buggy python submission (verdict: Runtime Error):
def hankei(x):
  print(x**2)
print(r)

Fixed submission:
r=int(input())
print(r**2)
Buggy python submission (verdict: Runtime Error):
import math
n=int(input())
li=[]
for x in range(2,int(math.sqrt(n))+1):
    if n%x==0:
        y=n//x
        walk=y+x-2
        li.append(walk)
    
if li==[]:
    print(n-1)
else:
    print(min(li))
import math
n=int(input())
li=[]
for x in range(2,int(math.sqrt(n))+1):
    if n%x==0:
        y=n//x
        walk=y+x-2
        li.append(walk)
    
if li==[]:
    print(n-1)
else:
    print(min(li))


Fixed submission:
import math
n=int(input())
li=[]
for x in range(2,int(math.sqrt(n))+1):
    if n%x==0:
        y=n//x
        walk=y+x-2
        li.append(walk)
    
if li==[]:
    print(n-1)
else:
    print(min(li))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[input() for i in range(n)]

for x in range(len(a)):
    if x==a.index(max(a)):
            print(sorted(a)[-2])
    else:
            print(max(a))


Fixed submission:
n=int(input())
a=[int(input()) for i in range(n)]
Max=max(a)
Second=sorted(a)[-2]
Index=a.index(Second)
[print(Max) if i!=Max else print(Second) for i in a]

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[input() for i in range(n)]

for x in range(n):
    if x!=a.index(max(a)):
            print(max(a))
    else:
            print(sorted(a)[-2])


Fixed submission:
n=int(input())
a=[int(input()) for i in range(n)]
Max=max(a)
Second=sorted(a)[-2]
Index=a.index(Second)
[print(Max) if i!=Max else print(Second) for i in a]

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[input() for i in range(n)]

for x in range(n):
    if x!=a.index(max(a)):
            print(max(a))
    else:
            print(sorted(a)[-2])


Fixed submission:
n=int(input())
a=[int(input()) for i in range(n)]
Max=max(a)
Second=sorted(a)[-2]
Index=a.index(Second)
[print(Max) if i!=Max else print(Second) for i in a]
Buggy python submission (verdict: Runtime Error):
n=int(input())
v=[int(x) for x in input().split()]
c=[int(y) for y in input().split()]

new=[v[i]-c[i] for i in range(n)]
new.sort()
print(new[-2]+new[-1])


Fixed submission:
n=int(input())
v=[int(x) for x in input().split()]
c=[int(y) for y in input().split()]

new=[v[i]-c[i] for i in range(n) if v[i]-c[i]>0]

print(sum(new))
Buggy python submission (verdict: Runtime Error):
import bisect
import itertools
 
a, b, q = map(int, input().split())
ss, tt = [], []
for _ in range(a):
  ss.append(int(input()))
for _ in range(b):
  tt.append(int(input()))
  
for _ in range(q):
  x = int(input())
  md = pow(10, 15)
  xs, xt = bisect.bisect_left(ss, x), bisect.bisect_left(tt, x)
  ls, rs, lt, rt = ss[max(0, xs-1)], ss[min(a-1, xs)], tt[max(0, xt-1)], tt[min(b-1, xt)]
  for s, t in itertools.product([ls, rs], [lt, rt]):
    if s > t:
      if t > x:
        md = s - x if s - x < md else md
      elif s > x:
        if md > 2 * (s-x) + x-t:
          md = 2 * (s-x) + x-t
        if md > 2 * (x-t) + s-x:
          md = 2 * (x-t) + s-x
      else:
        md = x - t if x - t < md else md
    else:  # t > s
      if s > x:
        md = t - x if t - x < md else md
      elif t > x:
        if md > 2 * (x-s) + t-x:
          md = 2 * (x-s) + t-x
        if md > 2 * (t-x) + x-s:
          md = 2 * (t-x) + x-s
      else:
        md = x - s if x - s < md else md
  print(md)

Fixed submission:
def solve():
  y,m,d = map(int, input().split("/"))
  if y < 2019: 
    return "Heisei"
  elif y > 2019: 
    return "TBD"
    
  if m < 4: 
    return "Heisei"
  elif m > 4: 
    return "TBD"
    
  if d > 30: 
    return "TBD"
  return "Heisei"

print(solve())
Buggy python submission (verdict: Runtime Error):
H1, M1, H2, M2, K = map(int, input().split())

if h1 > h2:
    h2 += 24

h1 = H1 * 60
m1 = M1
h2 = H2 * 60
m2 = M2

print((h2 - m2) - (h1 + m1) - K)

Fixed submission:
H1, M1, H2, M2, K = map(int, input().split())

h1 = H1 * 60
m1 = M1
h2 = H2 * 60
m2 = M2

ans = (h2 + m2) - (h1 + m1) - K if (h2 + m2) > (h1 + m1) else (h2 + m2) - (h1 + m1) - K + 24 * 60

print(ans)
Buggy python submission (verdict: Runtime Error):
A, B, H, M = map(int, input().split())


h = (H / 12 + (M / 60 / 12)) * 2 * math.pi
m = M / 60 * 2 * math.pi

ax = A * math.cos(h)
ay = A * math.sin(h)

bx = B * math.cos(m)
by = B * math.sin(m)

#print(h, m, ax, ay, bx, by)

ans = ((ax-bx)**2 + (ay-by)**2 )**(1/2)

print(ans)

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

"""
h = (H / 12 + (M / 60 / 12)) * 2 * math.pi
m = M / 60 * 2 * math.pi

ax = A * math.cos(h)
ay = A * math.sin(h)

bx = B * math.cos(m)
by = B * math.sin(m)

#print(h, m, ax, ay, bx, by)

ans = ((ax-bx)**2 + (ay-by)**2 )**(1/2)

print(ans)
"""

ang = ((H / 12 + (M / 60 / 12)) - (M / 60)) * 360

#print(ang)

C = ang * math.pi / 180 if ang < 180 else (360 - ang) * math.pi / 180

#print(C / math.pi)

c2 = A**2 + B**2 - 2 * A * B * math.cos(C)

print((c2)**(1/2))
Buggy python submission (verdict: Runtime Error):
A, B, C, K = map(int, input().split())

A = [1] * A
B = [0] * B
C = [-1] * C

sum = A + B + C

count = 0
for i in range(K):
    count += sum[i]

print(count)

Fixed submission:
A, B, C, K = map(int, input().split())

sum = 0
if A >= K:
    print(K)
    exit()
else:
    K = K - A
    sum += A

if B >= K:
    print(sum)
    exit()
else:
    K = K - B

print(sum - K)
Buggy python submission (verdict: Runtime Error):
import numpy as np

A, B, N = map(int, input().split())

s = B-1 if N > B-1 else N

x = np.arange(0, s+1)
X = A * (x % B) - (A * (x % B)) % B

print(int(np.max(X)))

Fixed submission:
# -*- coding: utf-8 -*-
A,B,N = map(int, input().split())
 
def function(x):
  return (A*x)//B-A*(x//B)
 
if B-1<=N:
  print(function(B-1))
else:
  print(function(N))

Buggy python submission (verdict: Runtime Error):
import numpy as np

A, B, N = map(int, input().split())

#s = B if N > B else N
#print(s)

x = np.arange(0, N+1)
x1 = np.floor(A * x / B)
x2 = A * np.floor(x / B)
X =  x1 - x2

print(int(np.max(X)))

Fixed submission:
# -*- coding: utf-8 -*-
A,B,N = map(int, input().split())
 
def function(x):
  return (A*x)//B-A*(x//B)
 
if B-1<=N:
  print(function(B-1))
else:
  print(function(N))

Buggy python submission (verdict: Runtime Error):
import numpy as np

A, B, N = map(int, input().split())

s = B if N > B else N
#print(s)

x = np.arange(0, int(s/2))
X = np.floor(A * x / B) - A * np.floor(x / B)

print(int(np.max(X)))

Fixed submission:
# -*- coding: utf-8 -*-
A,B,N = map(int, input().split())
 
def function(x):
  return (A*x)//B-A*(x//B)
 
if B-1<=N:
  print(function(B-1))
else:
  print(function(N))

Buggy python submission (verdict: Runtime Error):
import numpy as np

A, B, N = map(int, input().split())

s = B if N > B else N
#print(s)

x = np.arange(0, s+1)
X = np.floor(A * x / B) - A * np.floor(x / B)

print(int(np.max(X)))

Fixed submission:
# -*- coding: utf-8 -*-
A,B,N = map(int, input().split())
 
def function(x):
  return (A*x)//B-A*(x//B)
 
if B-1<=N:
  print(function(B-1))
else:
  print(function(N))

Buggy python submission (verdict: Runtime Error):
import numpy as np

A, B, N = map(int, input().split())

x = np.arange(0, N+1)
X = np.floor(A * x / B) - A * np.floor(x / B)

print(int(np.max(X)))

Fixed submission:
# -*- coding: utf-8 -*-
A,B,N = map(int, input().split())
 
def function(x):
  return (A*x)//B-A*(x//B)
 
if B-1<=N:
  print(function(B-1))
else:
  print(function(N))

Buggy python submission (verdict: Runtime Error):
import numpy as np

A, B, N = map(int, input().split())

X = np.arange(1, N+1)
X = np.floor(A * X / B) - A * np.floor(X / B)

print(int(np.max(X)))

Fixed submission:
# -*- coding: utf-8 -*-
A,B,N = map(int, input().split())
 
def function(x):
  return (A*x)//B-A*(x//B)
 
if B-1<=N:
  print(function(B-1))
else:
  print(function(N))

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

A, B, N = map(int, input().split())

min = 0
for x in range(1, N+1):
    ans = math.floor(A*x/B) - A*math.floor(x/B)
    if min < ans:
        min = ans

print(min)

Fixed submission:
# -*- coding: utf-8 -*-
A,B,N = map(int, input().split())
 
def function(x):
  return (A*x)//B-A*(x//B)
 
if B-1<=N:
  print(function(B-1))
else:
  print(function(N))
Buggy python submission (verdict: Runtime Error):
while True:
    C -= B
    if C <= 0:
        print("Yes")
        break
    A -= D
    if D <= 0:
        print("No")
        break

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

while True:
    C -= B
    #print(C)
    if C <= 0:
        print("Yes")
        break
    A -= D
    #print(A)
    if A <= 0:
        print("No")
        break
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())

A = 0
for i in range(M):
    s = int(input())
    A += s

sub = N - A

if sub >= 0:
    print(sub)
else:
    print(-1)

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

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

sub = N - sum(A)

if sub >= 0:
    print(sub)
else:
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())))

A = np.sort(A)

for i in range(1, N+1):
    ans = np.count_nonzero(A == i)
    print(ans)
    A = A[ans:]

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

import collections
c = collections.Counter(A)

for i in range(1, N+1):
    print(c[i])

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

N = int(input())
A = np.array(list(map(int, input().split())))
#print(A)

for i in range(1, N+1):
    print(np.count_nonzero(A == i))

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

import collections
c = collections.Counter(A)

for i in range(1, N+1):
    print(c[i])

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

A.sort()
A_ = list(set(A))

for i in range(1, N+1):
    if i in A_:
        print(A.count(i))
        A = A[A.count(i):]
    else:
        print(0)

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

import collections
c = collections.Counter(A)

for i in range(1, N+1):
    print(c[i])

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

A.sort()

for i in range(1, N+1):
    print(A.count(i))
    A = A[A.count(i):]

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

import collections
c = collections.Counter(A)

for i in range(1, N+1):
    print(c[i])

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

for i in range(1, N+1):
    print(A.count(i))

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

import collections
c = collections.Counter(A)

for i in range(1, N+1):
    print(c[i])
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(set(map(int, input().split())))

### 解説より、
while not any(x % 2 for x in A):
    A = [i // 2 for i in A]
 
if not all(x % 2 for x in A):
    print(0)
    exit()
### ###

def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a
    
def lcm(a, b):
    return a * b // gcd(a, b)

ans = A[0]
for i in range(1, N):
    ans = lcm(ans, A[i])
    
print((M // ans + 1) // 2)

Fixed submission:
import sys
N,M=map(int,input().split())
A=list(set(map(int,input().split())))
N=len(A)
A=[a//2 for a in A]
 
def f(x):
    cnt=0
    while x%2==0:
        x//=2
        cnt+=1
    return cnt
C=f(A[0])
for a in A:
    if f(a)!=C:
        print(0)
        sys.exit()
def lcm(x,y):
    xy=x*y
    while y!=0:
        x,y=y,x%y
    return xy//x
LCM=A[0]
for i in range(1,N):
    LCM=lcm(LCM,A[i])
if LCM>M:
    ans=0
else:
    M//=LCM
    ans=(M+1)//2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
A, B = map(int, input().split())

S = A if A < B else B

s = int(S**(1/2))+1

cd = [1]
if (A % 2 == 0) and (B % 2 == 0):
    cd.append(2)

for i in range(3, S, 2):
    if A % i == 0:
        if B % i == 0:
            cd.append(i)
            
#print(cd)

count = 0
for i in cd:
    for c in range(2, int(i**(1/2))+1):
        if i % c == 0:
            break
    else:
        count += 1
         
print(count)

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

import math

a = math.floor(math.sqrt(A))
b = math.floor(math.sqrt(B))

A_ = [1]
i = 2
while i <= a:
    if A % i == 0:
        A //= i
        A_.append(i)
    else:
        i += 1
A_.append(A)
        
B_ = [1]
i = 2
while i <= b:
    if B % i == 0:
        B //= i
        B_.append(i)
    else:
        i += 1
B_.append(B)

#print(A_)
#print(B_)
#print(set(A_))
#print(set(B_))

count = 0
for i in set(A_):
    if i in set(B_):
        count += 1

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

"""
A.sort(reverse=True)

for m in range(M):
    A[m] //= 2
    A.sort()
    #print(A)

print(sum(A))
"""

for i in range(M):
    m = A.index(max(A))
    A[m] //= 2
    #print(A)

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)

#print(A)

for _ in range(M):
    m = heapq.heappop(A)
    #print(m)
    heapq.heappush(A, -(-m // 2))
    #print(A)

print(-sum(A))

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

for m in range(M):
    A[-1] //= 2
    A.sort()
    #print(A)

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)

#print(A)

for _ in range(M):
    m = heapq.heappop(A)
    #print(m)
    heapq.heappush(A, -(-m // 2))
    #print(A)

print(-sum(A))
Buggy python submission (verdict: Time Limit Exceeded):

N = int(input())

alpha = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
num = {1:"a", 2:"b", 3:"c", 4:"d", 5:"e", 6:"f", 7:"g", 8:"h", 9:"i", 10:"j"}

D = []
for i in range(N):
    s = input()
    d = ""
    for j in alpha:
        c = s.count(j)
        if c:
            d += j + num[c]
    
    D.append(d)

D.sort()
#print(D)

count = 0
idx = 0
while idx < len(D):
    #print(D[idx])
    n = D.count(D[idx])
    count += n * (n-1) // 2
    idx += n

print(count)

Fixed submission:

N = int(input())

l = []
for i in range(N):
    s = input()
    s = sorted(s)
    l.append("".join(s))
    
import collections

c = collections.Counter(l)
#print(c)
issubclass(type(c), dict)
C = list(c.values())
#print(C)

count = 0
for i in C:
    count += i * (i-1) // 2
    
print(count)

Buggy python submission (verdict: Time Limit Exceeded):

N = int(input())
        

D = []
for i in range(N):
    s = input()
    d = {"a": 0, "b": 0, "c": 0, "d": 0, "e": 0, "f": 0, "g": 0, "h": 0, "i": 0, "j": 0, "k": 0, "l": 0, "m": 0, "n": 0, "o": 0, "p": 0, "q": 0, "r": 0, "s": 0, "t": 0, "u": 0, "v": 0, "w": 0, "x": 0, "y": 0, "z": 0}
    for j in s:
        d[j] += 1
    
    D.append(d)

#print(D)
count = 0
while len(D):
    s = D[0]
    #print(D.count(s))
    n = D.count(s)
    count += n * (n-1) // 2
    while n:
        D.remove(s)
        n -= 1

print(count)

Fixed submission:

N = int(input())

l = []
for i in range(N):
    s = input()
    s = sorted(s)
    l.append("".join(s))
    
import collections

c = collections.Counter(l)
#print(c)
issubclass(type(c), dict)
C = list(c.values())
#print(C)

count = 0
for i in C:
    count += i * (i-1) // 2
    
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

A = []
for i in range(N):
    a = int(input())
    A.append(a)

ma = 0
for i in range(N-1):
    print(max(ma, max(A[i+1:])))
    ma = max(ma, A[i])

print(ma)


Fixed submission:
N = int(input())

A = []
for i in range(N):
    a = int(input())
    A.append([a, i])
    
A_ = sorted(A, reverse=True)

#print(A_)

for i in range(N):
    if A_[0][1] == i:
        print(A_[1][0])
    else:
        print(A_[0][0])