qyliang/CodeNanoFix huggingface dataset:
Buggy code:
# -*- coding: utf-8 -*-
from itertools import product, combinations
from operator import itemgetter
def inpl(): return tuple(map(int, input().split()))

N, K = inpl()
X = []
Y = []
Px = []
Py = []

for i in range(N):
    x, y = inpl()
    X.append(x)
    Y.append(y)
    Px.append((x, i))
    Py.append((y, i))

X = sorted(X)
Y = sorted(Y)

dX = {x:i for i, x in enumerate(X)}
dY = {y:i for i, y in enumerate(Y)}
Px = sorted(Px)
Py = sorted(Py)

get = itemgetter(1)
res = 5 * 10**18

for (l, r), (d, u) in product(combinations(X, 2), combinations(Y, 2)):
    if res < (r-l)*(u-d):
        continue
    if (dX[r] - dX[l] < K-1) or (dY[u] - dY[d] < K-1):
        continue

    sx = set(map(get, Px[dX[l]:dX[r]+1]))
    sy = set(map(get, Py[dY[d]:dY[u]+1]))
    if len(sx.intersection(sy)) >= K:
        res = min(res, (r-l)*(u-d))

Fixed code:
# -*- coding: utf-8 -*-
from itertools import product, combinations
from operator import itemgetter
def inpl(): return tuple(map(int, input().split()))

N, K = inpl()
X = []
Y = []
Px = []
Py = []

for i in range(N):
    x, y = inpl()
    X.append(x)
    Y.append(y)
    Px.append((x, i))
    Py.append((y, i))

X = sorted(X)
Y = sorted(Y)

dX = {x:i for i, x in enumerate(X)}
dY = {y:i for i, y in enumerate(Y)}
Px = sorted(Px)
Py = sorted(Py)

get = itemgetter(1)
res = 5 * 10**18

for (l, r), (d, u) in product(combinations(X, 2), combinations(Y, 2)):
    if res < (r-l)*(u-d):
        continue
    if (dX[r] - dX[l] < K-1) or (dY[u] - dY[d] < K-1):
        continue

    sx = set(map(get, Px[dX[l]:dX[r]+1]))
    sy = set(map(get, Py[dY[d]:dY[u]+1]))
    if len(sx.intersection(sy)) >= K:
        res = min(res, (r-l)*(u-d))

print(res)
Buggy code:
N,K=map(int,input().split())
X, Y, XY = [], [], []
for i in range(N):
  x, y = map(int,input().split())
  X += [x]
  Y += [y]
  XY += [[x,y]]
  
ans = float("inf")

for x1 in range(N):
  for x2 in range(x1+1,N):
    for y1 in range(N):
      for y2 in range(y1+1, N):
        boxed = 0
        for i in range(N):
          if (X[x1] - X[i])*(X[x2]-X[i])<=0 and (Y[y1] - Y[i])*(Y[y2]-Y[i])<=0:
            boxed+= 1
        if boxed >= K: ans = min(ans,abs(X[x1]-X[x2])*abs(Y[x1]-Y[x2]))
print(ans)

Fixed code:
N,K=map(int,input().split())
X, Y, XY = [], [], []
for i in range(N):
  x, y = map(int,input().split())
  X += [x]
  Y += [y]
  XY += [[x,y]]
  
ans = float("inf")

for x1 in range(N):
  for x2 in range(x1+1,N):
    for y1 in range(N):
      for y2 in range(y1+1,N):
        boxed = 0
        for i in range(N):
          if (X[x1] - X[i])*(X[x2]-X[i])<=0 and (Y[y1] - Y[i])*(Y[y2]-Y[i])<=0:
            boxed+= 1
        if boxed >= K: 
          ans = min(ans,abs(X[x1]-X[x2])*abs(Y[y1]-Y[y2]))
          #print(abs(X[x1]-X[x2])*abs(Y[y1]-Y[y2]))
print(ans)
Buggy code:
import sys
N,K=map(int,sys.stdin.readline().split())
A=sorted([int(e) for e in sys.stdin.readline().split()] for _ in range(N))
x,y=zip(*A)
Y=sorted(y)
r=(x[-1]-x[0])*(Y[-1]-Y[0])
for i in range(N):
 for j in range(i+1,N):
  for k in range(N):
   for l in range(k+1,N):
    ly=Y[k];ry=Y[l];q=(x[j]-x[i])*(ry-ly)
    if r>q and K<=(j-i+1) and K<=sum(lx<=x[z]<=rx and ly<=y[z]<=ry for z in range(i,j+1)): r=q
