Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())
inis = {"M": 0, "A": 0, "R": 0, "C": 0, "H": 0}
for i in range(N):
    s = list(input())
    if s[0] == "M" or s[0] == "A" or s[0] == "R" or s[0] == "C" or s[0] == "H":
        inis[s[0]] += 1

ans = 0
march = ["M","A","R","C","H"]
for i in range(N):
    for j in range(i, N):
        for k in range(j, N):
            if march[i] != march[j] and march[i] != march[k] and march[j] != march[k]:
                ans += inis[march[i]] * inis[march[j]] * inis[march[k]]

print(ans)

Fixed submission:
N = int(input())
inis = {"M": 0, "A": 0, "R": 0, "C": 0, "H": 0}
for i in range(N):
    s = list(input())
    if s[0] == "M" or s[0] == "A" or s[0] == "R" or s[0] == "C" or s[0] == "H":
        inis[s[0]] += 1

ans = 0
march = ["M","A","R","C","H"]
for i in range(len(march)):
    for j in range(i, len(march)):
        for k in range(j, len(march)):
            if march[i] != march[j] and march[i] != march[k] and march[j] != march[k]:
                ans += inis[march[i]] * inis[march[j]] * inis[march[k]]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

num = 1
for i in range(1, N+1):
  	num = num * i

if num < (10**9 + 7):
  print(num)
else:
  print(num % (10**9 + 7))

Fixed submission:
N = int(input())

num = 1
for i in range(1, N+1):
  	num = i * num % (10**9 + 7)

print(num)
Buggy python submission (verdict: Runtime Error):
N = input()
flag = false
for i in range(N):
  if N[i] == "7":
    flag = true
if flag: print("Yes")
else: print("No")

Fixed submission:
N = input()
flag = False
for i in range(len(N)):
  if(N[i] == "7"):
    flag = True
if flag: 
    print("Yes")
else: 
    print("No")
Buggy python submission (verdict: Runtime Error):
import math

K = int(input())
ans = 0
for i in range(1, K+1):
  for j in range(1, K+1):
    for k in range(1, K+1):
      ans += gcd(gcd(i, j), k)

print(ans)

Fixed submission:
from math import gcd

K = int(input())
ans = 0
for i in range(1, K+1):
  for j in range(1, K+1):
    for k in range(1, K+1):
      ans += gcd(gcd(i, j), k)

print(ans)

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

def gcd(*numbers):
    return reduce(math.gcd, numbers)

K = int(input())
ans = 0
for i in range(1, K+1):
  for j in range(1, K+1):
    for k in range(1, K+1):
      ans += gcd(i, j, k)

print(ans)

Fixed submission:
from math import gcd

K = int(input())
ans = 0
for i in range(1, K+1):
  for j in range(1, K+1):
    for k in range(1, K+1):
      ans += gcd(gcd(i, j), k)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
count = 0
for i in range(N-2):
  for j in range(i+1, N-1):
    if S[i] == S[j]:
      continue
    for k in range(j+1, N):
      if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
        if j-i == k-j:
          continue
        else:
          count += 1
      
print(count)


Fixed submission:
n = int(input())
s = input()
r = s.count('R')
g = s.count('G')
b = s.count('B')
count = r*g*b
for i in range(n):
    for d in range(n):
        j = i+d
        k = j+d
        if k >= n: 
            break
        if s[i]!=s[j] and s[j]!=s[k] and s[k] != s[i]: 
            count -= 1
            
print(count)
Buggy python submission (verdict: Runtime Error):
S = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51".split(",")
for i in rangeAC(len(S)):
  S[i] = S[i].strip(" ")
K = int(input())
print(S[K-1])

Fixed submission:
S = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51".split(",")
for i in range(len(S)):
  S[i] = S[i].strip(" ")
K = int(input())
print(S[K-1])
Buggy python submission (verdict: Runtime Error):
S = input()
for i in range(2):
  if S == "AAA" or S == "BBB"
    print("No")
  else:
    print("Yes")

Fixed submission:
S = input()
if S == "AAA" or S == "BBB":
  print("No")
