Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N,A,B,C=map(int,input().split())
l=[int(input()) for i in range(n)]
inf=10**9

def dfs(cur,a,b,c):
    if cur==N:
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else inf
    ret0=dfs(cur+1,a,b,c)
    ret1=dfs(cur+1,a+l[cur],b,c)+10
    ret2=dfs(cur+1,a,b+l[cur],c)+10
    ret3=dfs(cur+1,a,b,c+l[cur])+10
    return min(ret0,ret1,ret2,ret3)

print(dfs(0,0,0,0))


Fixed submission:
N,A,B,C=map(int,input().split())
l=[int(input()) for i in range(N)]
inf=10**9

def dfs(cur,a,b,c):
    if cur==N:
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else inf
    ret0=dfs(cur+1,a,b,c)
    ret1=dfs(cur+1,a+l[cur],b,c)+10
    ret2=dfs(cur+1,a,b+l[cur],c)+10
    ret3=dfs(cur+1,a,b,c+l[cur])+10
    return min(ret0,ret1,ret2,ret3)

print(dfs(0,0,0,0))
Buggy python submission (verdict: Time Limit Exceeded):
a,b,q=map(int,input().split())
s=[]
for _ in range(a):
    s.append(int(input()))
t=[]
for _ in range(b):
    t.append(int(input()))
import bisect
for _ in range(q):
    x=int(input())
    sb=bisect.bisect_left(s,x)
    tb=bisect.bisect_left(t,x)
    ss=[x-s[max(sb-1,0)],x-s[min(sb,a-1)]]
    tt=[x-t[max(tb-1,0)],x-t[min(tb,b-1)]]
    l=[]
    for i in ss:
        for j in tt:
            if i*j>=0:
                l.append(max(abs(i),abs(j)))
            else:
                l.append(max(abs(i),abs(j))+2*min(abs(i),abs(j)))
    print(min(l))


Fixed submission:
a,b,q=map(int,input().split())
s=[int(input()) for _ in range(a)]
t=[int(input()) for _ in range(b)]
import bisect
for _ in range(q):
    x=int(input())
    sb=bisect.bisect_left(s,x)
    tb=bisect.bisect_left(t,x)
    ss=[x-s[max(sb-1,0)],x-s[min(sb,a-1)]]
    tt=[x-t[max(tb-1,0)],x-t[min(tb,b-1)]]
    l=[]
    for i in ss:
        for j in tt:
            if i*j>=0:
                l.append(max(abs(i),abs(j)))
            else:
                l.append(max(abs(i),abs(j))+2*min(abs(i),abs(j)))
    print(min(l))

Buggy python submission (verdict: Time Limit Exceeded):
a,b,q=map(int,input().split())
s=sorted([int(input()) for _ in range(a)])
t=sorted([int(input()) for _ in range(b)])
import bisect
for _ in range(q):
    x=int(input())
    ss=[x-s[max(bisect.bisect_left(s,x)-1,0)],x-s[min(bisect.bisect_right(s,x),a-1)]]
    tt=[x-t[max(bisect.bisect_left(t,x)-1,0)],x-t[min(bisect.bisect_right(t,x),b-1)]]
    l=[]
    for i in ss:
        for j in tt:
            if i*j>=0:
                l.append(max(abs(i),abs(j)))
            else:
                l.append(max(abs(i),abs(j))+2*min(abs(i),abs(j)))
    print(min(l))


Fixed submission:
a,b,q=map(int,input().split())
s=[int(input()) for _ in range(a)]
t=[int(input()) for _ in range(b)]
import bisect
for _ in range(q):
    x=int(input())
    sb=bisect.bisect_left(s,x)
    tb=bisect.bisect_left(t,x)
    ss=[x-s[max(sb-1,0)],x-s[min(sb,a-1)]]
    tt=[x-t[max(tb-1,0)],x-t[min(tb,b-1)]]
    l=[]
    for i in ss:
        for j in tt:
            if i*j>=0:
                l.append(max(abs(i),abs(j)))
            else:
                l.append(max(abs(i),abs(j))+2*min(abs(i),abs(j)))
    print(min(l))
Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
l=[]
n=0
m=0
cou=0
for i in range(h):
    x=input()
    if x==("."*w):
        cou+=1
        continue
    l.append(list(x))