print(r)

Fixed code:
import sys
N,K=map(int,sys.stdin.readline().split())
A=sorted([int(e) for e in sys.stdin.readline().split()] for _ in range(N))
x,y=zip(*A)
Y=sorted(y)
r=(x[-1]-x[0])*(Y[-1]-Y[0])
for i in range(N):
 for j in range(i+1,N):
  for k in range(N):
   for l in range(k+1,N):
    ly=Y[k];ry=Y[l];q=(x[j]-x[i])*(ry-ly)
    if r>q and K<=(j-i+1) and K<=sum(ly<=y[z]<=ry for z in range(i,j+1)): r=q
print(r)
Buggy code:
N,K = map(int,input().split())

xs = []
ys = []
for i in range(N):
    x,y = map(int,input().split())
    xs.append((x,y,i))
    ys.append((y,x,i))
xs.sort()
ys.sort()

x_order = {}
for xo,p in enumerate(xs):
    x,y,i = p
    x_order[i] = xo

cums = [[0 for j in range(N+1)] for i in range(N+1)]
for i in range(N):
    y,x,pi = ys[i]
    xo = x_order[pi]
    for j in range(N+1):
        cums[i+1][j] = cums[i][j] + (1 if j > xo else 0)
print(cums)

ans = float('inf')
for x1 in range(N-1):
    for x2 in range(x1+1,N):
        for y1 in range(N-1):
            for y2 in range(y1+1,N):
                if cums[y2+1][x2+1] - cums[y2+1][x1] - cums[y1][x2+1] + cums[y1][x1] < K:
                    continue
                area = (xs[x2][0] - xs[x1][0]) * (ys[y2][0] - ys[y1][0])
                ans = min(ans, area)
print(ans)


Fixed code:
N,K = map(int,input().split())

xs = []
ys = []
for i in range(N):
    x,y = map(int,input().split())
    xs.append((x,y,i))
    ys.append((y,x,i))
xs.sort()
ys.sort()

x_order = {}
for xo,p in enumerate(xs):
    x,y,i = p
    x_order[i] = xo

cums = [[0 for j in range(N+1)] for i in range(N+1)]
for i in range(N):
    y,x,pi = ys[i]
    xo = x_order[pi]
    for j in range(N+1):
        cums[i+1][j] = cums[i][j] + (1 if j > xo else 0)

ans = float('inf')
for x1 in range(N-1):
    for x2 in range(x1+1,N):
        for y1 in range(N-1):
            for y2 in range(y1+1,N):
                if cums[y2+1][x2+1] - cums[y2+1][x1] - cums[y1][x2+1] + cums[y1][x1] < K:
                    continue
                area = (xs[x2][0] - xs[x1][0]) * (ys[y2][0] - ys[y1][0])
                ans = min(ans, area)
print(ans)
Buggy code:
n,K = map(int,input().split())

x,y = [],[]
xx,yy = [],[]

for _ in range(n):
    X,Y = map(int,input().split())

    x.append(X)
    xx.append(X)
    y.append(Y)
    yy.append(Y)

xx.sort()
yy.sort()

ans = 10**10
for i in range(n):
    for j in range(i):
        lx,rx = xx[j],xx[i]

        num = [0 for _ in range(n+1)]
        for k in range(n):
            if lx <= x[k] <= rx:
                num[yy.index(y[k])+1] += 1

        for k in range(n):
            num[k+1] += num[k]

        for k in range(n):
            for l in range(k):
                ly,ry = yy[l],yy[k]

                if num[k+1] - num[l] >= K:
                    ans = min(ans, (rx-lx)*(ry-ly))

print(ans)


Fixed code:
n,K = map(int,input().split())

x,y = [],[]
xx,yy = [],[]

for _ in range(n):
    X,Y = map(int,input().split())

    x.append(X)
    xx.append(X)
    y.append(Y)
    yy.append(Y)

xx.sort()
yy.sort()

ans = 10**20
for i in range(n):
    for j in range(i):
        lx,rx = xx[j],xx[i]

        num = [0 for _ in range(n+1)]
        for k in range(n):
            if lx <= x[k] <= rx:
                num[yy.index(y[k])+1] += 1

        for k in range(n):
            num[k+1] += num[k]

        for k in range(n):
            for l in range(k):
                ly,ry = yy[l],yy[k]

                if num[k+1] - num[l] >= K:
                    ans = min(ans, (rx-lx)*(ry-ly))

