Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
Base = input().split(" ")
N = int(Base[0])
TL = int(Base[1])
TX = 10000

for i in range(N):
    Roi = input().split(" ")
    Coi = int(Roi[0])
    TLi = int(Roi[1])
    if TL >= TLi:
        if TX >= int(Coi) or i ==0:
            TX = Coi
if TX == 10000:
    print("TLE")
elif:
    print(TX)

Fixed submission:
Base = input().split(" ")
N = int(Base[0])
TL = int(Base[1])
TX = 10000

for i in range(N):
    Roi = input().split(" ")
    Coi = int(Roi[0])
    TLi = int(Roi[1])
    if TL >= TLi:
        if TX >= int(Coi) or i ==0:
            TX = Coi
if TX == 10000:
    print("TLE")
else:
    print(TX)
Buggy python submission (verdict: Runtime Error):
N = int(input())
NA = int(input())
NX = NA.split(" ")
NW = []
for i in range (1,N+1):
    Ni = int(NX.count(i))
    NW.append(Ni)
NN = NW.sort()
print(NW)
S = 0
for x in range (0,N-2):
    S = S + NW[x]
print(S)

Fixed submission:
X = input()
Xn = X.replace("1","N")
Xo = Xn.replace("9","1")
print(Xo.replace("N","9"))
Buggy python submission (verdict: Runtime Error):
N = int(input())
if N <=111:
    print("111")
elif N <=222:
    print("222")
elif N <=333:
    print("333")
elif N <= 444:
    print("444")
elif N <=555:
    print("555")
elif N <=666
    print("666")
elif N <=777:
    print("777")
elif N <=888:
    print("888")
else:
    print("999")

Fixed submission:
N = int(input())
if N <=111:
    print("111")
elif N <=222:
    print("222")
elif N <=333:
    print("333")
elif N <= 444:
    print("444")
elif N <=555:
    print("555")
elif N <=666:
    print("666")
elif N <=777:
    print("777")
elif N <=888:
    print("888")
else:
    print("999")
Buggy python submission (verdict: Runtime Error):
LX = list(input().split(" "))sort(reverse=True)
print(int(LX[0]+LX[1])+int(LX[2]))

Fixed submission:
LX = list(input().split(" "))
LX.sort(reverse=True)
print(int(LX[0]+LX[1])+int(LX[2]))
Buggy python submission (verdict: Runtime Error):
if N <=999:
    print("ABC")
else:
    print("ABD")

Fixed submission:
N = int(input())
if N <=999:
    print("ABC")
else:
    print("ABD")
Buggy python submission (verdict: Runtime Error):
h,w = map(int,input().split())

mp = []
for i in range(h):
    tmp = list(input())
    tml = []
    for j in range(w):
        tml.append(0 if tmp[j] == "." else 1)
    mp.append(tml)

flg = 0
for i in range(1,h-1):
    for j in range(1,w-1):
        if(mp[i-1][j]+mp[i+1][j]+mp[i][j-1]+mp[i][j+1] == 0):
            flag = 1
            break
        
ans = ["YES","NO"]
		
print(ans[flag])

Fixed submission:
h,w = map(int,input().split())

mp = []
for i in range(h):
    tmp = list(input())
    tml = []
    for j in range(w):
        tml.append(0 if tmp[j] == "." else 1)
    mp.append(tml)
    
#print(mp)

flg = 0
for i in range(1,h-1):
    for j in range(1,w-1):
        if((mp[i][j] == 1) and (mp[i-1][j]+mp[i+1][j]+mp[i][j-1]+mp[i][j+1] == 0)):
            flg = 1
 #           print("{}, {}".format(i,j))
            break
        
ans = ["Yes","No"]
		
print(ans[flg])
Buggy python submission (verdict: Runtime Error):
n, x = map(int,input().split())
m = []
ans = len(n)
for i in range(n):
    m.append(int(input()))