else:
  print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
[N, A, B] = list(map(int, input().split()))
pair = A+B
count = 0
ans = 0

while N >= pair:
  N -= pair
  count += 1

if N <= A:
  ans = count*A + N
else:
  ans = count*A + A

print(ans)


Fixed submission:
[N, A, B] = list(map(int, input().split()))
pair = A+B
ans = 0

num = int((N-(N%pair))/pair)

if N - num*pair <= A:
  ans = num*A + N - num*pair
else:
  ans = num*A + A

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
count = 0
for _ in range(q):
  query = input()
  if query[0] == "1":
    count += 1
  if count%2 == 0:
    if query[0] == "2":
      if query[2] == "1":
        s = query[4] + s
      if query[2] == "2":
        s = s + query[4]
        
  else:
    if query[0] == "2":
      if query[2] == "1":
        s = s + query[4]
      if query[2] == "2":
        s = query[4] + s

if count%2 != 0:
  s = s[::-1]
print(s)

Fixed submission:
s = input()
q = int(input())
c = 0
l = []
r = []

for i in range(q):
  query = input()
  if query[0] == "1":
    c += 1
    a = l
    l = r
    r = a
  if query[0] == "2":
    if query[2] == "1":
      l.append(query[4])
    if query[2] == "2":
      r.append(query[4])
      
l = "".join(l)
l = l[::-1]
r = "".join(r)
      
if c%2 == 1:
  s = s[::-1]
  
print(l + s + r)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
for _ in range(q):
  query = input()
  if query[0] == "1":
    s = s[::-1]
  if query[0] == "2":
    if query[2] == "1":
      s = query[4] + s
    if query[2] == "2":
      s = s + query[4]
      
print(s)

Fixed submission:
s = input()
q = int(input())
c = 0
l = []
r = []

for i in range(q):
  query = input()
  if query[0] == "1":
    c += 1
    a = l
    l = r
    r = a
  if query[0] == "2":
    if query[2] == "1":
      l.append(query[4])
    if query[2] == "2":
      r.append(query[4])
      
l = "".join(l)
l = l[::-1]
r = "".join(r)
      
if c%2 == 1:
  s = s[::-1]
  
print(l + s + r)
Buggy python submission (verdict: Runtime Error):
N = int(input())
d = list(map(int, [input() for i in range(N)]))

bucket = {}
for i in range(N):
  if(i in bucket) == False:
    bucket[d[i]] = []
  bucket[d[i]].append(d[i])

print(len(bucket))

Fixed submission:
N = int(input())
d = list(map(int, [input() for i in range(N)]))
d.sort()
count = 1

for i in range(0, N-1):
  if d[i] < d[i+1]:
    count += 1
    
print(count)
Buggy python submission (verdict: Runtime Error):
X = int(input())

def Sum_Digit(X):
  SUM = 0
  while X >= 1:
    SUM += X%10
    X = int((X - X%10)/10)
  return SUM

print(S)
if X%S == 0:
  print("Yes")
else:
  print("No")

Fixed submission:
X = int(input())

def Sum_Digit(X):
  SUM = 0
  while X >= 1:
    SUM += X%10
    X = int((X - X%10)/10)
  return SUM

S = Sum_Digit(X)
if X%S == 0:
  print("Yes")
else:
  print("No")

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

def Sum_Digit(X):
  SUM = 0
  while X > 1:
    SUM += X%10
    X = int((X - X%10)/10)
  return SUM

S = Sum_Digit(X)
if X%S == 0:
  print("Yes")
else:
  print("No")

Fixed submission:
X = int(input())

def Sum_Digit(X):
  SUM = 0
  while X >= 1:
    SUM += X%10
    X = int((X - X%10)/10)
  return SUM

S = Sum_Digit(X)
if X%S == 0:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
[N, M] = list(map(int, input().split()))
[s, e] = [ [], [] ]
for _ in range(M):
  input_line = list(map(int, input().split()))
  s.append(input_line[0])
  e.append(input_line[1])
bucket = {}

