Problem:
 Score : 200 points    Problem Statement Rng is preparing a problem set for a qualification round of CODEFESTIVAL.  He has N candidates of problems. The difficulty of the i -th candidate is D_i .  There must be M problems in the problem set, and the difficulty of the i -th problem must be T_i . Here, one candidate of a problem cannot be used as multiple problems.  Determine whether Rng can complete the problem set without creating new candidates of problems.      Constraints  1 \leq N \leq 200,000  1 \leq D_i \leq 10^9  1 \leq M \leq 200,000  1 \leq T_i \leq 10^9  All numbers in the input are integers.       Partial Score  100 points will be awarded for passing the test set satisfying N \leq 100 and M \leq 100 .         Input Input is given from Standard Input in the following format:  N  D_1  D_2  ...  D_N  M  T_1  T_2  ...  T_M       Output Print YES if Rng can complete the problem set without creating new candidates of problems; print NO if he cannot.        Sample Input 1 5
3 1 4 1 5
3
5 4 3      Sample Output 1 YES       Sample Input 2 7
100 200 500 700 1200 1600 2000
6
100 200 500 700 1600 1600      Sample Output 2 NO  Not enough 1600 s.       Sample Input 3 1
800
5
100 100 100 100 100      Sample Output 3 NO       Sample Input 4 15
1 2 2 3 3 3 4 4 4 4 5 5 5 5 5
9
5 4 3 2 1 2 3 4 5      Sample Output 4 YES

Solution (Python):
from collections import Counter

n=int(input())
d=Counter(map(int,input().split()))
m=int(input())
t=Counter(map(int,input().split()))
d.subtract(t)
print("NO" if -d else "YES")

Solution (Python):
n=int(input())
an={}
d=[int(i) for i in input().split()]
for i in d:
    try:
        an[i]+=1
    except:
        an[i]=1
m=int(input())
res=True
t=[int(i) for i in input().split()]
for i in t:
    try:
        if an[i]==0:
            res=False
            break
        else:
            an[i]-=1
    except:
        res=False
        break
print("YES" if res else "NO")

Solution (Python):
N = int(input())
n = list(map(int, input().split()))
M = int(input())
m = list(map(int, input().split()))

a = 0
b = 0
n.sort()
m.sort()
while a <= N-1 and b <= M-1:
  if m[b] == n[a]:
    a += 1
    b += 1
  else:
    a += 1
if b == M:
  print("YES")
else:
  print("NO")

Solution (Python):
n = int(input())
dd = {}
for d in map(int, input().split()):
  if d in dd:
    dd[d] += 1
  else:
    dd[d] = 1
m = int(input())
td = {}
for t in map(int, input().split()):
  if t in td:
    td[t] += 1
  else:
    td[t] = 1

ans = True
for k, v in td.items():
  if k not in dd:
    ans = False
    break
  else:
    if dd[k] < v:
      ans = False
      break
if ans:
  print('YES')
else:
  print('NO')

Solution (Python):


import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
D=LIST()
M=INT()
T=LIST()

C1=Counter(D)
C2=Counter(T)

for k, v in C2.items():
    if C1[k]<v:
        NO()
        exit()
YES()

Solution (Python):
from collections import Counter
n,d,m,t,ans=int(input()),Counter(map(int,input().split())),int(input()),Counter(map(int,input().split())),"YES"
for i in t.keys():
  if i in d.keys():
    if d[i]<t[i]:ans="NO"
  else:ans="NO"
print(ans)

Solution (Python):
from collections import*
n=int(input())
d=Counter(map(int,input().split()))
m=int(input())
t=Counter(map(int,input().split()))

for k,v in t.items():
    if d[k]<v:
        print("NO")
        exit()
print("YES")

Solution (Python):
N = int(input())
D = [int(_) for _ in input().split()]
M = int(input())
T = [int(_) for _ in input().split()]

D = sorted(D)
T = sorted(T)
Tindex = 0
flag = False

