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 defaultdict

n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
h = defaultdict(int)
g = defaultdict(int)
for k in d:
    h[k] += 1
for k in t:
    g[k] += 1
f = True
for k in g.keys():
    if h[k] < g[k]:
        f = False
        break
print(("YES" if f else "NO"))

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
D = LIST()
M = INT()
T = LIST()
a = Counter(D)
b = Counter(T)

for d in T:
    if a[d] == 0:
        print("NO")
        exit()
    else:
        
        
        a[d] -= 1
print("YES")

Solution (Python):
from collections import defaultdict
def main():
    N = int( input())
    D = list( map( int, input().split()))
    M = int( input())
    T = list( map( int, input().split()))
    probs = defaultdict( int)
    for d in D:
        probs[d] += 1
    for t in T:
        if probs[t] == 0:
            print("NO")
            return
        probs[t] -= 1
    print("YES")
if __name__ == '__main__':
    main()

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

t = 0

for d in D:
    if t < len(T) and T[t] == d:
        t += 1
        d += 1

    if t == len(T):
        break

print('YES' if t == len(T) else 'NO')

Solution (Python):
from collections import Counter

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

dc, tc = Counter(d), Counter(t)
ans = "YES"
for p in tc.keys():
    if tc[p] > dc[p]:
        ans = "NO"

print(ans)

Solution (Python):
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

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

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def dijkstra_heap(s, edge, n):
    
    d = [10**20] * n
    used = [True] * n 
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


def lcm(x, y):
    return (x * y) // gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm, numbers, 1)


def gcd_list(numbers):
    return reduce(gcd, numbers)


def is_prime(n):
    if n <= 1:
        return False
    p = 2
    while True:
        if p ** 2 > n:
            break
        if n % p == 0:
            return False
        p += 1
    return True



def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P


def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret



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




yes = True

for i in t_list:
    
    
    
    if d[i] == 0:
        yes = False
        break   
    d[i] -= 1

if yes:
    print("YES")
else:
    print("NO")

Solution (Python):
import sys
from collections import Counter

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    D = list(map(int, input().split()))
    m = int(input())
    T = list(map(int, input().split()))

    P = Counter(D)

    for i in range(m):
        P[T[i]] -= 1

    for v in P.values():
        if v < 0:
            print("NO")
            break
    else:
        print("YES")


if __name__ == '__main__':
    resolve()

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

ok = True
for i, j in tt.items():
    if i in dd:
        
        if dd[i] < j:
            ok = False
    else:
        ok = False
    

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

Solution (Python):

def myAnswer(N:int,D:list,M:int,T:list) -> str:
   dic = {key:0 for key in T}
   for d in D:
      if(d in dic.keys()):
         dic[d] += 1
   for t in T:
      if(dic[t] == 0):
         return "NO"
      else:
         dic[t] -= 1
   return "YES"

def modelAnswer():
   return
def main():
   N = int(input())
   D = list(map(int,input().split()))
   M = int(input())
   T = list(map(int,input().split()))
   print(myAnswer(N,D[:],M,T[:]))
if __name__ == '__main__':
   main()

Solution (Python):
n = int(input())
d = sorted(list(map(int,input().split())))
m = int(input())
t = sorted(list(map(int,input().split())))
ans = 'YES'
x = 0
for i in t:
    while  x<n and d[x]<i:
        x+=1
    if x==n or i!=d[x]:ans='NO'
    else:x+=1
print(ans)

Solution (Python):


from collections import deque,Counter













N = int(input())
arrD = list(map(int,input().split()))
M = int(input())
arrT = list(map(int,input().split()))

cntD = Counter(arrD)
cntT = Counter(arrT)

for dif,cnt in cntT.items():
    if dif in cntD:
        if cnt > cntD[dif]:
            print("NO")
            exit()
    else:
        print("NO")
        exit()

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(sorted(d))
cnt = 0
for i in range(m):
    if t[i] in d and d[t[i]] > 0:
        d[t[i]] -= 1
        cnt += 1
    else: break
print("YES" if cnt == m else "NO")

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

max_diff = max(D)
difficulty = {}
for d in D:
    try:
        difficulty[d] += 1
    except:
        difficulty[d] = 1

for t in T:
    try:
        difficulty[t] -= 1
    except:
        print('NO')
        sys.exit()
    if difficulty[t] < 0:
        print('NO')
        sys.exit()
print('YES')

Solution (Python):
import collections

n = int(input())
d = [int(_) for _ in input().split()]
m = int(input())
t = [int(_) for _ in input().split()]

D = collections.Counter(d)
nd = dict.fromkeys(D, 0)

for i in range(m):
    if t[i] in nd:
        get_cnt = nd[t[i]] + 1
        if get_cnt <= D[t[i]]:
            nd[t[i]] = get_cnt
        else:
            print('NO')
            exit()
    else:
        print('NO')
        exit()