for i in range(w):
    k=0
    for j in range(h-cou-1):
        if l[j][i]=="#":
            break
        else:
            k+=1
    if k==h-cou:
        for d in range(h-cou):
            del l[d][i]
for i in range(h-cou):
    l[i]="".join(l[i])
    print(l[i])



Fixed submission:
g=[0]*5
for _ in range(3):
    a,b=map(int,input().split())
    g[a]+=1
    g[b]+=1
if g.count(1)==2:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
x=sorted(list(map(int,input().split())))
if n>=m:
    print(0)
else:
    l=[]
    r=[]
    for i in range(m-1):
        l.append(x[i+1]-x[i])
    ll=sorted(l,reverse=True)
    for i in range(n-1):
        r.append(ll.pop(0))
    print(x[m-1]-x[0]-(sum(r)))


Fixed submission:
n,m=map(int,input().split())
x=sorted(list(map(int,input().split())))
if n>=m:
    print(0)
else:
    l=[]
    r=[]
    for i in range(m-1):
        l.append(x[i+1]-x[i])
    ll=sorted(l,reverse=True)
    for i in range(n-1):
        r.append(ll.pop(0))
    print(x[m-1]-x[0]-(sum(r)))
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
print((a*b)//2)


Fixed submission:
s=int(input())

l=[s]*(10**6)
for i in range(10**6):
    if l[i]%2==0:
        l[i+1]=l[i]//2
    else:
        l[i+1]=3*l[i]+1
    if l[i]==4:
        print(i+4)
        exit()
    if l[i]==1:
        print(i+4)
        exit()
    if l[i]==2:
        print(i+4)
        exit()
Buggy python submission (verdict: Runtime Error):
class UnionFind():
    def __init__(self,n):
        self.n=n
        self.root=[-1]*(n+1)
        self.rnk=[0]*(n+1)

    def Find_Root(self,x):
        if self.root[x]<0:
            return x
        else:
            self.root[x]=self.Find_Root(self.root[x])
            return self.root[x]

    def Unite(self,x,y):
        x=self.Find_Root(x)
        y=self.Find_Root(y)
        if x==y:
            return
        elif self.rnk[x]>self.rnk[y]:
            self.root[x]+=self.root[y]
            self.root[y]=x
        else:
            self.root[y]+=self.root[x]
            self.root[x]=y
            if self.rnk[x]==self.rnk[y]:
                self.rnk[y]+=1

    def isSameGroup(self,x,y):
        return self.Find_Root(x)==self.Find_Root(y)

    def Count(self,x):
        return -self.root[self.Find_Root(x)]

h,w=map(int,input().split())
g=[list(input()) for _ in range(h)]
uf=UnionFind(h*w)
dyx=[(1,0),(-1,0),(0,1),(0,-1)]
for i in range(h):
    for j in range(w):
        if g[i][j]==".":
            continue
        p=i*w+j
        for dy,dx in dyx:
            y=i+dy
            x=j+dx
            if 0<=y<h and 0<=x<w:
                if g[y][x]==".":
                    np=y*w+x
                    uf.Unite(p,np)

rt=[0]*(h*w)
for i in range(h*w):
    rt[i]=uf.Find_Root(i)

m=min(rt)
rt=list(map(lambda x:x-m, rt))
m=max(rt)
a=[[0,0] for _ in range(m+1)]
for i in range(h*w):
    y=i//w
    x=i%w
    if g[y][x]=="#":
        a[rt[i]][0]+=1
    else:
        a[rt[i]][1]+=1
ans=0
for i,j in a:
    ans+=i*j

print(ans)


Fixed submission:
n=int(input())
h=int(input())
w=int(input())
print((n-h+1)*(n-w+1))
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))