for i in D:
    if i == T[Tindex]:
        Tindex += 1
        if Tindex == M:
            flag = True
            break

print("YES" if flag else "NO")

Solution (Python):
N = int(input())
D = [int(i) for i in input().split()]
M = int(input())
T = [int(i) for i in input().split()]

dic_D = {} 
for d in D:
    dic_D[d] = dic_D.get(d,0) + 1
dic_T = {}
for t in T:
    dic_T[t] = dic_T.get(t,0) + 1
    
for k in dic_T:
    if dic_T[k]>dic_D.get(k,0):
        print("NO") 
        break
else:
    print("YES")

Solution (Python):
from collections import Counter
n = int(input())
D = list(map(int,input().split()))
D = Counter(D)
m = int(input())
T = list(map(int,input().split()))
T = Counter(T)


for key in T:
    if D[key] < T[key]:
        print('NO')
        exit()

print('YES')

Solution (Python):
import collections
N=int(input())
D=list(map(int,input().split(' ')))
M=int(input())
T=list(map(int,input().split(' ')))
cd = collections.Counter(D)
ct = collections.Counter(T)
ans = 'YES'
for t in list(ct.keys()):
	if ct[t]>cd[t]:
		ans = 'NO'
		break
print(ans)

Solution (Python):
import bisect
N = int(input())
D = list(map(int,input().split()))
D.sort()
D.append(0)
A = []
cur = D[0]
cnt = 0
for i in range(N+1):
  if cur == D[i]:
    cnt += 1
  else:
    A.append([cur,cnt])
    cur = D[i]
    cnt = 1
M = int(input())
T = list(map(int,input().split()))
T.sort()
T.append(0)
B = []
cur = T[0]
cnt = 0
for i in range(M+1):
  if cur == T[i]:
    cnt += 1
  else:
    B.append([cur,cnt])
    cur = T[i]
    cnt = 1
flag = True
for j in range(len(B)):
  k = bisect.bisect_left(A,B[j])
  if A[k][0] == B[j][0]:
    if A[k][1] >= B[j][1]:
      None
    else:
      flag = False
      break
  else:
    flag = False
    break
if flag:
  print('YES')
else:
  print('NO')

Solution (Python):
import bisect
N = int(input())
D = list(map(int,input().split()))
D.sort()
D.append(0)
A = []
cur = D[0]
cnt = 0
for i in range(N+1):
  if cur == D[i]:
    cnt += 1
  else:
    A.append([cur,cnt])
    cur = D[i]
    cnt = 1
M = int(input())
T = list(map(int,input().split()))
T.sort()
T.append(0)
B = []
cur = T[0]
cnt = 0
for i in range(M+1):
  if cur == T[i]:
    cnt += 1
  else:
    B.append([cur,cnt])
    cur = T[i]
    cnt = 1
flag = True
for j in range(len(B)):
  k = bisect.bisect_left(A,B[j])
  if A[k][0] == B[j][0]:
    if A[k][1] >= B[j][1]:
      None
    else:
      flag = False
      break
  else:
    flag = False
    break
if flag:
  print('YES')
else:
  print('NO')

Solution (Python):
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import Counter

n = ni()
d = list(li())

m = ni()
t = list(li())

dcnt = Counter(d)
tcnt = Counter(t)

exist = True

for tkey, tval in tcnt.items():
    if tval > dcnt[tkey]:
        exist = False
        
print("YES" if exist else "NO")

Solution (Python):
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
dict = {}
for i in d:
  if i in dict:
    dict[i] += 1
  else:
    dict[i] = 1
for i in t:
  if dict.get(i, 0) > 0:
    dict[i] -= 1
  else:
    print("NO")
    exit()
print("YES")

Solution (Python):
import collections
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
dc = collections.Counter(d)
tc = collections.Counter(t)
for i in tc:
    if tc[i] > dc[i]:
        print("NO")
        exit()
print("YES")