print('YES')

Solution (Python):
import collections

n = int(input())
d = [int(_) for _ in input().split()]
m = int(input())
t = [int(_) for _ in input().split()]

D = collections.Counter(d)
nd = dict.fromkeys(D, 0)

for i in range(m):
    if t[i] in nd:
        get_cnt = nd[t[i]] + 1
        if get_cnt <= D[t[i]]:
            nd[t[i]] = get_cnt
        else:
            print('NO')
            exit()
    else:
        print('NO')
        exit()
print('YES')

Solution (Python):
from collections import Counter
def main():
    N, D = int(input()), Counter(list(map(int, input().split())))
    M, T = int(input()), Counter(list(map(int, input().split())))
    result = "YES"
    for key, value in T.items():
        temp = D.get(key)
        if temp == None or temp < value:
            result = "NO"
            break
    print(result)
main()

Solution (Python):
from collections import Counter

n = int(input())
dl = list(map(int, input().split()))
m = int(input())
tl = list(map(int, input().split()))

dc = Counter(dl)
tc = Counter(tl)

for k in tc:
    if dc[k]<tc[k]:
        print("NO")
        exit()
print("YES")

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

dindex = 0
for i in range(M):
  while 1:
    dindex += 1
    if T[i] == D[dindex-1]:
      break
    elif dindex == N:
      print('NO')
      exit()
print('YES')

Solution (Python):
import bisect
n = int(input())
d_li = list(map(int,input().split()))
m = int(input())
t_li = list(map(int,input().split()))

import collections
d_cnt = collections.Counter(d_li)
t_cnt = collections.Counter(t_li)


for t in t_cnt.items():
    
    if d_cnt[t[0]] < t[1]:
        print('NO')
        exit()
print('YES')

Solution (Python):
from collections import*
i = eval("Counter(list(map(int, input().split()))),"*4)
print("YNEOS"[i[3]-i[1] != {}::2])

Solution (Python):
from collections import*
i = eval("Counter(list(map(int, input().split()))),"*4)
print("YNEOS"[any(i[1][j] < k for j, k in i[3].items())::2])

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 t in c2.keys():
    if c2[t] > c1[t]:
        print("NO")
        exit()
print("YES")

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

cnt_D = Counter(D)
cnt_T = Counter(T)
for t in T:
	if cnt_D[t] < cnt_T[t]:
		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()))

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


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

Solution (Python):
from collections import Counter 

N=int(input())
C = Counter(list(map(int,input().split())))
O=int(input())
M = Counter(list(map(int,input().split())))
for key in M.keys():
  if C[key]<M[key]:
    print("NO")
    break
else:
  print("YES")

Solution (Python):
n=int(input())
d=sorted(list(map(int,input().split())))
m=int(input())
t=sorted(list(map(int,input().split())))
if m>n:
    print("NO")
else:
    a=0
    for i in range(m):
        flag=0
        while flag!=1:
            if a==n:
                print("NO")
                exit()
            if t[i]>d[a]:
                a+=1
            elif t[i]==d[a]:
                a+=1
                flag=1
            else:
                print("NO")
                exit()
    print("YES")

Solution (Python):
import collections
n = int(input())
d = list(map(int,input().split()))
dc = collections.Counter(d)

m = int(input())
t = list(map(int,input().split()))
dt = collections.Counter(t)

for k,v in dt.items():
    if dc[k] < v:
        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())))

ans = 'YES'
di = -1
for t in T:
  while True:
    di += 1
    if di >= n:
      ans = 'NO'
      break    
    if D[di] == t:
      break
        
print(ans)

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    

    
    

    n = int(input())
    d = list(map(int, input().split()))
    m = int(input())
    t = list(map(int, input().split()))
    dc = Counter(d)
    tc = Counter(t)
    for k, v in tc.items():
        if dc[k]<v:
            print('NO')
            break
    else:
        print('YES')

if __name__ == '__main__':
    main()

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

Solution (Python):
import collections

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

DC = collections.Counter(D)

for t in T:
    if t in DC:
        if DC[t] > 0:
            DC[t] -= 1
            continue

    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()))

d.sort(reverse=True)
t.sort(reverse=True)

for i in range(n):
    if t[-1]==d[-1]:
        d.pop()
        t.pop()
    else:
        d.pop()
    if t==[]:
        print("YES")
        exit()
    if d==[]:
        print("NO")
        exit()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
def main():
    n=int(input())
    D=[int(_) for _ in input().split()]
    D_c=Counter(D)
    M=int(input())
    T=[int(_) for _ in input().split()]
    T_c=Counter(T)
    for t in T_c.items():
        if D_c[t[0]]<t[1]:
            print("NO")
            break
    else:
        print("YES")