for i in range(M):
  if s[i] in bucket and e[i] in bucket:
    bucket[s[i]].append(s[i])
    bucket[e[i]].append(e[i])
  elif s[i] in bucket:
    bucket[s[i]].append(s[i])
    bucket[e[i]] = [e[i]]
  elif e[i] in bucket:
    bucket[s[i]] = [s[i]]
    bucket[e[i]].append(e[i])
  else:
    bucket[s[i]] = [s[i]]
    bucket[e[i]] = [e[i]]

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

Fixed submission:
[N, M] = list(map(int, input().split()))
[s, e] = [ [], [] ]
for _ in range(M):
  input_line = list(map(int, input().split()))
  s.append(input_line[0])
  e.append(input_line[1])
bucket = {}
for i in range(1, N+1):
  bucket[i] = []

for i in range(M):
  if s[i] in bucket and e[i] in bucket:
    bucket[s[i]].append(s[i])
    bucket[e[i]].append(e[i])
  elif s[i] in bucket:
    bucket[s[i]].append(s[i])
    bucket[e[i]] = [e[i]]
  elif e[i] in bucket:
    bucket[s[i]] = [s[i]]
    bucket[e[i]].append(e[i])
  else:
    bucket[s[i]] = [s[i]]
    bucket[e[i]] = [e[i]]

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

Buggy python submission (verdict: Runtime Error):
[N, M] = list(map(int, input().split()))
[s, e] = [ [], [] ]
for _ in range(N):
  input_line = list(map(int, input().split()))
  s.append(input_line[0])
  e.append(input_line[1])
bucket = {}

for i in range(N):
  if s[i] in bucket and e[i] in bucket:
    bucket[s[i]].append(s[i])
    bucket[e[i]].append(e[i])
  elif s[i] in bucket:
    bucket[s[i]].append(s[i])
    bucket[e[i]] = [e[i]]
  elif e[i] in bucket:
    bucket[s[i]] = [s[i]]
    bucket[e[i]].append(e[i])
  else:
    bucket[s[i]] = [s[i]]
    bucket[e[i]] = [e[i]]

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


Fixed submission:
[N, M] = list(map(int, input().split()))
[s, e] = [ [], [] ]
for _ in range(M):
  input_line = list(map(int, input().split()))
  s.append(input_line[0])
  e.append(input_line[1])
bucket = {}
for i in range(1, N+1):
  bucket[i] = []

for i in range(M):
  if s[i] in bucket and e[i] in bucket:
    bucket[s[i]].append(s[i])
    bucket[e[i]].append(e[i])
  elif s[i] in bucket:
    bucket[s[i]].append(s[i])
    bucket[e[i]] = [e[i]]
  elif e[i] in bucket:
    bucket[s[i]] = [s[i]]
    bucket[e[i]].append(e[i])
  else:
    bucket[s[i]] = [s[i]]
    bucket[e[i]] = [e[i]]

for i in range(1, N+1):
  print(len(bucket[i]))
Buggy python submission (verdict: Time Limit Exceeded):
S=input()
Q=int(input())
snt=1
for i in range(Q):
    inp=input().split()
    if inp[0]=="1":
        snt*=(-1)
    else:
        F=int(inp[1])
        C=inp[2]
        if (2*F-3)*snt>0:
            S=S+C
        else:
            S=C+S
if snt==1:
    print(S)
else:
    for i in range(len(S)):
        print(S[len(S)-1-i],end="")
    print()


Fixed submission:
from collections import deque
S=deque(input())
Q=int(input())
snt=1
for i in range(Q):
    inp=input().split()
    if inp[0]=="1":
        snt*=(-1)
    else:
        F=int(inp[1])
        C=inp[2]
        if (2*F-3)*snt>0:
            #S=S+C
            S.append(C)
        else:
            #S=C+S
            S.appendleft(C)
if snt==1:
    #print(S)
    for i in range(len(S)):
        print(S.popleft(),end="")
    print()
else:
    for i in range(len(S)):
        #print(S[len(S)-1-i],end="")
        print(S.pop(),end="")
    print()