Solution (Python):
n=int(input())
l1=list(map(int,input().split()))
n=int(input())
l2=list(map(int,input().split()))
l1.sort()
l2.sort()
le=len(l1)
ind=0
for i in l2:
  while True:
    if ind+1>le:
      print('NO')
      exit()
    if ind+1<=le and i==l1[ind]:
      ind+=1
      break
    else:
      ind+=1
print('YES')

Solution (Python):
from collections import defaultdict
input()
a = [int(x) for x in input().split()]
input()
b = [int(x) for x in input().split()]
dic = defaultdict(int)
flag = True
for i in a:
  dic[i] += 1
for i in b:
  dic[i] -= 1
  if dic[i] < 0:
    flag = False
if flag: print('YES')
else: print('NO')

Solution (Python):
import collections
n = int(input())
d =list(int(i) for i in input().split())
m = int(input())
t =list(int(i) for i in input().split())
a = collections.deque(sorted(d))
b = collections.deque(sorted(t))


for i in range(n):
  if a[0] == b[0]:
    b.popleft()
  a.popleft()
  if len(b) == 0:
    print('YES')
    exit()
  elif len(a) == 0:
    break
print('NO')

Solution (Python):
import collections


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

d = collections.Counter(D)
t = collections.Counter(T)

F  = True
dk = d.keys()

for tk in t.keys():
    if tk in dk == False:
        F = False
        break
    elif d[tk] < t[tk]:
        F = False
        break

if F:
    print('YES')
else:
    print('NO')

Solution (Python):
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
a=Counter(a)
m=int(input())
b=list(map(int,input().split()))
b=Counter(b)
for d,e in b.items():
    if a[d]<e:
        print("NO")
        exit()
print("YES")

Solution (Python):
N = int(input())
D = list(map(int, input().split()))
D_dict = {}
for i in range(N):
    if not D[i] in D_dict:
        D_dict[D[i]] = 0
    D_dict[D[i]] += 1

M = int(input())
T = list(map(int, input().split()))
ans = True
for i in range(M):
    if not T[i] in D_dict:
        ans = False
        break
    if D_dict[T[i]] == 0:
        ans = False
        break
    D_dict[T[i]] -= 1

print("YES" if ans else "NO")

Solution (Python):
from collections import Counter
N = int(input())
D = list(map(int,input().split()))
M = int(input())
T = list(map(int,input().split()))

c1 = Counter(D)
c2 = Counter(T)

for k,v in c2.items():
    if c1[k] < v:
        print('NO')
        exit()
print('YES')

Solution (Python):
N = int(input())
D = [int(_) for _ in input().split()]
M = int(input())
T = [int(_) for _ in input().split()]
levels = {}
for d in D:
    levels[d] = levels.get(d, 0) + 1
tests = {}
for t in T:
    tests[t] = tests.get(t, 0) + 1
for t in tests:
    if tests[t] > levels.get(t, 0):
        print('NO')
        exit()
print('YES')

Solution (Python):
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))
from collections import Counter
cs=Counter(d)
ct=Counter(t)
j=True
for x in t:
    if cs[x]<ct[x]:
        j=False
print("YES" if j else "NO")

Solution (Python):
from collections import Counter
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

DC = Counter(D)
for i in range(M):
  if T[i] in DC and DC[T[i]] > 0:
    DC[T[i]] -= 1
  else:
    print("NO")
    exit(0)
    
print("YES")

Solution (Python):
from collections import defaultdict

d = defaultdict(int)

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

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

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

judge = "YES"
for key in T:
	if d[key] >= 1:
		d[key] -= 1
	else:
		judge = "NO"
		break

print(judge)

Solution (Python):
N = int(input())
D = list(map(int,input().split()))
M = int(input())
T = list(map(int,input().split()))
flag = 1
DiD = {}
DiT = {}
for i in range(len(D)) :
    if D[i] not in DiD :
        DiD[D[i]] = 1
    else :
        DiD[D[i]] += 1
for i in range(len(T)) :
    if T[i] not in DiT :
        DiT[T[i]] = 1
    else :
        DiT[T[i]] += 1
        