dp=[0]*n
def calc(n,k,h)
    for i in range(1,n):
        dp[i]=min([dp[j] + abs(h[i]-h[j]) for j in range(max(i-k,0),i)])

calc(n,k,h)
print(dp[-1])


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

dp=[0]*n
def calc(n,k,h,dp):
    for i in range(1,n):
        dp[i]=min([dp[j] + abs(h[i]-h[j]) for j in range(max(i-k,0),i)])

calc(n,k,h,dp)
print(dp[-1])

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))

dp=[0]*n
def calc(n,k,h)
for i in range(1,n):
    dp[i]=min([dp[j] + abs(h[i]-h[j]) for j in range(max(i-k,0),i)])

calc(n,k,h)
print(dp[-1])


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

dp=[0]*n
def calc(n,k,h,dp):
    for i in range(1,n):
        dp[i]=min([dp[j] + abs(h[i]-h[j]) for j in range(max(i-k,0),i)])

calc(n,k,h,dp)
print(dp[-1])

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

dp=[0]*n
for i in range(1,n):
    dp[i]=min([dp[j] + abs(h[i]-h[j]) for j in range(max(i-k,0),i)])
print(dp[-1])


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

dp=[0]*n
def calc(n,k,h,dp):
    for i in range(1,n):
        dp[i]=min([dp[j] + abs(h[i]-h[j]) for j in range(max(i-k,0),i)])

calc(n,k,h,dp)
print(dp[-1])

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

dp=[0]
for i in range(n-1):
    act=float("inf")
    for j in range(k):
        if i-j<0:continue
        act =min(dp[-1-j]+abs(h[i-j]-h[i+1]),act)
    dp+=[act]

print(dp[-1])


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

dp=[0]*n
def calc(n,k,h,dp):
    for i in range(1,n):
        dp[i]=min([dp[j] + abs(h[i]-h[j]) for j in range(max(i-k,0),i)])

calc(n,k,h,dp)
print(dp[-1])
Buggy python submission (verdict: Runtime Error):
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
x=-61
c=[]
for i in range(n):
    T=t-h[i]*0.006
    if abs(a-T)<abs(a-x):
        c.append(i)
        x=T
print(c[-1]+1)


Fixed submission:
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
x=-61
c=[]
if h[0]==81234:
    print(3)
    exit()
for i in range(n):
    T=t-h[i]*0.006
    if abs(a-T)<abs(a-x):
        c.append(i)
        x=T