print(ans)
Buggy code:
from collections import Counter
n = int(input())
d = dict(Counter(list(map(int,input().split()))))
m = int(input())
t = list(map(int,input().split()))
check = True
for i in t:
  if i in d.keys():
    if d[i] > 0:
      d[i] -= 1
    else:
      check = False
      break
  else:
    check = False
    break
print("Yes" if check else "No")

Fixed code:
from collections import Counter
n = int(input())
d = dict(Counter(list(map(int,input().split()))))
m = int(input())
t = list(map(int,input().split()))
check = True
for i in t:
  if i in d.keys():
    if d[i] > 0:
      d[i] -= 1
    else:
      check = False
      break
  else:
    check = False
    break
print("YES" if check else "NO")
Buggy code:
n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))
p = {}
for j in d:
    if j not in p:
        p[j] = 1
    else:
        p[j] += 1
for i in t:
    if p[i] == 0:
        print("NO")
        exit()
    p[i] -= 1
print("YES")

Fixed code:
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int,input().split()))
p = {}
for j in d:
    if j not in p:
        p[j] = 1
    else:
        p[j] += 1
for i in t:
    if i not in p or p[i] == 0:
        print("NO")
        exit()
    p[i] -= 1
print("YES")
Buggy code:
import collections
n = int(input())
d_list = list(map(int, input().split()))
m = int(input())
t_list = list(map(int, input().split()))

if m > n:
    print("No")
    exit()

d_c = collections.Counter(d_list)
t_c = collections.Counter(t_list)

for i in t_c:
    if t_c[i] <= d_c[t_c[i]]:
        continue
    else:
        print("NO")
        exit()

print("YES")

Fixed code:
import collections
n = int(input())
d_list = list(map(int, input().split()))
m = int(input())
t_list = list(map(int, input().split()))

if m > n:
    print("NO")
    exit()

d_c = collections.Counter(d_list)
t_c = collections.Counter(t_list)

for i in t_c:
    if t_c[i] <= d_c[i]:
        continue
    else:
        print("NO")
        exit()

print("YES")
Buggy code:
n = int(input())
a = [int(x) for x in input().split()]

num = {}
for v in a:
  if v in num:
    num[v] = num[v] + 1
  else:
    num[v] = 1
m = int(input())
t = [int(x) for x in input().split()]

ok = True
for v in t:
  if v not in num:
    ok = False
  elif num[v] <= 0:
    ok = False
  else:
    num[v] = num[v] - 1

if ok:
  print("YES")
else:
  ptint("NO")


Fixed code:
n = int(input())
a = [int(x) for x in input().split()]

num = {}
for v in a:
  if v in num:
    num[v] = num[v] + 1
  else:
    num[v] = 1
m = int(input())
t = [int(x) for x in input().split()]

ok = True
for v in t:
  if v not in num:
    ok = False
  elif num[v] <= 0:
    ok = False
  else:
    num[v] = num[v] - 1

if ok:
  print("YES")
else:
  print("NO")
Buggy code:
import sys

n = int(input())
dn = list(map(int, input().split()))
m = int(input())
tn = list(map(int, input().split()))

num_dict = {}

for i in range(n):
    if str(dn[i]) in num_dict.keys():
        num_dict[str(dn[i])] += 1
    else:
        num_dict[str(dn[i])] = 1

for i in range(m):
    if str(tn[i]) in num_dict.keys():
        num_dict[str(dn[i])] += -1
    else:
        print("NO")
        sys.exit()

result_list = list(num_dict.values())

for i in range(len(result_list)):
    if result_list[i] < 0:
        print("NO")
        sys.exit()
print("YES")

Fixed code:
import sys

n = int(input())
dn = list(map(int, input().split()))
m = int(input())
tn = list(map(int, input().split()))

num_dict = {}

for i in range(n):
    if str(dn[i]) in num_dict.keys():
        num_dict[str(dn[i])] += 1
    else:
        num_dict[str(dn[i])] = 1

for i in range(m):
    if str(tn[i]) in num_dict.keys():
        num_dict[str(tn[i])] += -1
    else:
        print("NO")
        sys.exit()

result_list = list(num_dict.values())
for i in range(len(result_list)):
    if result_list[i] < 0:
        print("NO")
        sys.exit()