for i in DiT :
    if (i not in DiD) or (DiT[i] > DiD[i]) :
        flag = 0
if flag == 1:
    print("YES")
else :
    print("NO")

Solution (Python):
N = int(input())
D = [int(i) for i in input().split()]
M = int(input())
T = [int(i) for i in input().split()]

Dd = {}
for d in D:
    if d not in Dd:
        Dd[d] = 1
    else:
        Dd[d] += 1

Td = {}
for t in T:
    if t not in Td:
        Td[t] = 1
    else:
        Td[t] += 1

for k,v in Td.items():
    if k in Dd and Dd[k] >= Td[k]:
        continue
    print("NO")
    exit()
print("YES")

Solution (Python):
import collections
N = int(input())
D = sorted(list(map(int, input().split())))

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

DD = collections.Counter(D)
TT = collections.Counter(T)
ch = 1
for t,num_t in TT.items():
    num_d = DD[t]
    if num_t > num_d:
        ch = 0

if ch == 1:
    print('YES')
else:
    print('NO')

Solution (Python):
from collections import defaultdict as dd
n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))
dict = dd(int)
for i in d:
    dict[i] += 1
for i in t:
    dict[i] -= 1
for k in dict:
    if dict[k] < 0:
        print('NO')
        exit()
print('YES')

Solution (Python):
import collections

N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))
flag = False
ans_flag = True
d = collections.Counter(D)
t = collections.Counter(T)


for i in t:
    i_str = str(i)
    d_count = d[i]
    if d_count < t[i]:
        print("NO")
        ans_flag = False
        break

if ans_flag == True:
    print("YES")

Solution (Python):
n = int(input())
D = list(map(int, input().split()))
m = int(input())
T = list(map(int, input().split()))
D_dict = {}
for d in D:
    if d not in D_dict:
        D_dict[d] = 1
    else:
        D_dict[d] += 1
for t in T:
    if t not in D_dict:
        print('NO')
        exit()
    else:
        if D_dict[t] == 0:
            print('NO')
            exit()
        else:
            D_dict[t] -= 1
print('YES')

Solution (Python):
from collections import Counter
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))
D=Counter(d);T=Counter(t)
x=0
for i in list(set(t)):
  if D[i]<T[i]:
    x=1
    break
if x==0:print('YES')
else:print('NO')

Solution (Python):
from collections import Counter
n=int(input())
a=list(map(int, input().split()))
m=int(input())
b=list(map(int, input().split()))
ans='YES'
a1=Counter(a)
b1=Counter(b)
for i in b:
    if a1[i]<b1[i]:
        ans='NO'
        break
print(ans)

Solution (Python):
n = int(input())
list_d = list((map(int, input().split())))
m = int(input())
list_t = list((map(int, input().split())))

dict_d = {}
dict_t = {}
for number in set(list_d):
    dict_d[number] = 0
for number in set(list_t):
    dict_d[number] = 0
for number in list_d:
    dict_d[number] += 1

for number in set(list_t):
    dict_t[number] = 0
for number in list_t:
    dict_t[number] += 1

for number,value in dict_t.items():
    if dict_d[number] < value:
        print("NO")
        break
    else:
        pass
else:
    print("YES")

Solution (Python):
import collections

n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
dc = collections.Counter(d)
tc = collections.Counter(t)
for i in tc:
    if tc[i] > dc[i]:
        print("NO")
        exit()
print("YES")

Solution (Python):
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")

Solution (Python):
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))
D.sort()
T.sort()
i = 0
for t in T:
    while i < N:
        if D[i]==t:
            i+=1
            break
        else:
            i+=1
    else:
        print("NO")
        exit()
print("YES")

Solution (Python):
import sys
from collections import Counter
candnum=int(input())
candiff=list(map(int,input().split()))
pronum=int(input())
prodiff=list(map(int,input().split()))

candiff=Counter(candiff)
prodiff=Counter(prodiff)
if pronum>candnum:
    print("NO")
    sys.exit()