Buggy python submission (verdict: Time Limit Exceeded):
M=10**9+7
N=int(input())
la=list(map(int,input().split()))
ans=0
for i in range(60):
    n0=0
    n1=0
    for j in range(N):
        if la[j]&1:
            n1+=1
        else:
            n0+=1
        la[j]>>=1
    ans=(ans+n0*n1%M*(2**i%M))%M
print(ans)


Fixed submission:
M=10**9+7
N=int(input())
la=list(map(int,input().split()))
ans=0
for i in range(60):
    n0=0
    n1=0
    for j in range(N):
        if la[j]&1:
            n1+=1
        else:
            n0+=1
        la[j]>>=1
    ans=(ans+n0*n1%M*(2**i%M))%M
print(ans)
Buggy python submission (verdict: Runtime Error):
X=int(input())
ldp=[0 for i in range(X+1)]
for i in range(100,106):
    ldp[i]=1
for i in range(106,X+1):
    if sum(ldp[i-105:i-99])>=1:
        ldp[i]=1
print(ldp[X])


Fixed submission:
X=int(input())
m=X%100
nmin=0
for i in range(5,0,-1):
    nmin+=m//i
    m=m-(m//i)*i
if nmin>(X//100):
    print("0")
else:
    print("1")
Buggy python submission (verdict: Runtime Error):
H,W,K=map(int,input().split())
ls=[]
for i in range(H):
    ls.append(input())
ld=[]
f=0
#n=1
ns=0
for i in range(H):
    nstmp=0
    ld.append([])
    for j in range(W):
        if ls[i][j]=="#":
            nstmp+=1
            ns+=1
            if nstmp==2:
                #ld[i].append(j)
                #n+=1
                #ld[i].append((j,ns))
                ld[i].append((j,ns-1))#jより小さいところはns-1区画
                nstmp=1
                #n+=1
    if nstmp==1:
        ld[i].append((j+1,ns))
    if not ld[i]:
        if i==0:
            f=1
        else:
            ld[i]=ld[i-1]
    #n+=1
if f==1:
    ld[0]=ld[1]
#print(ld)
for i in range(H):
    k=0
    for j in range(W):
        if j>=ld[i][k][0]:
            k+=1
        print(ld[i][k][1],end=" ")
    print("")


Fixed submission:
H,W,K=map(int,input().split())
ls=[]
for i in range(H):
    ls.append(input())
ld=[]
#f=0
f=-1
#n=1
ns=0
for i in range(H):
    nstmp=0
    ld.append([])
    for j in range(W):
        if ls[i][j]=="#":
            nstmp+=1
            ns+=1
            if nstmp==2:
                #ld[i].append(j)
                #n+=1
                #ld[i].append((j,ns))
                ld[i].append((j,ns-1))#jより小さいところはns-1区画
                nstmp=1
                #n+=1
    #print("j",j)
    if nstmp==1:
        ld[i].append((j+1,ns))
    if not ld[i]:
        if i==0:
            f=0
        elif not ld[i-1]:
            f+=1
        else:
            ld[i]=ld[i-1]
    #n+=1
#if f==1:
    #ld[0]=ld[1]
if f>-1:
    for i in range(f,-1,-1):
        ld[i]=ld[i+1]
#print(ld)
for i in range(H):
    k=0
    for j in range(W):
        if j<ld[i][k][0]:
            print(ld[i][k][1],end=" ")
        else:
            k+=1
            print(ld[i][k][1],end=" ")
    print("")
Buggy python submission (verdict: Runtime Error):
X,Y=map(int,input().split())
N=10**9+7
def kaizyou(n):
    l=[1]
    for i in range(1,n+1):
        ll=(l[i-1]*i)%N
        l.append(ll)
    return l
def modpow(a,n,p):#a^n mod p ,O(log n)
    res=1
    while n>0:
        if n&1:#１とのビット論理積が１、つまり奇数
            res=res*a%p
        a=a*a%p
        n>>=1
        #ビットの右シフト_2進数表記のnを小数点を固定して右に１桁ずらす_１桁小さくなる
    return res
if (2*X-Y)%3==0 and (2*Y-X)%3==0:
    nx=int((2*X-Y)/3)
    ny=int((2*Y-X)/3)
    l=kaizyou(nx+ny)
    nxdv=modpow(l[nx],N-2,N)
    nydv=modpow(l[ny],N-2,N)
    ans=l[-1]*nxdv%N
    ans=ans*nydv%N
    print(ans)
else:
    print(0)


Fixed submission:
X,Y=map(int,input().split())
N=10**9+7
def kaizyou(n):
    l=[1]
    for i in range(1,n+1):
        ll=(l[i-1]*i)%N
        l.append(ll)
    return l
def modpow(a,n,p):#a^n mod p ,O(log n)
    res=1
    while n>0:
        if n&1:#１とのビット論理積が１、つまり奇数
            res=res*a%p
        a=a*a%p
        n>>=1
        #ビットの右シフト_2進数表記のnを小数点を固定して右に１桁ずらす_１桁小さくなる
    return res
if (2*X-Y)%3==0 and (2*Y-X)%3==0 and 2*X-Y>=0 and 2*Y-X>=0:
    nx=int((2*X-Y)/3)
    ny=int((2*Y-X)/3)
    l=kaizyou(nx+ny)
    nxdv=modpow(l[nx],N-2,N)
    nydv=modpow(l[ny],N-2,N)
    ans=l[-1]*nxdv%N
    ans=ans*nydv%N
    print(ans)
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left
N=int(input())
ll=list(map(int,input().split()))
ll.sort()
ans=0
for i in range(N):
    for j in range(i+1,N):
        delta=bisect_left(ll,ll[i]+ll[j],lo=j)-j-1
        if delta>0:
            ans+=delta
        #print(i,j,delta)
print(ans)



Fixed submission:
from bisect import bisect_left
N=int(input())
ll=list(map(int,input().split()))
ll.sort()
ans=0
for i in range(N):
    for j in range(i+1,N):
        if j==i+1:
            delta=bisect_left(ll,ll[i]+ll[i+1],lo=i+1)-i-2
            if delta>0:
                ans+=delta
            in_b=delta+i+1+1
        else:
            if in_b!=N:
                delta=bisect_left(ll,ll[i]+ll[j],lo=in_b)-j-1
            else:
                delta=N-j-1
            if delta>0:
                ans+=delta
            in_b=delta+j+1
print(ans)

Buggy python submission (verdict: Runtime Error):
from bisect import bisect_left
N=int(input())
ll=list(map(int,input().split()))
ll.sort()
ans=0
for i in range(N):
    delta=bisect_left(ll,ll[i]+ll[i+1],lo=i+1)-i-2
    if delta>0:
        ans+=delta
    in_b=delta+i+1+1
    for j in range(i+2,N):
        if in_b!=N:
            delta=bisect_left(ll,ll[i]+ll[j],lo=in_b)-j-1
        else:
            delta=N
        if delta>0:
            ans+=delta
        in_b=delta+j+1
print(ans)

Fixed submission:
from bisect import bisect_left
N=int(input())
ll=list(map(int,input().split()))
ll.sort()
ans=0
for i in range(N):
    for j in range(i+1,N):
        if j==i+1:
            delta=bisect_left(ll,ll[i]+ll[i+1],lo=i+1)-i-2
            if delta>0:
                ans+=delta
            in_b=delta+i+1+1
        else:
            if in_b!=N:
                delta=bisect_left(ll,ll[i]+ll[j],lo=in_b)-j-1
            else:
                delta=N-j-1
            if delta>0:
                ans+=delta
            in_b=delta+j+1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left
N=int(input())
ll=list(map(int,input().split()))
ll.sort()
ans=0
for i in range(N):
    for j in range(i+1,N):
        delta=bisect_left(ll,ll[i]+ll[j],lo=j)-j-1
        if delta>0:
            ans+=delta
        #print(i,j,delta)
print(ans)

Fixed submission:
from bisect import bisect_left
N=int(input())
ll=list(map(int,input().split()))
ll.sort()
ans=0
for i in range(N):
    for j in range(i+1,N):
        if j==i+1:
            delta=bisect_left(ll,ll[i]+ll[i+1],lo=i+1)-i-2
            if delta>0:
                ans+=delta
            in_b=delta+i+1+1
        else:
            if in_b!=N:
                delta=bisect_left(ll,ll[i]+ll[j],lo=in_b)-j-1
            else:
                delta=N-j-1
            if delta>0:
                ans+=delta
            in_b=delta+j+1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
A,B=map(int,input().split())
import sys
input=sys.stdin.readline
sys.setrecursionlimit(1000000000)
def gcd(a,b):#最大公約数を返す。Euclid
    if a<b:
        a,b=b,a
    if b==0:
        return a
    return gcd(b,a%b)
c=gcd(A,B)
#print(c)
if c==1:
    print(1)
else:
    sqrtc=int(c**(1/2))
    lf=[0 for i in range(c-1)]#2,3,,,,c
    #print(lf)
    for i in range(sqrtc):
        if lf[i]==0:
            for j in range(i+2,c//(i+2)+1):
                lf[(i+2)*j-2]=1
    #print(lf)
    ans=1
    for i in range(c-1):
        if lf[i]==0 and c%(i+2)==0:
            ans+=1

    #print(c-sum(lf)+1)
    print(ans)


Fixed submission:
A,B=map(int,input().split())
import sys
input=sys.stdin.readline
sys.setrecursionlimit(1000000000)
def gcd(a,b):#最大公約数を返す。Euclid
    if a<b:
        a,b=b,a
    if b==0:
        return a
    return gcd(b,a%b)
c=gcd(A,B)
#print(c)
sqrtc=int(c**(1/2))
vc=c
ans=1
for i in range(2,sqrtc+1):
    if vc%i==0:
        ans+=1
        vc/=i
        while vc%i==0:
            vc/=i
if vc!=1:
    ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
A,B=map(int,input().split())
import sys
input=sys.stdin.readline
sys.setrecursionlimit(1000000000)
def gcd(a,b):#最大公約数を返す。Euclid
    if a<b:
        a,b=b,a
    if b==0:
        return a
    return gcd(b,a%b)
c=gcd(A,B)
#print(c)
if c==1:
    print(1)
else:
    sqrtc=int(c**(1/2))
    lf=[0 for i in range(c-1)]#2,3,,,,c
    #print(lf)
    for i in range(sqrtc):
        if lf[i]==0:
            for j in range(2,c//(i+2)+1):
                lf[(i+2)*j-2]=1
    #print(lf)
    ans=1
    for i in range(c-1):
        if lf[i]==0 and c%(i+2)==0:
            ans+=1

    #print(c-sum(lf)+1)
    print(ans)

Fixed submission:
A,B=map(int,input().split())
import sys
input=sys.stdin.readline
sys.setrecursionlimit(1000000000)
def gcd(a,b):#最大公約数を返す。Euclid
    if a<b:
        a,b=b,a
    if b==0:
        return a
    return gcd(b,a%b)
c=gcd(A,B)
#print(c)
sqrtc=int(c**(1/2))
vc=c
ans=1
for i in range(2,sqrtc+1):
    if vc%i==0:
        ans+=1
        vc/=i
        while vc%i==0:
            vc/=i
if vc!=1:
    ans+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect


N,M=map(int,input().split())
la=list(map(int,input().split()))
la.sort()
for i in range(M):
    #la.sort()
    #la[N-1]/=2
    ll=la[N-1]/2
    la.pop()
    #la.insert(nibutan(0,N-2,la,ll),ll)
    bisect.insort_left(la,ll,0,N-1)

ans=0
for i in range(N):
    ans+=int(la[i])
print(ans)


Fixed submission:
import heapq
N,M=map(int,input().split())
la=list(map(lambda x:-int(x),input().split()))
heapq.heapify(la)
#la.sort()
for i in range(M):
    ll=heapq.heappop(la)/2
    heapq.heappush(la,ll)
ans=0
for i in range(N):
    ans+=int(-heapq.heappop(la))
print(ans)

Buggy python submission (verdict: Runtime Error):
def nibutan(a,b,l,x):#一つ後ろ
    while a+1!=b:
        mid=int((a+b)/2)
        if x<l[mid]:
            b=mid
        elif x>l[mid]:
            a=mid
        else:
            return mid
    if x<=l[a]:
        return a
    elif x<=l[b]:
        return b
    else:
        return b+1


N,M=map(int,input().split())
la=list(map(int,input().split()))
la.sort()
for i in range(M):
    #la.sort()
    la[N-1]/=2
    ll=la[N-1]
    la.pop()
    la.insert(nibutan(0,N-2,la,ll),ll)

ans=0
for i in range(N):
    ans+=int(la[i])
print(ans)


Fixed submission:
import heapq
N,M=map(int,input().split())
la=list(map(lambda x:-int(x),input().split()))
heapq.heapify(la)
#la.sort()
for i in range(M):
    ll=heapq.heappop(la)/2
    heapq.heappush(la,ll)
ans=0
for i in range(N):
    ans+=int(-heapq.heappop(la))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
la=list(map(int,input().split()))
#la.sort()
for i in range(M):
    la.sort()
    la[N-1]/=2
ans=0
for i in range(N):
    ans+=int(la[i])
print(ans)


Fixed submission:
import heapq
N,M=map(int,input().split())
la=list(map(lambda x:-int(x),input().split()))
heapq.heapify(la)
#la.sort()
for i in range(M):
    ll=heapq.heappop(la)/2
    heapq.heappush(la,ll)
ans=0
for i in range(N):
    ans+=int(-heapq.heappop(la))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
ls=[]
for i in range(N):
    s=input()
    dc={}
    for ss in s:
        if ss in dc.keys():
            dc[ss]+=1
        else:
            dc[ss]=1
    ls.append(dc)
ans=0
#print(ls)
for i in range(N):
    for j in range(i+1,N):
        if ls[i]==ls[j]:
            ans+=1
print(ans)


Fixed submission:
N=int(input())
#ls=[]
ds={}
for i in range(N):
    s=input()
    #dc={}
    #for ss in s:#sを辞書化
        #if ss in dc.keys():
            #dc[ss]+=1
        #else:
            #dc[ss]=1
    #s=sorted(s)
    s="".join(sorted(s))#sを比較できる形へ

    #ls.append(dc)
    #if dc in ds:#文字列がそれぞれ何個重複しているかわかる
    #_TypeError: unhashable type: 'dict'
    #_辞書のキーはイミュータブルでなければならない
    #    ds[dc]+=1
    #else:
    #    ds[dc]=1"""

    if s in ds:
        ds[s]+=1
    else:
        ds[s]=1

ans=0
for i in ds:
    ans+=ds[i]*(ds[i]-1)/2
#print(ls)
#for i in range(N):
    #for j in range(i+1,N):
        #if ls[i]==ls[j]:
        #    ans+=1

    #dc=ls[i]
    #del ls[i]
    #if dc in ls:
print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
lh=list(map(int,input().split()))
ldp=[float("inf") for i in range(N)]
"""for i in range(K):
    if i<=N-1:
        ldp[i]="""
ldp[0]=0
for i in range(1,N):
    mintmp=float("inf")
    for j in range(1,K+1):
        if i-j>=0:
            mintmp=min(mintmp,ldp[i-j]+abs(lh[i]-lh[i-j]))
    ldp[i]=mintmp
#print(ldp)
print(mintmp)


Fixed submission:
N,K=map(int,input().split())
lh=list(map(int,input().split()))
ldp=[float("inf") for i in range(N)]
"""for i in range(K):
    if i<=N-1:
        ldp[i]="""
ldp[0]=0
for i in range(1,N):
    mintmp=float("inf")
    for j in range(1,K+1):
        if i-j>=0:
            mintmp=min(mintmp,ldp[i-j]+abs(lh[i]-lh[i-j]))
    ldp[i]=mintmp
#print(ldp)
print(mintmp)