if __name__=='__main__':
    main()

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()]

c = collections.Counter(d)


for i in t:
  if i in c:
    c[i] = c[i] - 1
  elif i not in c:
    print("NO")
    exit()


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

print("YES")

Solution (Python):
from collections import Counter  
import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


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

        DD = Counter(D)
        TT = Counter(T)

        for key, value in TT.items():
            if DD[key] < value:
                return 'NO'
        return 'YES'

    print(main())


resolve()

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

D.sort()
T.sort()
if N<M:
    print("NO")
    exit()

flag=True
cnt=0
count=0
for i in range(M):
    if cnt>=N:
        flag=False
        break
    chk=0
    while(D[cnt]!=T[i]):
        cnt+=1
        chk=1
        if cnt==N:
            flag=False
            break
    if cnt>=N:
        break
    if D[cnt]==T[i]:
        count+=1
    cnt+=1

if count==M:
    pass
else:
    flag=False

if flag:
    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()))

from collections import Counter
cntr = Counter(D)
ans = 'YES'
for t in T:
  if cntr.get(t) == None or cntr.get(t) == 0:
    ans = 'NO'
    break
  else:
    cntr[t] -= 1
print(ans)

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
stat=''
while i < n and j < m:
  if d[i]==t[j]:
    i+=1
    j+=1
  elif d[i]>t[j]:
    print('NO')
    exit()
  elif d[i]<t[j]:
    i+=1
print('YES' if j==m else 'NO')

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()]

if n < m:
    print('NO')
else:
    d_c = Counter(d)
    t_c = Counter(t)
    for k, v in t_c.items():
        n = d_c.get(k, 0)
        if n >= v:
            continue
        else:
            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()))

d.sort()
t.sort()
j = 0


for i in range(n):
    if d[i] == t[j]:
        if j < m-1:
            j += 1
        else:
            j += 1
            break

if j == m:
    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()
j = 0


for i in range(n):
    if d[i] == t[j]:
        if j < m-1:
            j += 1
        else:
            j += 1
            break

if j == m:
    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()]

def bs(nums, target):
    l = 0
    r = len(nums) - 1
    while l <= r:
        mid = (l + r) // 2
        if nums[mid] == target:
            return mid
        elif nums[mid] > target:
            r = mid - 1
        else:
            l = mid + 1
    return -1

if n < m:
    print('NO')
else:
    d.sort()
    t.sort()
    i = j = 0
    while i < n and j < m:
        if d[i] == t[j]:
            i += 1
            j += 1
        else:
            i += 1
    if j == m:
        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()))

cnt = {}
for d in D:
    if d not in cnt:
        cnt[d] = 1
    else:
        cnt[d] += 1
ans = True
for t in T:
    if t not in cnt:
        ans = False
        break
    elif cnt[t] == 0:
        ans = False
        break
    else:
        cnt[t] -= 1

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

Solution (Python):
import bisect

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

d.sort()
t.sort()

set_t = list(set(t))


for i in range(len(set_t)):
    n_d = bisect.bisect_right(d,set_t[i]) - bisect.bisect_left(d,set_t[i])
    n_t = bisect.bisect_right(t,set_t[i]) - bisect.bisect_left(t,set_t[i])
    
    if n_t > n_d:
        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()))

import collections
dict_D = dict(collections.Counter(D))
dict_T = dict(collections.Counter(T))

for k, v in dict_T.items():
    if v <= dict_D.get(k, 0):
        pass
    else:
        print('NO')
        break
else:
    print('YES')

Solution (Python):
n = int(input())
d = [int(x) for x in input().split()]
m = int(input())
t = [int(x) for x in input().split()]

from collections import Counter

t = dict(Counter(t))
d = dict(Counter(d))
for i in t.keys():
    if d.get(i)==None or d.get(i)<t.get(i):
        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()))
if n < m:
    print('NO')
    exit(0)
dcnt = {}
for x in d:dcnt[x] = 0
ok = True
for x in d:dcnt[x]+=1
for i in range(m):
    if t[i] not in dcnt:
        ok = False
        break
    if dcnt[t[i]] == 0:
        ok = False
        break
    dcnt[t[i]] -= 1
if ok:print('YES')
else:print('NO')

Solution (Python):
from collections import Counter
n = int(input())
d = [int(x) for x in input().split()]
m = int(input())
t = [int(x) for x in input().split()]

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

ans = "YES"
for x in T.keys():
    if D[x] < T[x]:
        ans = "NO"
        break

print(ans)

Solution (Python):
import collections

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


for i in t:
    if t[i]>d[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())))
for x in T[::-1]:
    while 1:
        if len(D)==0:
            print('NO')
            exit()
        temp = D.pop()
        if temp==x:
            break
print('YES')