for k,v in prodiff.items():
    if k in candiff:
        if candiff[k]<v:
            print("NO")
            sys.exit()
    else:
        print("NO")
        sys.exit()
print("YES")

Solution (Python):
import sys
from collections import Counter
 
N = int(input())
s1 = list(map(int,input().split()))
M = int(input())
s2 = list(map(int,input().split()))
 
c1 = Counter(s1)
c2 = Counter(s2)
 
for k,v in c2.items():
    if k in c1:
        if v > c1[k]:
            print('NO')
            sys.exit()
    else:
        print('NO')
        sys.exit()
print('YES')

Solution (Python):
N = int(input())
D = sorted([int(x) for x in input().split()])
M = int(input())
T = sorted([int(x) for x in input().split()])
j = 0
for i in range(len(D)):
    if j == len(T):
        break
    if D[i] == T[j]:
        j += 1
print("YES" if j == len(T) else "NO")

Solution (Python):
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))
D.sort()
T.sort()
i = 0
j = 0
while True:
    if i >= len(T) or j >= len(D):
        break
    ans = 0
    while True:
        if j >= len(D):
            break
        if T[i] == D[j]:
            ans = 1
            j += 1
            break
        j += 1
    if ans == 0:
        break
    i += 1
            
if ans == 1:
    print("YES")
elif ans == 0:
    print("NO")

Solution (Python):
from collections import Counter
n=int(input())
d=Counter(map(int,input().split()))
m=int(input())
t=Counter(map(int,input().split()))

for i in t.keys():
  if not i in d:
    print("NO")
    break
  elif d[i]<t[i]:
    print("NO")
    break
else:
  print("YES")

Solution (Python):
input()
d={}
for k in input().split():
  d[k]=d.get(k,0)+1
input()
for i in input().split():
  if d.get(i,0)>0:
    d[i]-=1
  else:
    print('NO')
    break
else:
  print('YES')

Solution (Python):
input()
d={}
for k in input().split():
  d[k]=d.get(k,0)+1
input()
for i in input().split():
  if d.get(i,0)>0:
    d[i]-=1
  else:
    print('NO')
    break
else:
  print('YES')

Solution (Python):
from collections import defaultdict
def getinputdata():

    
    array_result = []
    
    data = input()
    
    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

            else:

                flg = 0
    finally:

        return array_result

arr_data = getinputdata()

n = int(arr_data[0][0])
arr=[int(x) for x in arr_data[1]]

numbers = defaultdict(lambda: 0)
for v in arr:
    numbers[v] += 1
hash01=dict(numbers)

m = int(arr_data[2][0])
arr_problem=[int(x) for x in arr_data[3]]

numbers_problem = defaultdict(lambda: 0)
for v in arr_problem:
    numbers_problem[v] += 1
hash02=dict(numbers_problem)

chkflg=True

for k,v in hash02.items():
    
    if not k in hash01 or v>hash01[k]:
    
        chkflg=False
    
print("YES" if chkflg else "NO")

Solution (Python):
import sys
from collections import defaultdict

dict = defaultdict(int) 

N = list(input())
D_li = list(map(int,input().split()))

for key in D_li:
	dict[key] += 1
	
M = list(input())
T_li = list(map(int,input().split()))

for key in T_li:
	dict[key] -= 1
	if dict[key] < 0:
		print('NO')
		sys.exit()

print('YES')

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

P = dict()
for k in range(N):
    if D[k] in P:
        P[D[k]] += 1
    else:
        P[D[k]] = 1

for k in range(M):
    if T[k] in P:
        P[T[k]] -= 1
        if P[T[k]] == -1:
            print("NO")
            exit(0)
    else:
        print("NO")
        exit(0)
print("YES")

Solution (Python):
lena=int(input())
s=input().split()
a=[]
for i in s:
 a.append(int(i))
a.sort()
lenb=int(input())
s=input().split()
b=[]
for i in s:
 b.append(int(i))