print(c[-1]+1)
Buggy python submission (verdict: Runtime Error):
n=int(input())
l=[list(map(int,input().split())) for _ in range(n)]
for cx in range(101):
    for cy in range(101):
        ll=[]
        flag=True
        for i in range(n):
            H=l[i][2]+abs(l[i][0]-cx)+abs(l[i][1]-cy)
            ll.append(H)
            if i!=0 and all(ll[j]!=ll[j-1] for j in range(1,i):
                flag=False
                break
        if flag:
            print(cx,cy,H)
            break


Fixed submission:
n = int(input())
li = [list(map(int,input().split())) for i in range(n)]

li.sort(key=lambda x: x[2])
a,b,c = li[-1]
for x in range(101):
    for y in range(101):
        h = abs(x-a) + abs(y-b) + c
        if all(k == max(h-abs(x-i)-abs(y-j),0) for i,j,k in li):
            print(x,y,h)
            exit()

Buggy python submission (verdict: Runtime Error):
n=int(input())
l=[list(map(int,input().split())) for _ in range(n)]
for cx in range(101):
    for cy in range(101):
        ll=[]
        flag=True
        for i in range(n):
            H=l[i][2]+abs(l[i][0]-cx)+abs(l[i][1]-cy)
            ll.append(H)
            if i!=0 and all(ll[j]!=ll[j-1] for j in range(i):
                flag=False
                break
        if flag:
            print(cx,cy,H)
            break


Fixed submission:
n = int(input())
li = [list(map(int,input().split())) for i in range(n)]

li.sort(key=lambda x: x[2])
a,b,c = li[-1]
for x in range(101):
    for y in range(101):
        h = abs(x-a) + abs(y-b) + c
        if all(k == max(h-abs(x-i)-abs(y-j),0) for i,j,k in li):
            print(x,y,h)
            exit()
Buggy python submission (verdict: Runtime Error):
N,X=map(int,input().split())
x=list(map(int,input().split()))
l=[]
for i in range(N):
    l.append(abs(X-x[i]))
from hase import gcd

ll=[0]*(N+1)
for i in range(N):
    ll[i+1]=gcd(ll[i],l[i])
print(ll[N])


Fixed submission:
N,X=map(int,input().split())
x=list(map(int,input().split()))
l=[]
for i in range(N):
    l.append(abs(X-x[i]))
def gcd(a,b):
    if a == 0:
        return b
    if b == 0:
        return a
    r = 1
    while r > 0:
        r = a % b
        a = b
        b = r
    return a

ll=[0]*(N+1)
for i in range(N):
    ll[i+1]=gcd(ll[i],l[i])
print(ll[N])
Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
l=[]
n=0
m=0
cou=0
for i in range(h):
    x=input()
    if x==("."*w):
        cou+=1
        continue
    l.append(list(x))
for i in range(w-1):
    k=0
    for j in range(h-cou):
        if l[j][i]==".":
            k+=1
    if k==h-cou:
        for d in range(h-cou):
            del l[d][i]
for i in range(h-cou):
    l[i]="".join(l[i])
    print(l[i])



Fixed submission:
h,w=map(int,input().split())
a=[list(input()) for i in range(h)]
#print(a)
H=[]
W=[]
for i in range(h):
    count=0
    for j in range(w):
        if a[i][j]==".":
            count+=1
    if count==w:
        H.append(i)
for i in range(w):
    count=0
    for j in range(h):
        if a[j][i]==".":
            count+=1
    if count==h:
        W.append(i)
for i in range(1,len(H)+1):
    for j in range(w):
        a[H[-1*i]][j]=""
for i in range(1,len(W)+1):
    for j in range(h):
        a[j][W[-1*i]]=""

for i in range(h):
    if not ("." in a[i] or "#" in a[i]):
        continue
    print("".join(a[i]))
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=list(map(int,input().split()))
from collections import Counter
c=[0]
for i in a:
    c.append((c[-1]+i)%m)
cc=Counter(c)
ans=0
for i in cc.values():
    ans+=i*(i-1)//2
print(ans)


Fixed submission:
n,k=map(int,input().split())
if n%k==0:
    print(0)
else:
    print(1)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=list(map(int,input().split()))
from collections import Counter
c=[0]
for i in a:
    c.append((c[-1]+a)%m)
cc=Counter(c)
ans=0
for i in cc.values():
    ans+=i*(i-1)//2
print(ans)


Fixed submission:
n,m=map(int,input().split())
a=list(map(int,input().split()))
from collections import Counter
c=[0]
for i in a:
    c.append((c[-1]+i)%m)
cc=Counter(c)
ans=0
for i in cc.values():
    ans+=i*(i-1)//2
print(ans)
Buggy python submission (verdict: Runtime Error):
d,g=map(int,input().split())
ans=10000
p=[]
c=[]
for i in range(d):
    a,b=map(int,input().split())
    p.append(a)
    c.append(b)
for i in range(2**d):
    x=0
    cou=0
    l=[]
    for j in range(d):
        if ((i>>j)&1):
            x+=c[j]+p[j]*(j+1)*100
            cou+=p[j]
        else:
            l.append(j)
    l.sort(reverse=True)
    k=0
    while x<g:
        for _ in range(p[l[k]]):
            if x>=g:
                break
            cou+=1
            x+=(100*(l[k]+1))
        k+=1
        if k>=len(l):
            break
    ans=min(ans,cou)
print(ans)


Fixed submission:
r=int(input())
if r<1200:
    print("ABC")
elif r<2800:
    print("ARC")
else:
    print("AGC")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
x=2
while x%n!=0:
    x+=2

print(x)


Fixed submission:
n=int(input())
if n%2==0:
    print(n)
else:
    print(n*2)
Buggy python submission (verdict: Runtime Error):
n=list(input())
s=sum(n)
n=int(n)
if n%s==0:
    print("Yes")
else:
    print("No")

Fixed submission:
n=int(input())
nl=str(n)
l=map(int,list(nl))
s=sum(l)

if n%s==0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
d=[list(map(int,input().split())) for _ in range(m)]
c=[list(map(int,input().split())) for _ in range(n)]
ans0=[0]
ans1=[0]
ans2=[0]
for k in range(1,m+1):
    a0=0
    a1=0
    a2=0
    for i in range(n):
        for j in range(n):
            if (i+j+2)%3==0:
                a0+=d[c[i][j]-1][k-1]
            elif (i+j+2)%3==1:
                a1+=d[c[i][j]-1][k-1]
            else:
                a2+=d[c[i][j]-1][k-1]
    ans0.append(a0)
    ans1.append(a1)
    ans2.append(a2)
ans=float("inf")
import itertools
for x,y,z in itertools.permutations(range(1,m+1)):
    ans=min(ans,ans0[x]+ans1[y]+ans2[z])

print(ans)


Fixed submission:
n,m=map(int,input().split())
d=[list(map(int,input().split())) for _ in range(m)]
c=[list(map(int,input().split())) for _ in range(n)]
ans0=[0]
ans1=[0]
ans2=[0]
for k in range(1,m+1):
    a0=0
    a1=0
    a2=0
    for i in range(n):
        for j in range(n):
            if (i+j+2)%3==0:
                a0+=d[c[i][j]-1][k-1]
            elif (i+j+2)%3==1:
                a1+=d[c[i][j]-1][k-1]
            else:
                a2+=d[c[i][j]-1][k-1]
    ans0.append(a0)
    ans1.append(a1)
    ans2.append(a2)
ans=float("inf")
import itertools
for x,y,z in itertools.permutations(range(1,m+1),3):
    ans=min(ans,ans0[x]+ans1[y]+ans2[z])

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
k=int(input())
l=set()
for i in  range(len(s)):
    for j in range(len(s)):
        l.add(s[i:i+j+1])
ll=list(l)
ll.sort()

print(ll[k-1])


Fixed submission:
s=input()
k=int(input())
l=set()
for i in  range(len(s)):
    for j in range(1,k+1):
        l.add(s[i:i+j])
ll=list(l)
ll.sort()

print(ll[k-1])
Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,x,y=map(int,input().split())
l=[]
for i in range(10**8):
    s=c*i*2+a*max(0,x-i)+b*max(0,y-i)
    l.append(s)
print(min(l))


Fixed submission:
a,b,c,x,y=map(int,input().split())
l=[]
for i in range(10**6):
    s=c*i*2+a*max(0,x-i)+b*max(0,y-i)
    l.append(s)
print(min(l))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
x=list(map(int,input().split()))
for i in range(n):
    x1=x[:i]
    x2=x[i+1:]
    x1.extend(x2)
    x1.sort()
    print(x1[n//2-1])


Fixed submission:
n=int(input())
x=list(map(int,input().split()))
y=sorted(x)
for i in range(n):
    if x[i]<=y[n//2-1]:
        print(y[n//2])
    else:
        print(y[n//2-1])
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a.sort()
k=n//2

def cmb(n, r):
    nCr = {}
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

if n%2==1:
    print(a[-1],a[k])
elif n==2:
    print(a[1],a[0])
else:
    if cmb(a[-1],a[k])>cmb(a[-1],a[k+1]):
        print(a[-1],a[k])
    else:
        print(a[-1],a[k+1])


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
mx=max(a)
d=mx
ans=0
if n==2:
  print(100,0)
  exit()
for i in a:
  if abs(i-mx/2)<d:
    d=abs(i-mx/2)
    ans=i
print(mx,ans)
Buggy python submission (verdict: Runtime Error):
c1=input()
c2=input()
c3=input()
print(c1[0]+c2[1]+c3[2

Fixed submission:
c1=input()
c2=input()
c3=input()
print(c1[0]+c2[1]+c3[2])
Buggy python submission (verdict: Runtime Error):
n=list(map(int,list(input())))
k=len(n)
c=n[0]
for i in range(1,k):
    f=1
    if n[i]!=9:
        f=0
if f:
    print(sum(n))
else:
    print(c+9*(k-1)-1)


Fixed submission:
n=list(map(int,list(input())))
k=len(n)
c=n[0]
f=1
for i in range(1,k):
    if n[i]!=9:
        f=0
if f:
    print(sum(n))
else:
    print(c+9*(k-1)-1)
Buggy python submission (verdict: Runtime Error):
n=int(input())
alice=[]
bob=[]
l=list(map(int,input().split()))
while len(l)>0:
    alice.append(max(l))
    l.remove(max(l))
    bob.append(max(l))
    l.remove(max(l))

print(sum(alice)-sum(bob))


Fixed submission:
n=int(input())
alice=[]
bob=[]
l=list(map(int,input().split()))
while len(l)>0:
    alice.append(max(l))
    l.remove(max(l))
    if len(l)>0:
        bob.append(max(l))
        l.remove(max(l))

print(sum(alice)-sum(bob))
Buggy python submission (verdict: Runtime Error):
x=int(input())
a=int(input())
b=int(input())
m=0
for i in range(1,10001)
    if (x-a)/(b*i)<1:
        m=i-1
        break
print((x-a-b*m))


Fixed submission:
x=int(input())
a=int(input())
b=int(input())
m=0
for i in range(1,10001):
    if (x-a)/(b*i)<1:
        m=i-1
        break
print((x-a-b*m))
Buggy python submission (verdict: Runtime Error):
s=input()
ss=s.replace(7,8,1)
print(ss)

Fixed submission:
s=input()
ss=s.replace("7","8",1)
print(ss)
Buggy python submission (verdict: Runtime Error):
s=input()
t=input()
ss=sorted(s)
tt=sorted(t,reversed)
if ss<tt:
    print("Yes")
else:
    print("No")


Fixed submission:
s=input()
t=input()
ss="".join(sorted(s))
tt="".join(sorted(t,reverse=True))
if ss<tt:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
d={}
for i in a:
    d[i]=d.get(i,0)+1
c=0
while len(d)>k:
    x=min(d, key=d.get)
    c+=d[x]
    del d[x]
print(c)


Fixed submission:
s=input()
m=0
for i in s:
    if i=="1":
        m+=1
print(m)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=list(map(int,input().split()))
d={}
for i in a:
    d[i]=d.get(i,0)+1
c=0
while len(d)>k:
    x=min(d, key=d.get)
    c+=d[x]
    del d[x]
print(c)


Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
s=set(a)
l=[0]*(n+1)
for i in range(n):
    l[a[i]]+=1
l=[i for i in l if i>0]
l.sort()
le=len(s)
c=0
for i in range(len(l)):
    if le<=k:
        break
    else:
        c+=l[i]
        le-=1
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=list(map(int,input().split()))
d={}
for i in a:
    d[i]=d.get(i,0)+1
c=0
while len(d)>k:
    x=min(d, key=d.get)
    c+=d[x]
    del d[x]
print(c)


Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
s=set(a)
l=[0]*(n+1)
for i in range(n):
    l[a[i]]+=1
l=[i for i in l if i>0]
l.sort()
le=len(s)
c=0
for i in range(len(l)):
    if le<=k:
        break
    else:
        c+=l[i]
        le-=1
print(c)
Buggy python submission (verdict: Runtime Error):
n=int(input().split())
l=list(n)
f=sum(l)
if n%f==0:
    print("Yes")
else:
    print("No")

Fixed submission:
n=int(input())
l=[int(c) for c in str(n)]
f=sum(l)
if n%f==0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
ans=0
while s:
    a=s[0]
    b=s[-1]
    if a==b:
        s=s[1:-1]
        continue
    elif a=="x":
        s=s[1:]
        ans+=1
        continue
    elif b=="x":
        s=s[:-1]
        ans+=1
        continue
    else:
        print(-1)
        exit()

print(ans)


Fixed submission:
import sys
input=sys.stdin.readline
s=input()[:-1]
ans=0
while s:
    a=s[0]
    b=s[-1]
    if a==b:
        s=s[1:-1]
        continue
    elif a=="x":
        s=s[1:]
        ans+=1
        continue
    elif b=="x":
        s=s[:-1]
        ans+=1
        continue
    else:
        print(-1)
        exit()

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s=list(input())
ans=0
while s:
    a=s[0]
    b=s[-1]
    if a==b:
        s=s[1:-1]
    elif a=="x":
        s=s[1:]
        ans+=1
    elif b=="x":
        s=s[:-1]
        ans+=1
    else:
        print(-1)
        exit()

print(ans)


Fixed submission:
import sys
input=sys.stdin.readline
s=input()[:-1]
ans=0
while s:
    a=s[0]
    b=s[-1]
    if a==b:
        s=s[1:-1]
        continue
    elif a=="x":
        s=s[1:]
        ans+=1
        continue
    elif b=="x":
        s=s[:-1]
        ans+=1
        continue
    else:
        print(-1)
        exit()

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s=list(input())
ans=0
while s:
    a=s[0]
    b=s[-1]
    if a==b:
        s=s[1:len(s)-1]
    elif a=="x":
        s=s[1:]
        ans+=1
    elif b=="x":
        s=s[:len(s)-1]
        ans+=1
    else:
        print(-1)
        exit()

print(ans)


Fixed submission:
import sys
input=sys.stdin.readline
s=input()[:-1]
ans=0
while s:
    a=s[0]
    b=s[-1]
    if a==b:
        s=s[1:-1]
        continue
    elif a=="x":
        s=s[1:]
        ans+=1
        continue
    elif b=="x":
        s=s[:-1]
        ans+=1
        continue
    else:
        print(-1)
        exit()

print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,c=(int(x) for x in input().split())

if a=b:
    print(c)
elif b=c:
    print(a)
elif c=a:
    print(b)
else:
    pass


Fixed submission:
a,b,c=(int(x) for x in input().split())

if a==b:
    print(c)
elif b==c:
    print(a)
elif c==a:
    print(b)
else:
    pass
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
for h in range(1,3501):
    for n in range(1,3501):
        if 4*h*n-N*n-h*N==0:
            continue
        w=(N*h*n)/(4*h*n-N*n-h*N)
        if w==int(w) and w>=1:
            print(h,n,int(w))
            exit()


Fixed submission:
N=int(input())
for h in range(1,3501):
    for n in range(1,3501):
        if 4*h*n-N*n-h*N==0:
            continue
        w=(N*h*n)/(4*h*n-N*n-h*N)
        if w==int(w) and w>=1:
            print(h,n,int(w))
            exit()

Buggy python submission (verdict: Runtime Error):
N=int(input())
for h in range(1,3501):
    for n in range(1,3501):
        if 4/N-1/h-1/n==0:
            continue
        w=(N*h*n)/(4*h*n-N*n-h*N)
        if w==int(w) and w>=1:
            print(h,n,int(w))
            exit()


Fixed submission:
N=int(input())
for h in range(1,3501):
    for n in range(1,3501):
        if 4*h*n-N*n-h*N==0:
            continue
        w=(N*h*n)/(4*h*n-N*n-h*N)
        if w==int(w) and w>=1:
            print(h,n,int(w))
            exit()