x -= sum(m)
ans+=(x//min(m))

Fixed submission:
n, x = map(int,input().split())
m = []
ans = n
for i in range(n):
    m.append(int(input()))
x -= sum(m)
ans+=(x//min(m))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import copy

n = int(input())

a = [0] + list(map(int,input().split())) + [0]

#print(a)


for i in range(1,len(a)-1):
    ans = 0
    for j in range(1,len(a)):
        if(j-1 != i and j != i):
            ans += abs(a[j]-a[j-1])
        elif(j == i):
            ans += abs(a[j+1]-a[j-1])
            j+=1
    print(ans)

    

Fixed submission:
import copy

n = int(input())

a = [0] + list(map(int,input().split())) + [0]

#print(a)
anst = 0
for j in range(1,len(a)):
    anst += abs(a[j]-a[j-1])

for j in range(1,len(a)-1):
    ans = anst
    ans -= abs(a[j-1]-a[j]) + abs(a[j]-a[j+1])
    ans += abs(a[j-1]-a[j+1])
    print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()

ans = 0

if (len(s) >= 4):
    if (s[0:4] == "YAKI"):
        ans = 1

if(ans == 1)
    print("Yes")
else:
    print("No")

Fixed submission:
s = input()

ans = 0

if (len(s) >= 4):
    if (s[0:4] == "YAKI"):
        ans = 1

if (ans == 1):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n  = int(input())
s = [int(input()) for i in range(n)]


ans = 0
for i in range(0,2**n):
    bits = (bin(i)[2:]).zfill(n)
    tmp = sum([j * int(k) for j, k in zip(s, bits)])
    ans = max(ans, tmp if tmp % 10 != 0 else 0)

print(ans)

Fixed submission:
n  = int(input())
s = [int(input()) for i in range(n)]

s.sort()
ans = sum(s)
if (ans % 10 != 0):
    print(ans)
else:
    for i in s:
        if (i % 10 != 0):
            print(ans - i)
            break
    else:
        print(0)
Buggy python submission (verdict: Runtime Error):
s = input()

for i in range(len(s) - 2):
    if (s[i] == s[i + 1] or s[i] == s[i + 2]):
        print("{} {}".format(i + 1, i + 3))
        break
else:
    if (s[-2] == s[-1]):
        print("{} {}".format(len(n) - 1, len(n)))
    else:
        print("-1 -1")



Fixed submission:
s = input()

for i in range(len(s) - 2):
    if (s[i] == s[i + 1] or s[i] == s[i + 2]):
        print("{} {}".format(i + 1, i + 3))
        break
else:
    if (s[-2] == s[-1]):
        print("{} {}".format(len(s) - 1, len(s)))
    else:
        print("-1 -1")
Buggy python submission (verdict: Runtime Error):
s = list(input())

ans = []
for i in s:
    if(i == "B"):
        ans.pop(-1)
    else:
        ans+=i

for i in ans:
    print(i, end="")

print("")

Fixed submission:
s = list(input())

ans = []
for i in s:
    if (i == "B"):
        if(len(ans)!=0):
            ans.pop(-1)
    else:
        ans+=i

for i in ans:
    print(i, end="")

print("")
Buggy python submission (verdict: Runtime Error):
list(input())
t=list(input())
a=[0]*27
for i in range(len(s)):
  if a[ord(s[i])-96]==0:
    a[ord(s[i])-96]=ord(t[i])-96
  elif a[ord(s[i])-96]==ord(t[i])-96:
    continue
  else:
    print("No")
    exit()
print("Yes")


Fixed submission:
a=list(input())
b=list(input())
from collections import Counter
def f(s):
    return sorted(Counter(s).values())
if f(a)==f(b):
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
s=list(map(int,input().split()))
t=list(map(int,input().split()))
a=[0]*26
for i in range(len(s)):
  if a[ord(s[i])]==0:
    a[ord(s[i])]=ord(t[i])
  elif a[ord(s[i])]==ord(t[i]):
    continue
  else:
    print("No")
    exit()
print("Yes")

Fixed submission:
a=list(input())
b=list(input())
from collections import Counter
def f(s):
    return sorted(Counter(s).values())
if f(a)==f(b):
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
s=list(map(int,input().split()))
t=list(map(int,input().split()))
a=[0]*26
for i in range(len(s)):
  if a[ord(s[i])]==0:
    a[ord(s[i])]=ord(t[i])
  elif a[ord(s[i])]==ord(t[i]):
    continue
  else:
    print("No")
    exit()

Fixed submission:
a=list(input())
b=list(input())
from collections import Counter
def f(s):
    return sorted(Counter(s).values())
if f(a)==f(b):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
t=[]
s=list(map(int,input().split()))
for i in s:
    t.append(abs(i-k))
import math
from functools import reduce
print(reduce(math.gcd,t))

Fixed submission:
n,k=map(int,input().split())
t=[]
s=list(map(int,input().split()))
for i in s:
    t.append(abs(i-k))
from fractions import gcd
from functools import reduce
print(reduce(gcd,t))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n,m,q=map(int,input().split())
s=[[] for i in range(n+1)]
t=[]
ss=[]
for i in range(m):
    x,y=map(int,input().split())
    s[x]+=[y]

for i in range(q):
    x,y=map(int,input().split())
    ss=s[x:]
    ww=[]
    for j in range(n-x+1):
        ww+=ss[j]
    ww=np.array(ww)
    print(len(ww[ww<=y]))


Fixed submission:
from itertools import accumulate
n,m,q=map(int,input().split())
s=[[0 for i in range(n)] for j in range(n)]
for i in range(m):
    x,y=map(int,input().split())
    s[n-x][y-1]+=1
def f(s):
    for i in range(len(s)):
        s[i]=list(accumulate(s[i]))
f(s)
s=list(zip(*s))
f(s)
for i in range(q):
    x,y=map(int,input().split())
    print(s[y-1][n-x])

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left
import numpy as np
n,m,q=map(int,input().split())
s=[]
t=[]
ss=[]
def aa(m):
    for i in range(m):
        x,y=map(int,input().split())
        ss.append((x,y))
    ss.sort()
    return ss
def bb(ss):
    global s,t
    for x,y in ss:
        s+=[x]
        t+=[y]
    return s,t
def cc(q,s,t):
    for i in range(q):
        x,y=map(int,input().split())
        bi=bisect_left(s,x)
        u=np.array(t[bi:])
        print(len(u[u<=y]))
    return
s,t=bb(aa(m))
cc(q,s,t)


Fixed submission:
from itertools import accumulate
n,m,q=map(int,input().split())
s=[[0 for i in range(n)] for j in range(n)]
for i in range(m):
    x,y=map(int,input().split())
    s[n-x][y-1]+=1
def f(s):
    for i in range(len(s)):
        s[i]=list(accumulate(s[i]))
f(s)
s=list(zip(*s))
f(s)
for i in range(q):
    x,y=map(int,input().split())
    print(s[y-1][n-x])

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left
import numpy as np
n,m,q=map(int,input().split())
s=[]
t=[]
ss=[]
for i in range(m):
    x,y=map(int,input().split())
    ss.append((x,y))
ss.sort()
for x,y in ss:
    s+=[x]
    t+=[y]
for i in range(q):
    x,y=map(int,input().split())
    bi=bisect_left(s,x)
    u=np.array(t[bi:])
    print(len(u[u<=y]))

Fixed submission:
from itertools import accumulate
n,m,q=map(int,input().split())
s=[[0 for i in range(n)] for j in range(n)]
for i in range(m):
    x,y=map(int,input().split())
    s[n-x][y-1]+=1
def f(s):
    for i in range(len(s)):
        s[i]=list(accumulate(s[i]))
f(s)
s=list(zip(*s))
f(s)
for i in range(q):
    x,y=map(int,input().split())
    print(s[y-1][n-x])
Buggy python submission (verdict: Time Limit Exceeded):
s=[1,0,0,0]
n=input()
for i in n:
    if i=="?":
        for j in range(3,0,-1):
            s[j]*=3
            s[j]+=s[j-1]
            s[j]%=10**9+7
        s[0]*=3
    else:
        j="1ABC".index(i)
        s[j]+=s[j-1]
        s[j]%=10**9+7
print(s[3])

Fixed submission:
t=10**9+7
s=[1,0,0,0]
n=input()
for i in n:
    if i=="?":
        for j in range(3,0,-1):
            s[j]*=3
            s[j]+=s[j-1]
            s[j]%=t
        s[0]*=3
        s[0]%=t
    else:
        j="1ABC".index(i)
        s[j]+=s[j-1]
        s[j]%=t
print(s[3])
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate
N=int(input())
t=[]
s=list(map(int,input().split()))
for i in range(2,N-1):
    p=10**9
    for j in range(1,len(s[:i])):
        a=sum(s[:i][:j])
        b=sum(s[:i][j:])
        q=abs(a-b)
        if p>q:
            p=q
            (x,y)=(a,b)
    p=10**9        
    for j in range(1,len(s[i:])):
        a=sum(s[i:][:j])
        b=sum(s[i:][j:])
        q=abs(a-b)
        if p>q:
            p=q
            (x1,y1)=(a,b)
    l=(x,y,x1,y1)
    t.append(max(l)-min(l))
print(min(t))    

Fixed submission:
from itertools import accumulate
N=int(input())
s=list(accumulate(map(int,input().split())))
ans=10**9
p=0
q=2
for i in range(2,N-1):
    while p<i-1 and abs(s[i-1]-2*s[p+1])<abs(s[i-1]-2*s[p]):
        p+=1
    if q<i:
        q+=1
    while q<N and abs(s[i-1]-2*s[q+1]+s[-1])<abs(s[i-1]-2*s[q]+s[-1]):   
        q+=1
    t=[s[q]-s[i-1],s[-1]-s[q],s[p],s[i-1]-s[p]]
    w=max(t)-min(t)
    ans=min(ans,w) 
print(ans)
Buggy python submission (verdict: Runtime Error):
from itertools import product
t=[]
ans=0
n,m=map(int,input().split())
s=list(product([1,-1],repeat=3))
for i in range(n):
    li=[]
    p,q,r=map(int,input().split())
    for a,b,c in s:
        li.append(a*p+b*q+c*r)
    t+=[li]
for j in list(zip((*t))):
    p=sum(sorted(j)[n-m:])
    ans=max(ans,p)
print(ans)


Fixed submission:
from itertools import product
t=[]
ans=0
n,m=map(int,input().split())
s=list(product([1,-1],repeat=3))
for i in range(n):
    li=[]
    p,q,r=map(int,input().split())
    for a,b,c in s:
        li.append(a*p+b*q+c*r)
    t+=[li]
for j in list(zip(*t)):
    p=sum(sorted(j)[n-m:])
    ans=max(ans,p)
print(ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np
s=[]
tt=[]
n,m=map(int,input().split())
for i in range(n):
    a,b,c=map(int,input().split())
    s.append([a,b,c])
import itertools
t=list(itertools.permutations(s,m))
for i in t:
    total=np.zeros((3))
    for j in range(m):
        total+=np.array(i[j])
        tt.append(abs(total[0])+abs(total[1])+abs(total[2])//1)
print(int(max(tt)))

Fixed submission:
from itertools import product
t=[]
ans=0
n,m=map(int,input().split())
s=list(product([1,-1],repeat=3))
for i in range(n):
    li=[]
    p,q,r=map(int,input().split())
    for a,b,c in s:
        li.append(a*p+b*q+c*r)
    t+=[li]
for j in list(zip(*t)):
    p=sum(sorted(j)[n-m:])
    ans=max(ans,p)
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=[]
t=1000
p=0
def f9(n,p):
    while n>=9:
        n//=9
        p+=1
        f9(n,p)
    return p
def f6(n,p):
    while n>=6:
        n//=6
        p+=1
        f6(n,p)
    return p    
s.append((n,0))
while s:
    a=s[0][0]
    b=s[0][1]
    if a<6:
    t=min(t,b+a)
    if t>=b+1:
        p=0
        s.append((a-9**f9(a,p),b+1))
        p=0
        s.append((a-6**f6(a,p),b+1))
    s.pop(0)    
print(t)




Fixed submission:
n=int(input())
s=[]
t=1000
p=0
def f9(n,p):
    while n>=9:
        n//=9
        p+=1
        f9(n,p)
    return p
def f6(n,p):
    while n>=6:
        n//=6
        p+=1
        f6(n,p)
    return p    
s.append((n,0))
while s:
    a=s[0][0]
    b=s[0][1]
    if a<6:
        t=min(t,b+a)
    if t>=b+1:
        p=0
        s.append((a-9**f9(a,p),b+1))
        p=0
        s.append((a-6**f6(a,p),b+1))
    s.pop(0)    
print(t)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=[]
t=[]
p=0
def f9(n,p):
    while n>=9:
        n//=9
        p+=1
        f9(n,p)
    return p
def f6(n,p):
    while n>=6:
        n//=6
        p+=1
        f6(n,p)
    return p    
s.append((n,0))
while s:
    a=s[0][0]
    b=s[0][1]
    if a<6:
        t.append(b+a)
    else:
        p=0
        s.append((a-9**f9(a,p),b+1))
        p=0
        s.append((a-6**f6(a,p),b+1))
    s.pop(0)    
print(min(t))




Fixed submission:
n=int(input())
s=[]
t=1000
p=0
def f9(n,p):
    while n>=9:
        n//=9
        p+=1
        f9(n,p)
    return p
def f6(n,p):
    while n>=6:
        n//=6
        p+=1
        f6(n,p)
    return p    
s.append((n,0))
while s:
    a=s[0][0]
    b=s[0][1]
    if a<6:
        t=min(t,b+a)
    if t>=b+1:
        p=0
        s.append((a-9**f9(a,p),b+1))
        p=0
        s.append((a-6**f6(a,p),b+1))
    s.pop(0)    
print(t)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
m=list(input())
ans=10**5
for i in range(n):
    p=0
    x=m[:i]
    y=m[i+1:]
    p=x.count("W")+y.count("E")
    ans=min(ans,p) 
print(ans)



Fixed submission:
n=int(input())
m=list(input())
p=m.count("E")
s=p
for i in m:
    if i=="E":
        p-=1
    else:
        p+=1
    s=min(s,p)
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
p=0
t=list(map(int,input().split()))
for i in range(N):
    k=1
    while k+i<N and t[i]&t[i+k]==0:
        t[i]+=t[i+k]
        k+=1
    p+=k
print(p)        



Fixed submission:
N=int(input())
t=list(map(int,input().split()))
l=1
k=t[0]
a=0
for i in range(N):
    while l<N and k&t[l]==0:
        k+=t[l]
        l+=1
    a+=l-i
    k-=t[i]
print(a)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
s=[]
t=list(map(int,input().split()))
for i in range(N):
    p=0
    for j in t[i+1:]:
        if t[i]&j==0:
            t[i]=t[i]^j
            p+=1
        else:
            s.append(p)
            break
    else:
        s.append(p)
q=N
for i in s:
    q+=i
print(q)    
        

Fixed submission:
N=int(input())
t=list(map(int,input().split()))
l=1
k=t[0]
a=0
for i in range(N):
    while l<N and k&t[l]==0:
        k+=t[l]
        l+=1
    a+=l-i
    k-=t[i]
print(a)
Buggy python submission (verdict: Runtime Error):
N=int(input())
s=list(map(int,input().split()))
t=sorted(s)
p=t[N//2]
q=t[N//2+1]
for i in range(N):
    if s[i]<=p:
        print(q)
    else:
        print(p)
        

Fixed submission:
N=int(input())
s=list(map(int,input().split()))
t=sorted(s)
p=t[N//2-1]
q=t[N//2]
for i in range(N):
    if s[i]<=p:
        print(q)
    else:
        print(p)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
s=list(map(int,input().split()))
for i in range(N):
    t,ans=[],0
    t+=s
    t.pop(i)
    t.insert(0,0)
    t.append(0)
    for k in range(N):
        ans+=abs(t[k]-t[k+1])
    print(ans)    
        

Fixed submission:
N=int(input())
s=list(map(int,input().split()))
s.insert(0,0)
s.append(0)
ans=0
for k in range(N+1):
    ans+=abs(s[k]-s[k+1])
for i in range(N):
    a,b,c=s[i]-s[i+1],s[i+1]-s[i+2],s[i]-s[i+2]
    if a*b>=0:
        print(ans)
    else:
        print(ans-abs(a)-abs(b)+abs(c))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
n=0
num=[]
for i in range(N):
    s=list(str(N-i))
    for j in range(len(s)):
        n+=int(s[j])
    num.append(n)
    n=0
print(max(num))        
        


Fixed submission:
def f(s):
    p=0
    for i in str(s):
        p+=int(i)
    return p
N=int(input())
i=1
ans=f(N)
while N>=10**i:
    p=f((N//10**i)*(10**i)-1)
    ans=max(ans,p)
    i+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
retu = input()
gyo1 = list(map(int,input().split()))
gyo2 = list(map(int,input().split()))
goal=[]
for i in range(retu):
    kai = sum(gyo1[0:i+1]) + sum(gyo2[i:])
    goal.append(kai)
print(max(goal))
    

Fixed submission:
# coding: utf-8
# hello worldと表示する
# coding: utf-8
# hello worldと表示する
retu = int(input())
gyo1 = list(map(int,input().split()))
gyo2 = list(map(int,input().split()))
num = 0
kai=0
boss=[]
for i in range(retu):
    for ii in range(i + 1):
        num += gyo1[ii]
    for iii in range(retu-i):
        num += gyo2[iii+i]
    boss.append(num)
    num=0
#print(boss)
oss = sorted(boss)
print(oss[retu-1])
Buggy python submission (verdict: Runtime Error):
N,ans,x=int(input()),0,0
s=sorted([int(input()) for i in range(N)])
for i in range(N):
    if s[i]>x:
        ans+=1
        x=s[i]
print(ans)        

Fixed submission:
# coding: utf-8
# hello worldと表示する
a,b=map(int,input().split())
ans=True
for i in range(a+1):
    for j in range(a+1-i):
        if ans==True:
            s=10000*i+5000*j+1000*(a-i-j)
            if s == b:
                print(str(i)+" "+str(j)+" "+str(a-i-j))
                ans = False
        else:
            break
if ans==True:
    print("-1 -1 -1")
Buggy python submission (verdict: Runtime Error):
s=sorted(input())
t=sorted(input(),reverse=True)
if s==t:
	print("No")
    exit()
a=sorted([s,t])
if a[0]==s:
    print("Yes")
else:
    print("No")


Fixed submission:
s=sorted(input())
t=sorted(input(),reverse=True)
a=sorted([s,t])
if s==t:
    print("No")
    exit()
if a[0]==s:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
s=list(map(int,input().split()))
t=list(set(s))
ans=0
for i in range(len(t)):
    u=s.count(t[i])-t[i]
    if u<0:
        ans+=s.count(t[i])
    if u>0:
        ans+=u
print(ans)   

Fixed submission:
N=int(input())
s,ans={},0
for i in list(map(int,input().split())):
    s[i]=s.get(i,0)+1
for c,v in s.items():
    if c<v:
        ans+=v-c
    if c>v:
        ans+=v
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
t=[]
s=list(map(int,input().split()))
def f(s):
    for i in list(set(s)):
        t.append(s.count(i))
    return sum(sorted(t)[:len(t)-m])   
print(f(s))  

Fixed submission:
N,K=map(int,input().split())
d,ans={},0
for i in list(map(int,input().split())):
    d[i]=d.get(i,0)+1
s=sorted(d.values())
for i in range(len(s)-K):
    ans+=s[i]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
t=[]
s=list(map(int,input().split()))
for i in list(set(s)):
    t.append(s.count(i))
print(sum(sorted(t)[:len(t)-m]))  


Fixed submission:
N,K=map(int,input().split())
d,ans={},0
for i in list(map(int,input().split())):
    d[i]=d.get(i,0)+1
s=sorted(d.values())
for i in range(len(s)-K):
    ans+=s[i]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
s=list(map(int,input().split()))
t=list(set(s))
ss,ans=[],0
for i in t:
    ss.append(s.count(i))
    ss=sorted(ss)
if len(ss)>K:
    for i in range(len(ss)-K):
        ans+=ss[i]
    print(ans)      
else:
    print("0")

Fixed submission:
N,K=map(int,input().split())
d,ans={},0
for i in list(map(int,input().split())):
    d[i]=d.get(i,0)+1
s=sorted(d.values())
for i in range(len(s)-K):
    ans+=s[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,c,d = list(input())
#print(b)
if a==b==c or b==c==d:
    print("Yes")
else:
    print("No

Fixed submission:
a,b,c,d = list(input())
if a==b==c or b==c==d:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
s=sorted(list(map(int,input().split())))
t=sorted(list(map(int,input().split())),reverse=True)
u=sorted(list(map(int,input().split())),reverse=True)
ans=0
for j in range(N):
    tt=[]
    for k in range(N):
        if s[j]<t[k]:
            tt.append(t[k])
        else:
            break
    for ii in range(len(tt)):
        for jj in range(N):
            if tt[ii]<u[jj]:
                ans+=1
            else:
                break
print(ans)            
                

Fixed submission:
import bisect
N=int(input())
a=sorted(list(map(int,input().split())))
b=list(map(int,input().split()))
c=sorted(list(map(int,input().split())))
ans=0
for i in b:
    aa=bisect.bisect_left(a,i)
    cc=N-bisect.bisect_right(c,i)
    ans+=aa*cc
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
s=list(map(int,input().split()))
t=list(map(int,input().split()))
u=list(map(int,input().split()))
ans=0
for j in range(N):
    tt=[]
    for k in range(N):
        if s[j]<t[k]:
            tt.append(t[k])
    for ii in range(len(tt)):
        for jj in range(N):
            if tt[ii]<u[jj]:
                ans+=1
print(ans)            

Fixed submission:
import bisect
N=int(input())
a=sorted(list(map(int,input().split())))
b=list(map(int,input().split()))
c=sorted(list(map(int,input().split())))
ans=0
for i in b:
    aa=bisect.bisect_left(a,i)
    cc=N-bisect.bisect_right(c,i)
    ans+=aa*cc
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=sorted(list(map(int,input().split())))
m=int(input())
t=sorted(list(map(int,input().split())))
for i in s:
    if i in t:
        t.remove(i)
if t==[]:
    print("YES")
else:
    print("NO")

Fixed submission:
from collections import Counter
input()
s=list(input().split())
s=Counter(s)
input()
for i in input().split():
    if s.get(i,0)==0:
        print("NO")
        break
    else:
        s[i]-=1
else:
    print("YES")

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n=int(input())
s=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))
ss=Counter(s)
tt=Counter(t)
s1=list(ss.keys())
s2=list(ss.values())
for i,j in tt.items():
    if i not in s:
        print("NO")
        exit()
    if s2[s1.index(i)]<j:
        print("NO")
        exit()
print("YES")

Fixed submission:
from collections import Counter
input()
s=list(input().split())
s=Counter(s)
input()
for i in input().split():
    if s.get(i,0)==0:
        print("NO")
        break
    else:
        s[i]-=1
else:
    print("YES")