b.sort()
i=0
j=0
while i<lena:
    if a[i]==b[j]:
        i+=1
        j+=1
        if j==lenb:
            break
    elif a[i]<b[j]:
        i+=1
    else:
        break
if j==lenb:
    print("YES")
else:
    print("NO")

Solution (Python):





if __name__ == '__main__':
    from collections import Counter

    n = int(input())
    ds = Counter(list(map(int, input().split())))
    m = int(input())
    ts = Counter(list(map(int, input().split())))

    for t_key, t_value in ts.items():
        if (ds[t_key] - t_value) < 0:
            print('NO')
            exit()

    print('YES')

Solution (Python):
import collections
N = int(input())
D = [int(i) for i in input().split()]
M = int(input())
T = [int(i) for i in input().split()]

count_D = collections.Counter(D)
count_T = collections.Counter(T)

ans = 'YES'
for k,v in count_T.items():
  if count_D[k] < v:
    ans = 'NO'
    break
print(ans)

Solution (Python):
from collections import Counter
from bisect import bisect
n = int(input())
d = [int(i) for i in input().split()]
m = int(input())
t = [int(i) for i in input().split()]
d,tc,flag = sorted(d),Counter(t),True
for i in tc.most_common():
	if bisect(d,i[0])-bisect(d,i[0]-1)<i[1]:
		flag = False
		break
if flag: print("YES")
else: print("NO")

Solution (Python):
N = int(input())
Ds = list(map(int,input().split()))
dif = {}
for D in Ds:
  if D in dif:
    dif[D] += 1
  else:
    dif[D] = 1
M = int(input())
Ts = list(map(int,input().split()))
for T in Ts:
  if T not in dif:
    print('NO')
    exit()
  else:
    if 0 < dif[T]:
      dif[T] -= 1
    else:
      print('NO')
      exit()
print('YES')

Solution (Python):
N=int(input())
D=[int(i) for i in input().split()]
M=int(input())
T=[int(i) for i in input().split()]
D.sort()
T.sort()
d=dict()
t=dict()
for i in range(N):
    if not D[i] in d:
        d[D[i]]=1
    d[D[i]]+=1
for i in range(M):
    if not T[i] in t:
        t[T[i]]=1
    t[T[i]]+=1
S=set(T)
for i in S:
    if not i in d:
        print("NO")
        exit()
    if d[i]<t[i]:
        print("NO")
        exit()
print("YES")

Solution (Python):
import collections
N = int(input())
D = collections.Counter(map(int, input().split()))
M = int(input())
T = collections.Counter(map(int, input().split()))
for k,v in T.items():
    if D[k]<v:
        print('NO')
        break
else:
    print('YES')

Solution (Python):
n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))

dd = {}
tt ={}
for i in t:
    if i in tt:
        tt[i] += 1
    else:
        tt[i] = 1
        dd[i] = 0
for i in d:
    if i in dd:
        dd[i] += 1
    else:
        dd[i] =1


ans = 'YES'
for i in tt:
    if tt[i] > dd[i]:
        ans = 'NO'
print(ans)

Solution (Python):
from collections import defaultdict

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

    L = set(D+T)
    D_count = defaultdict(int)
    T_count = defaultdict(int)

    for d in D: D_count[d] += 1
    for t in T: T_count[t] += 1

    for t in T_count:
        if t not in D_count: D_count[t] = 0
        if D_count[t] < T_count[t]:
            print("NO")
            return
    
    print("YES")
    return

a()

Solution (Python):
n = int(input())
d = input().split()
b1 = dict()
for i in d:
    b1[i] = b1.get(i, 0) + 1

m = int(input())
t = input().split()
b2 = dict()
for i in t:
    b2[i] = b2.get(i, 0) + 1

for tKey in b2.keys():
    if not(tKey in b1) or (b2[tKey] > b1[tKey]):
        print('NO')
        exit()       
print('YES')

Solution (Python):
import sys
from collections import Counter