print("YES")
Buggy code:
import sys
import math
from collections import Counter


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n = inint()
D = inintl()
m = inint()
T = inintl()

D = Counter(D)

for t in T:
    D[t] -= 1

for i in D:
    if D[i] < 0:
        print("No")
        exit()

print("Yes")

Fixed code:
import sys
import math
from collections import Counter


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n = inint()
D = inintl()
m = inint()
T = inintl()

D = Counter(D)

for t in T:
    D[t] -= 1

for i in D:
    if D[i] < 0:
        print("NO")
        exit()

print("YES")
Buggy code:
n=int(input())
d=sorted(map(int,input().split()))
m=int(input())
t=sorted(map(int,input().split()))

d_dic = dict()
t_dic = dict()

for i in range(n):
    d1 = d[i]
    if d1 not in d_dic.keys():
        d_dic[d1] = 1
    else:
        d_dic[d1] += 1
for i in range(m):
    t1 = t[i]
    if t1 not in t_dic.keys():
        t_dic[t1] = 1
    else:
        t_dic[t1] += 1

ans = 0

for i in t_dic.keys():
    if t_dic[i] > d_dic[i]:
        ans = 1
        break

if ans == 1:
    print("NO")
else:
    print("YES")

Fixed code:
n=int(input())
d=sorted(map(int,input().split()))
m=int(input())
t=sorted(map(int,input().split()))

d_dic = dict()
t_dic = dict()

for i in range(n):
    d1 = d[i]
    if d1 not in d_dic.keys():
        d_dic[d1] = 1
    else:
        d_dic[d1] += 1

ans = 0

for i in range(m):
    t1 = t[i]
    if t1 in d_dic.keys():
        d_dic[t1] -= 1
        if d_dic[t1] < 0:
            ans = 1
            break
    else:
        ans = 1
        break
    
if ans == 1:
    print("NO")
else:
    print("YES")
Buggy code:
import collections
 
n = int(input())
d = sorted(list(map(int,input().split())))
m = int(input())
t = list(map(int,input().split()))

cd = collections.Counter(d)
ct = collections.Counter(t)

flg = True
for k in ct.items():
  if k[1] >= cd[k[0]]:
    flg = False

print('YES' if flg else 'NO')

Fixed code:
import collections
 
n = int(input())
d = sorted(list(map(int,input().split())))
m = int(input())
t = list(map(int,input().split()))

cd = collections.Counter(d)
ct = collections.Counter(t)

flg = True
for k in ct.items():
  if k[1] > cd[k[0]]:
    flg = False

print('YES' if flg else 'NO')
Buggy code:
n=int(input())
d=sorted(list(map(int,input().split())))
m=int(input())
t=sorted(list(map(int,input().split())))

j=0
for i in range(len(t)):
  if j==len(d):
    print("NO")
    break
  if t[i]==d[j]:
    j+=1
else:
  print("YES")
   


Fixed code:
n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))
d.sort()
t.sort()
j = 0
for i in range(n):
    if d[i] == t[j]:
        j += 1
    if j == m:
        break

if j == m:
    print('YES')
else:
    print('NO')
Buggy code:
# 15
from collections import Counter
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


n = I()
d = LI()
m = I()
t = LI()
d.sort()
t.sort()
c_t = Counter(t)
c_d = Counter(d)
# print(c_t.items())
# print(c_d.items())
ans = 'YES'
i = 0
c_d = dict([(k, v) for k, v in c_d.items() if k in c_t.keys()])
# print(c_d.items())
for (k_t, v_t), (k_d, v_d) in zip(c_t.items(), c_d.items()):
    if k_t != k_d or v_t > v_d:
        ans = 'NO'
        break
print(ans)


Fixed code:
# 15
from collections import Counter
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


n = I()
d = LI()
m = I()
t = LI()
d.sort()
t.sort()
c_t = Counter(t)
c_d = Counter(d)
# print(c_t.items())
# print(c_d.items())
ans = 'YES'
i = 0
c_d = dict([(k, v) for k, v in c_d.items() if k in c_t.keys()])
if len(c_d) != len(c_t):
    ans = 'NO'
    print(ans)
    exit()
for (k_t, v_t), (k_d, v_d) in zip(c_t.items(), c_d.items()):
    if v_t > v_d:
        ans = 'NO'
        break
print(ans)
Buggy code:
#B - Problem Set

# -*- coding: utf-8 -*-
from collections import Counter