Solution (Python):
N = int(input())
D = sorted(list(map(int,input().split())))
M = int(input())
T = sorted(list(map(int,input().split())))
for x in T[::-1]:
    while 1:
        if len(D)==0:
            print('NO')
            exit()
        temp = D.pop()
        if temp==x:
            break
else:
    print('YES')

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

Solution (Python):
N = int(input())
D = sorted(list(map(int, input().split())))
M = int(input())
T = sorted(list(map(int, input().split())))
C = {}
for d in D:
    if d in C:
        C[d] += 1
    else:
        C[d] = 1
E = {}
for t in T:
    if t in E:
        E[t] += 1
    else:
        E[t] = 1
for key, val in E.items():
    if key in C:
        C[key] //= val

print('YES' if min([C[t] if t in C else 0 for t in T]) > 0 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()))

d_cnt = Counter(d)
t_cnt = Counter(t)

flag = True
for k, v in t_cnt.items():
    if k in d_cnt.keys():
        if v > d_cnt[k]:
            flag = False
            break
    
    else:
        flag = False
        break
print("YES" if flag 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)

ans = 'YES'
for k, v in c2.items():
    if not k in c1.keys():
        ans = 'NO'
        break
    if c1[k] < v:
        ans = 'NO'
        break

print(ans)

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_ans = dict(Counter(d))
t_ans = dict(Counter(t))
flag = True
for i in t_ans:
    if i not in d_ans:
        flag = False
        
    else:
        if t_ans[i] > d_ans[i]:
            flag = False
print('YES' if flag==True else 'NO')

Solution (Python):
n=int(input())
d=list(map(int,input().split()))
d=sorted(d)
m=int(input())
t=list(map(int,input().split()))
t=sorted(t)
flag=True 
if n<m:
    flag=False
else:
    t_num=[] 
    bef=t[0]
    ren=1
    for i in range(1,m):
        if bef!=t[i]:
            t_num.append([bef,ren])
            bef=t[i]
            ren=1
        else:
            ren+=1
    t_num.append([bef,ren])
    kind=len(t_num)
    
    
    now=0
    ren=0
    for i in range(n):
        if t_num[now][0]==d[i]:
            ren+=1
        else: 
            if ren!=0: 
                if t_num[now][1]<=ren:
                    now+=1
                    ren=0
                    if kind==now: 
                        break
                    if t_num[now][0]==d[i]:
                        ren+=1
                else:
                    flag=False
                    break
        
        
    if ren!=0: 
        if t_num[now][1]<=ren:
            now+=1
    if now<kind: 
        flag=False
print("YES" if flag else "NO")

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

Solution (Python):
from collections import Counter

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

valid = True
for i in t:
    if d[i] < t[i]:
        valid = False

if valid: print("YES")
else: print("NO")

Solution (Python):
from collections import Counter as c
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
flag = True
d_c = c(d)
t_c = c(t)
if n<m: flag = False
else: 
    for i,j in t_c.items():
        if d_c[i] < j:
            flag = False
            break
print('YES' if flag 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()))
need = Counter(T)
aru = Counter(D)
for k in need:
    if aru[k] < need[k]:
        print('NO')
        exit()
print('YES')

Solution (Python):
n = int(input())
*D, = map(int, input().split())
m = int(input())
*T, = map(int, input().split())
D.sort()
T.sort()
j = 0
for i in range(n):
    if j == m:
        break
    if D[i] == T[j]:
        j += 1
if j == m:
    print('YES')
else:
    print('NO')

Solution (Python):
from collections import Counter

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



for key, value in T.items():
    if D.get(key) is None:
        print('NO')
        exit()
    if D.get(key) < value:
        print('NO')
        exit()
print('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()))
for i in t:
  if d[i] < t[i]:
    print('NO')
    exit()
print('YES')

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
x=int(input())
b=list(map(int,input().split()))
from collections import Counter
c=Counter(a)
d=Counter(b)

for x,y in d.items():
    if y>c[x]:
        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()))
ans = "YES"
dict = {}
keyword = set(D) | set(T)
for d in keyword:
    dict.update({d:0})
for d in D:
    dict[d]+=1
for t in T:
    dict[t]-=1
    if dict[t]<0:
        ans = "NO"
        break
print(ans)

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_ans = dict(Counter(d))
t_ans = dict(Counter(t))
flag = True
for i in t_ans:
    if i not in d_ans:
        flag = False
        
    else:
        if t_ans[i] > d_ans[i]:
            flag = False
print('YES' if flag==True else 'NO')

Solution (Python):
N = int(input())
Dlist = sorted(list(map(int, input().split())))
M = int(input())
Tlist = sorted(list(map(int, input().split())))
now = 0
for d in Dlist:
    if now == M:
        break
    if Tlist[now] == d:
        now += 1

if now == M:
    print("YES")
else:
    print("NO")