n=int(input())
Dc=Counter(input().split())
m=int(input())
Tc=Counter(input().split())
for key,val in Tc.items():
    if(val>Dc[key]):
        print("NO")
        sys.exit()
print("YES")

Solution (Python):
from collections import Counter


def main():
    """
    1 ≤ N  ≤ 2 * 10^5
    1 ≤ Di ≤ 10^9
    1 ≤ M  ≤ 2 * 10^5
    1 ≤ Ti ≤ 10^9

    N*M: TLE
    """
    N = int(input())
    D = map(int, input().split())
    M = int(input())
    T = map(int, input().split())

    f(N, D, M, T)


def f(N, D, M, T):
    c = Counter(D)
    for t in T:
        if c[t] == 0:
            print("NO")
            return

        c[t] -= 1

    print("YES")


if __name__ == '__main__':
    main()

Solution (Python):
import collections
n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))
dcounter = collections.Counter(d)
tcounter = collections.Counter(t)
check = True
for i in tcounter.items():
	if dcounter[i[0]] < i[1]:
		check = False
if check:
	print('YES')
else:
	print('NO')

Solution (Python):
import collections
n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))
dcounter = collections.Counter(d)
tcounter = collections.Counter(t)
check = True
for i in tcounter.items():
	if dcounter[i[0]] < i[1]:
		check = False
if check:
	print('YES')
else:
	print('NO')

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

D.sort();T.sort()
di = 0
ti = 0
while True:
     d = D[di];t=T[ti]
     if d==t:
         di+=1;ti+=1
     elif d>t:
         print("NO")
         exit()
     elif t>d:
         di+=1
     if ti >= len(T):
         print("YES")
         exit()
     if di >= len(D):
         print(di)
         print("NO")
         exit()

Solution (Python):
from collections import defaultdict

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

dic = defaultdict(int)
for d in D:
    dic[d] += 1

for t in T:
    if t in dic and dic[t] >= 1:
        dic[t] -= 1
    else:
        print("NO")
        exit()
print("YES")

Solution (Python):
def solve():
    N = int(input())
    D = list(map(int, input().split()))
    M = int(input())
    T = list(map(int, input().split()))
    prepared_map = {}
    necessary_map = {}
    for i in D:
        if not i in prepared_map.keys():
            prepared_map[i] = 1
        else:
            prepared_map[i] = prepared_map[i] + 1
        if not i in necessary_map.keys():
            necessary_map[i] = 0
    for i in T:
        if not i in necessary_map.keys():
            necessary_map[i] = 1
        else:
            necessary_map[i] = necessary_map[i] + 1
        if not i in prepared_map.keys():
            prepared_map[i] = 0
    if all(prepared_map[k] >= necessary_map[k] for k in necessary_map.keys()):
        print("YES")
    else:
        print("NO")

solve()

Solution (Python):
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")


def main():
    N = int(input())
    D_list = list(map(int, input().split()))
    M = int(input())
    T_list = list(map(int, input().split()))

    c = Counter(D_list)
    for t in T_list:
        if c[t] <= 0:
            print("NO")
            return
        c[t] -= 1
    print("YES")


if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter

N = int(input())
D = [int(i) for i in input().split()]
M = int(input())
T = [int(i) for i in input().split()]

d = Counter(D)
t = Counter(T)

for k, v in t.items():
    if d[k] < v:
        print('NO')
        break
else:
    print('YES')

Solution (Python):

import collections

n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))

dc = collections.Counter(d)
tc = collections.Counter(t)
s = [0 for i in range(len(tc))]
for i,index in enumerate(tc):
    s[i] = dc[index]-tc[index]
    

print('YES' if all(list(map(lambda x : x >= 0 , s))) else 'NO')

Solution (Python):
import sys
N=input()
a={}
for i in raw_input().split():
	
	if i in a:
		a[i]=a[i]+1
	else:
		a[i]=1



M=input()
for j in raw_input().split():
	
	if j in a:
		a[j]=a[j]-1
		if a[j]<0:
			print "NO"
			sys.exit()
	else:
			print "NO"
			sys.exit()		