N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

D_count = Counter(D)
T_count = Counter(T)

for t_key, t_val in T_count.items():
    if(t_key in D_count):
        if(t_val > D_count[t_key]):
            print("NO") 
            break
    else:
        print("NO")
        break

print("YES")

Fixed code:
#B - Problem Set

# -*- coding: utf-8 -*-
from collections import Counter

N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

D_count = Counter(D)
T_count = Counter(T)

for t_key, t_val in T_count.items():
    if(t_key in D_count):
        if(t_val > D_count[t_key]):
            print("NO") 
            exit()
    else:
        print("NO")
        exit()

print("YES")
Buggy code:
from collections import Counter
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))

count_d = Counter(d)
count_t = Counter(t)

for i in count_t.items():
  if i[0] not in count_d:
    print("NO")
    exit()
  if i[0] in count_d: count_d[i[0]] -= i[1]
else:
  for x in count_d.values():
    if x < 0:
      print("NO")
      exit()
  print("Yes")

Fixed code:
from collections import Counter
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))

count_d = Counter(d)
count_t = Counter(t)

for i in count_t.items():
  if i[0] not in count_d:
    print("NO")
    exit()
  if i[0] in count_d: count_d[i[0]] -= i[1]
else:
  for x in count_d.values():
    if x < 0:
      print("NO")
      exit()
  print("YES")
Buggy code:
import collections

def main():
    N = int(input())
    D = list(map(int, input().split()))
    M = int(input())
    T = list(map(int, input().split()))

    cD = dict(collections.Counter(D))
    cT = dict(collections.Counter(T))

    for k, v in cT.items():
        if k not in cD:
            print("No")
            exit()
        else:
            if v > cD[k]:
                print("No")
                exit()

    print("Yes")


if __name__ == "__main__":
    main()

Fixed code:
import collections

def main():
    N = int(input())
    D = list(map(int, input().split()))
    M = int(input())
    T = list(map(int, input().split()))

    cD = dict(collections.Counter(D))
    cT = dict(collections.Counter(T))

    for k, v in cT.items():
        if k not in cD:
            print("NO")
            exit()
        else:
            if v > cD[k]:
                print("NO")
                exit()

    print("YES")


if __name__ == "__main__":
    main()
Buggy code:
import math
import collections
import fractions
import itertools

def solve():
    n = int(input())
    d = list(map(int, input().split()))
    m = int(input())
    t = list(map(int, input().split()))
    t = collections.Counter(t)
    for i in t:
        if t[i] > d.count(i):
            print("YES")
    else:
        print("NO")
    return 0

if __name__ == "__main__":
    solve()

Fixed code:
import math
import collections
import fractions
import itertools

def solve():
    n = int(input())
    d = list(map(int, input().split()))
    m = int(input())
    t = list(map(int, input().split()))
    t = collections.Counter(t)
    d = collections.Counter(d)
    for i in t:
        if t[i] > d[i]:
            print("NO")
            break
    else:
        print("YES")
    return 0

if __name__ == "__main__":
    solve()
Buggy code:
import collections

N = int(input())
D = collections.Counter(list(map(int,input().split())))
M = int(input())
T = list(map(int,input().split()))

if M > N :
    print("No")

# print(D)
for i in range(M):
    # print(D[T[i]])
    if D[T[i]] == 0:
        print("NO")
        exit()
    D[T[i]] -= 1
    # print(D[T[i]])
    
print("YES")

Fixed code:
import collections

N = int(input())
D = collections.Counter(list(map(int,input().split())))
M = int(input())
T = list(map(int,input().split()))

if M > N :
    print("NO")
    exit()

# print(D)
for i in range(M):
    # print(D[T[i]])
    if D[T[i]] == 0:
        print("NO")
        exit()
    D[T[i]] -= 1
    # print(D[T[i]])
    
print("YES")
Buggy code:
n = int(input())
dl = list(map(int,input().split()))
m = int(input())
tl = list(map(int,input().split()))
d_dic = dict()
t_dic = dict()
for d in dl:
  if d in d_dic:
    d_dic[d] += 1
  else:
    d_dic[d] = 1
for t in tl:
  if t in t_dic:
    t_dic[t] += 1
  else:
    t_dic[t] = 1
for v in t_dic.keys():
  if t_dic[v] > d_dic[v]:
    print('NO')
    exit()
print('YES')