print "YES"

Solution (Python):
import sys
N=int(input())
D=list(map(int,input().split()))
M=int(input())
T=list(map(int,input().split()))
D.sort()
T.sort()
for i in range(M-1,-1,-1):
  while D:
    q=D.pop()
    if T[i]==q:
      
      break
    elif T[i]>q:
      print("NO")
      sys.exit()
  else:
    print("NO")
    sys.exit()
print("YES")

Solution (Python):
from collections import Counter
input()
d = Counter(map(int, input().split()))
input()
t = Counter(map(int, input().split()))
d.subtract(t)
print("NO" if -d else "YES")

Solution (Python):
from collections import Counter
n = input()
d = Counter(map(int, input().split()))
m = input()
t = Counter(map(int, input().split()))
d.subtract(t)
print("NO" if -d else "YES")

Solution (Python):
N = int(input())
D = sorted(map(int, input().split()))
M = int(input())
T = sorted(map(int, input().split()))
i = 0
for t in T:
    while D[i] < t:
        i += 1
    if D[i] == t:
        i += 1
    else:
        print('NO')
        exit()
print('YES')

Solution (Python):
import numpy as np

N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))
res = True
dic = {}
for i in range(N):
  if D[i] in dic:
    dic[D[i]] += 1
  else:
    dic[D[i]] = 1
for j in range(M):
  if (dic.get(T[j], 0) == 0):
    res = False
    break
  else:
    dic[T[j]] -= 1
if(res):
  print("YES")
else:
  print("NO")

Solution (Python):
from collections import defaultdict


def main():
    dic = defaultdict(lambda: 0)
    _ = input()
    d_list = [int(i) for i in input().split()]
    for d in d_list:
        dic[d] += 1

    flag = True
    _ = input()
    m_list = [int(i) for i in input().split()]
    for m in m_list:
        dic[m] -= 1
        if dic[m] < 0:
            flag = False
            break
    if flag: print("YES")
    else: print("NO")


if __name__ == "__main__":
    main()

Solution (Python):
import collections

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

DS=collections.Counter(D)
TS=collections.Counter(T)

for i,k in TS.items():

    if k > DS[i]:
        print('NO')
        exit()

print('YES')

Solution (Python):
n = int(input())
d = sorted(list(map(int,input().split())))
m = int(input())
t = sorted(list(map(int,input().split())))
didx = 0
tidx = 0
while tidx < m and didx < n:
    if d[didx] == t[tidx]:
        didx += 1; tidx += 1
    elif d[didx] < t[tidx]:
        didx += 1
    else:
        print("NO")
        break
else:
    if tidx == m:
        print("YES")
    else:
        print("NO")

Solution (Python):
from collections import defaultdict

n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))

di = defaultdict(lambda: 0)

for i in d:
    di[i] += 1
      
ans = "YES" 
      
for i in t:
    if (i not in di) or (di[i] == 0):
        ans = "NO"
        break
    else:
        di[i] -= 1
         
print(ans)

Solution (Python):
n = int(input())
d = input().split()
m = int(input())
t = input().split()
 
dic = dict()
 
for di in d:
    if di in dic:
        dic[di] += 1
    else:
        dic[di] = 1
 
ans = "YES"
for ti in t:
    if ti not in dic or dic[ti] == 0:
        ans = "NO"
        break
    else:
        dic[ti] -= 1
 
print(ans)

Solution (Python):

q=input()
x=[int(i) for i in input().split()]
cnt=input()
y=[int(i) for i in input().split()]

if max(x) >= max(y):
    MAX=max(x)
else:
    MAX=max(y)

dic = {}

for k in x :
    if k in dic.keys() :
        dic[k] += 1
    else :
        dic[k] = 1
    
for i in y :
    if i in dic.keys() :
        dic[i] -= 1
        if dic[i] == -1 :
            print('NO')
            exit()
    else :
        print('NO')
        exit()
print('YES')