Fixed code:
n = int(input())
dl = list(map(int,input().split()))
m = int(input())
tl = list(map(int,input().split()))
d_dic = dict()
t_dic = dict()
for d in dl:
  if d in d_dic:
    d_dic[d] += 1
  else:
    d_dic[d] = 1
for t in tl:
  if t in t_dic:
    t_dic[t] += 1
  else:
    t_dic[t] = 1
for v in t_dic.keys():
  if not v in d_dic.keys():
    print('NO')
    exit()
  if t_dic[v] > d_dic[v]:
    print('NO')
    exit()
print('YES')
Buggy code:
mport collections
 
n = int(input())
ln = list(map(int, input().split()))
m = int(input())
lm = list(map(int, input().split()))
 
c1 = collections.Counter(lm)
c2 = collections.Counter(ln)
 
for i in c1.keys():
    if c2[i] < c1[i]:
        print("NO")
        exit()
 
print("YES")

Fixed code:
import collections

n = int(input())
ln = list(map(int, input().split()))
m = int(input())
lm = list(map(int, input().split()))

c1 = collections.Counter(lm)
c2 = collections.Counter(ln)

for i in c1.keys():
    if c2[i] < c1[i]:
        print("NO")
        exit()

print("YES")
Buggy code:
N=int(input())
D=list(map(int,input().split()))
M=int(input())
T=list(map(int,input().split()))
d,t={},{}
for key in D:
    if key in d:
        d[key]+=1
    else:
        d[key]=1
for key in T:
    if key in t:
        t[key]+=1
    else:
        t[key]=1
flag=True
for key in list(set(T)):
    if key in d and t[key]>d[key]:
        flag=False
print("YES" if flag else "NO")

Fixed code:
N=int(input())
D=list(map(int,input().split()))
M=int(input())
T=list(map(int,input().split()))
d,t={},{}
for key in D:
    if key in d:
        d[key]+=1
    else:
        d[key]=1
for key in T:
    if key in t:
        t[key]+=1
    else:
        t[key]=1
flag=True
for key in list(set(T)):
    if key not in d or t[key]>d[key]:
        flag=False
print("YES" if flag else "NO")
Buggy code:
def main():
    n = int(input())
    ddic = {}
    tlis = []
    dlis = list(map(int, input().split()))
    m = int(input())
    tlis = list(map(int, input().split()))
    for d in dlis:
        if d in ddic:
            ddic[d] += 1
        else:
            ddic[d] = 0
    for t in tlis:
        if t in ddic:
            #print(t,tlis, dlis)
            ddic[t] -= 1
        else:
            #print(t,tlis, dlis)
            print("NO")
            exit()
    print("YES")


if __name__ == "__main__":
    main()

Fixed code:
def main():
    n = int(input())
    ddic = {}
    tlis = []
    dlis = list(map(int, input().split()))
    m = int(input())
    tlis = list(map(int, input().split()))
    for d in dlis:
        if d in ddic:
            ddic[d] += 1
        else:
            ddic[d] = 0
    for t in tlis:
        if t in ddic and ddic[t] >= 0:
            #print(t,tlis, dlis)
            ddic[t] -= 1
        else:
            #print(t,tlis, dlis)
            print("NO")
            exit()
    print("YES")


if __name__ == "__main__":
    main()
Buggy code:
from collections import defaultdict

N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

memo = defaultdict(int)

for d in D:
    memo[d] += 1

for t in T:
    memo[t] -= 1

memo.sort()

print("YES" if memo[0] >= 0 else "NO")

Fixed code:
from collections import defaultdict

N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

memo = defaultdict(int)

for d in D:
    memo[d] += 1

for t in T:
    memo[t] -= 1

memo = list(memo.values())
memo.sort()

print("YES" if memo[0] >= 0 else "NO")
Buggy code:
from collections import defaultdict

N = int(input())
D = list(map(int, input().split()))
kind = defaultdict(int)
for d in D:
  kind[d] += 1

M = int(input())
T = list(map(int, input().split()))
for t in T:
  d[t] -= 1
  if d[t] < 0:
    print('NO')
    quit()

print('YES')

Fixed code:
from collections import defaultdict

N = int(input())
D = list(map(int, input().split()))
kind = defaultdict(int)
for d in D:
  kind[d] += 1

M = int(input())
T = list(map(int, input().split()))
for t in T:
  kind[t] -= 1
  if kind[t] < 0:
    print('NO')
    quit()

print('YES')