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):
N = int(input())
D = list(map(int, input().split()))
d_map = {}
for d in D:
    if d not in d_map:
        d_map[d] = 1
    else:
        d_map[d] += 1
        
M = int(input())
T = list(map(int, input().split()))
possible = True
for i in range(M):
    if T[i] not in d_map or d_map[T[i]] == 0:
        possible = False
        break
    d_map[T[i]] -= 1
    
if possible:
    print("YES")
else:
    print("NO")

Solution (Python):
from collections import*
def s():
	n,*L=open(0).read().split();n=int(n);print("YNEOS"[Counter(L[n+1:])-Counter(L[:n])!={}::2])
if __name__=="__main__":s()

Solution (Python):
from collections import*;_,a,_,b=eval("Counter(input().split()),"*4);print("YNEOS"[b-a!={}::2])

Solution (Python):

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

d.sort()
t.sort()
flag2 = True
pos = 0

for i in range(m):
    flag = False
    for j in range(pos, n):
        if t[i] == d[j]:
            pos = j+1
            flag = True
            break
        else:
            pass
    if flag :
        pass
    else:
        flag2 = False
        break

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

Solution (Python):
def resolve():
    n = int(input())
    d = list(map(int, input().split()))
    m = int(input())
    t = list(map(int, input().split()))
    dt, dd = dict(), dict()
    for l, dc in zip([d, t], [dd, dt]):
        for ti in l:
            if ti in dc:
                dc[ti] += 1
            else:
                dc[ti] = 1
    print("YES" if all(k in dd and dd[k] >= v for k, v in dt.items()) else "NO")


if __name__ == "__main__":
    resolve()

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 k,v in t.items():
    d[k]=d.get(k,0)-v
    if d[k]<0:
        print('NO')
        exit()
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)
ans="YES"
for k in list(t.keys()):
  if d[k]<t[k]:
    ans="NO"
    break
print(ans)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
m=int(input())
b=list(map(int,input().split()))
a.sort()
b.sort()
j=0
for i in range(n):
	if a[i]==b[j]:
		j+=1
	if j==m:
		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()))

if N < M:
    print('NO')
    exit()

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 in d_dict:
        d_dict[t] -= 1
        if d_dict[t] < 0:
            print('NO')
            exit()
    else:
        print('NO')
        exit()

print('YES')

Solution (Python):
def main():

    
    
    

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

    d1 = dict()
    for v in D:
        d1[v] = d1.get(v, 0) + 1
    d2 = dict()
    for v in T:
        d2[v] = d2.get(v, 0) + 1

    for v in d2:
        if v not in d1:
            return "NO"
        elif d2[v] > d1[v]:
            return "NO"
    return "YES"
if __name__ == '__main__':
    print(main())

Solution (Python):
N = int(input())
Ds = list(map(int, input().split()))
M = int(input())
Ts = list(map(int, input().split()))
nsD = {}
for D in Ds:
  if D not in nsD: nsD[D] = 0
  nsD[D] += 1
nsT = {}
for T in Ts:
  if T not in nsT: nsT[T] = 0
  nsT[T] += 1
ok = True
for T in nsT:
  nT = nsT[T]
  if T not in nsD or nT > nsD[T]:
    ok = False
    break
if ok:
  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
sw=0
for i in range(M):
    while 1:
      if T[i]==D[j]:
        j+=1
        break
      j+=1
      if j==N:
        sw=1
        break
    if sw==1:
      break
print("NO" if sw==1 else "YES")

Solution (Python):
N=int(input());D=sorted(map(int,input().split()))[::-1]
M=int(input());T=sorted(map(int,input().split()))
for t in T:
 d=0
 while D and d!=t:d=D.pop()
 if d!=t:print("NO");quit()
print("YES")

Solution (Python):
N=int(input())
D = sorted(map(int,input().split()))[::-1]
M=int(input())
T = sorted(map(int,input().split()))

for t in T:
  while D:
    d = D.pop()
    if t==d : break
  else:
    print("NO")
    break
else:
  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 i in T.keys():
    if not i in D.keys():
        print("NO")
        exit()
    else:
        if T[i] > D[i]:
            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()))

D_dict=collections.Counter(D)
T_dict=collections.Counter(T)

for i in T_dict.keys():
    if not i in D_dict.keys():
        print("NO")
        exit()
    else:
        if T_dict[i]>D_dict[i]:
            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()))
d_dict = {}
for d in D:
    if d not in d_dict:
        d_dict[d] = 0
    d_dict[d] += 1
 
count = 0
for t in T:
    if t in d_dict and d_dict[t] > 0:
        d_dict[t] -= 1
        count += 1
if count == 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_dict = {}
for d in D:
    if d not in d_dict:
        d_dict[d] = 0
    d_dict[d] += 1

count = 0
for t in T:
    if t in d_dict and d_dict[t] > 0:
        d_dict[t] -= 1
        count += 1
if count == M:
    print("YES")
else:
    print("NO")

Solution (Python):
import collections

a=int(input())
b=collections.Counter(list(map(int,input().split())))
c=int(input())
d=collections.Counter(list(map(int,input().split())))
e=set(d)

for item in e:
  if d[item]>b[item]:
    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()))

dicD = {}
dicT = {}

for d in D:
    if d not in dicD:
        dicD[d] = 0
    dicD[d] += 1

for t in T:
    if t not in dicT:
        dicT[t] = 0
    dicT[t] += 1

for t in dicT:
    if (t not in dicD) or (dicT[t] > dicD[t]):
        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()))

dicD = {}
dicT = {}

for d in D:
    if d not in dicD:
        dicD[d] = 0
    dicD[d] += 1

for t in T:
    if t not in dicT:
        dicT[t] = 0
    dicT[t] += 1

for t in dicT:
    if t not in dicD:
        print("NO")
        break
    elif dicT[t] > dicD[t]:
        print("NO")
        break
else:
    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()]
import sys
from collections import Counter
d = Counter(d)
for i in t:
    if not i in d:
        print('NO')
        sys.exit()
    d[i] -= 1
print('YES') if min(d.values()) >= 0 else print('NO')

Solution (Python):



import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
d = LI()
m = I()
t = LI()
x = defaultdict(lambda : 0)
y = defaultdict(lambda : 0)
for i in range(n):
    x[d[i]] += 1
for i in range(m):
    y[t[i]] += 1
for i,j in y.items():
    if x[i] < j:
        print('NO')
        quit()
print('YES')

Solution (Python):
n = int(input())

ht = {}

for i in input().split():
  ht[i] = ht.get(i, 0) + 1

m = int(input())

for i in input().split():
  if i not in ht or ht[i] == 0:
    print("NO")
    exit()
  else:
    ht[i] -= 1

print("YES")

Solution (Python):
from collections import Counter
n=int(input())
ln=list(map(int,input().split()))
m=int(input())
lm=list(map(int,input().split()))
d=dict(Counter(ln))
ans="YES"
for i in lm:
    try:
        if d[i]>=1:d[i]-=1
        else:ans="NO"
    except:ans="NO"
print(ans)

Solution (Python):
from collections import Counter
N = int(input())
c1 = Counter([int(_) for _ in input().split()])
M = int(input())
c2 = Counter([int(_) for _ in input().split()])
for a,b in c2.items():
    if c1[a]<b:
        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()))

dd = {}
for i in range(n):
    if d[i] in dd:
        dd[d[i]] += 1
    else:
        dd[d[i]] = 1


ans = "YES"
for i in t:
    try:
        if dd[i] >= 1:
            dd[i] -= 1
        else:
            ans = "NO"
    except:
        ans="NO"
print(ans)

Solution (Python):
def main():
  from collections import Counter
  n = int(input())
  D = list(map(int,input().split()))
  m = int(input())
  T = list(map(int,input().split()))
  
  d = dict(Counter(D))
  ans = "YES"
  for t in T:
    try:
      if d[t] - 1 >= 0:
        d[t] -= 1
      else:
        ans = "NO"
    except:
      ans = "NO"

  print(ans)

main()

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
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 LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007


def A():
    ans = 0
    for i in range(101):
        if i%3 and i%5:
            ans += i
    print(ans)
    return


def B():
    a,b,n = LI()
    x = input()
    for i in x:
        if i == "S":
            a = max(0,a-1)
        elif i == "C":
            b = max(0,b-1)
        else:
            if a >= b:
                a = max(0,a-1)
            else:
                b = max(0,b-1)
    print(a)
    print(b)
    return


def C():
    n = I()
    d = LI()
    m = I()
    t = LI()
    dic = defaultdict(lambda : 0)
    for i in d:
        dic[i] += 1
    for i in t:
        if not dic[i]:
            print("NO")
            return
        dic[i] -= 1
    print("YES")
    return


def D():

    return


def E():

    return


def F():

    return


def G():

    return


def H():

    return


def I_():

    return


if __name__ == "__main__":
    C()

Solution (Python):
import collections
n = int(input())
n_list = [ int(v) for v in input().split() ]
m = int(input())
m_list = [ int(v) for v in input().split() ]

n_counter, m_counter = collections.Counter(), collections.Counter()
for i in n_list:
    n_counter[i] += 1
for i in m_list:
    m_counter[i] += 1

n_counter.subtract(m_counter)
if min(list(n_counter.values())) < 0:
    ans = "NO"
else:
    ans = "YES"
print(ans)

Solution (Python):
n=int(input());D=list(map(int,input().split()))
m=int(input());T=list(map(int,input().split()))
dic1={};dic2={}
for d in D:
  dic1.setdefault(d,0)
  dic1[d]+=1
for t in T:
  dic1.setdefault(t,0)
  dic2.setdefault(t,0)
  dic2[t]+=1

x="YES"
for k in dic2:
  if dic2[k]>dic1[k]:
    x="NO";break
print(x)

Solution (Python):
N = int(input())
counter = {}
for i in input().split():
    if i not in counter:
        counter[i] = 1
    else:
        counter[i] += 1

M = int(input())
for i in input().split():
    if i not in counter or counter[i] == 0:
        print('NO')
        exit()
    else:
        counter[i] -= 1
print('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()))
dic = defaultdict(int)
for d in D:
    dic[d] += 1
def find(a, i):
    l = 0
    r = len(a)-1
    mid = (l+r)//2
    while l <= r:
        if i == a[mid]:
            return mid
        elif i < a[mid]:
            r = mid - 1
        else:
            l = mid + 1
        mid = (l+r)//2
    return -1
keys = list(dic.keys())
keys.sort()
for i in range(M):
    j = find(keys, T[i])
    if j == -1 or dic[keys[j]] == 0:
        print("NO")
        exit(0)
    dic[keys[j]] -= 1
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()

i = 0
j = 0
while j < m:
    if d[i] == t[j]:
        i += 1
        j += 1
    elif d[i] < t[j]:
        i += 1
    else:
        print("NO")
        exit()
print("YES")

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())))
ans = True
for key, value in T.items():
    if D[key] < value:
        ans = False
        break

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

Solution (Python):
import sys
input = sys.stdin.readline

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

    t = 0
    for d in range(N):
        if T[t] == D[d]:
            t += 1
            if t >= M:
                break
    if t == M:
        print("YES")
    else:
        print("NO")

if __name__ == "__main__":
    main()

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

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

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


for k, v in dictT.items():
    if k in dictD:
        if v > dictD[k]:
            print("NO")
            exit()
    else:
        print("NO")
        exit()

print("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()))
ans = "YES"
d = defaultdict(lambda : 0)
for i in range(N):
    d[D[i]] += 1
for j in range(M):
    if d[T[j]] == 0:
        ans = "NO"
        break
    d[T[j]] -= 1
print(ans)

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

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

for key in tcnt.keys():
    if tcnt[key] > dcnt[key]:
        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()))


pd = {}
sd = {}

for i in range(n):
    if d[i] in pd:
        pd[d[i]] += 1
    else:
        pd[d[i]] = 1

for i in range(m):
    if t[i] in sd:
        sd[t[i]] += 1
    else:
        sd[t[i]] = 1


flag = True
for s in sd.keys():
    if s in pd:
        if sd[s] <= pd[s]:
            continue
        else:
            flag = False
    else:
        flag = False

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

Solution (Python):
from collections import defaultdict

N=int(input())
d = defaultdict(int)
for D in input().split():
    d[int(D)]+=1
M=int(input())
T=[int(i) for i in input().split()]

for t in T:
    if d[t]>=1:
        d[t]-=1
    else:
        print('NO')
        exit()
print('YES')

Solution (Python):

from collections import Counter


def main():
    n = int(input())
    D = Counter(map(int, input().split()))
    m = int(input())
    T = list(map(int, input().rstrip().split()))
    for i in T:
        if i not in D or D[i] == 0:
            print("NO")
            return
        D[i] -= 1
    print("YES")


if __name__ == "__main__":
    main()

Solution (Python):
def main():
    N = int(input())
    D = list(map(int, input().split()))
    M = int(input())
    T = list(map(int, input().split()))
    D.sort()
    T.sort()
    idx = 0
    for d in D:
        if idx < M and T[idx] == d:
            idx += 1
    if idx == M:
        print("YES")
    else:
        print("NO")


if __name__ == "__main__":
    main()

Solution (Python):
import sys
from collections import Counter
n=int(input())
d=Counter(list(map(int,input().split())))
m=int(input())
t=Counter(list(map(int,input().split())))
k=list(t.keys())
for i in range(len(k)):
    if d[k[i]]<t[k[i]]:
        print('NO')
        sys.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 k, v in T.items():
    if D[k] < v:
        print('NO')
        exit()
print('YES')

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

n = 0
for t in T:
    for i in range(n, N):
        if D[i] == t:
            n = i + 1
            break
        if D[i] > t:
            print('NO')
            exit()
        if i == N - 1:
            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()))

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

for function in range(M):
	point = T[function]
	if not point in functions:
		print("NO")
		break
	if 1 == functions[point]:
		del functions[point]
	else:
		functions[point] -= 1
else:
	print("YES")

Solution (Python):
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.sort()
t.sort()

d.append(0)
d_val = []
d_cnt = []
cnt = 1
for i in range(1, n+1):
    if d[i-1] != d[i]:
        d_cnt.append(cnt)
        d_val.append(d[i-1])
        cnt = 1
    else:
        cnt += 1

t.append(0)
t_val =[]
t_cnt = []
cnt = 1
for i in range(1, m+1):
    if t[i-1] != t[i]:
        t_cnt.append(cnt)
        t_val.append(t[i-1])
        cnt = 1
    else:
        cnt += 1

flag = True
if t_val[0] in d_val:
    n_begin = d_val.index(t_val[0])
else:
    flag = False
if t_val[-1] in d_val:
    n_end = d_val.index(t_val[-1])
else:
    flag = False
if flag:
    for i in range(len(t_val)):
        idx = bisect.bisect_left(d_val,t_val[i], n_begin, n_end+1)
        if d_val[idx] != t_val[i]:
            flag=False
            break
        if d_cnt[idx] < t_cnt[i]:
            flag=False
            break
        else:
            n_begin = idx + 1

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

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

CD = Counter(D)
CT = Counter(T)
for x in CT:
  c = CD.get(x)
  if not c is None and CT[x] <= c:
    pass
  else:
    break
else:
  print("YES")
  sys.exit()
print("NO")

Solution (Python):
from collections import Counter

N = int(input())
*D, = map(int, input().split())
M = int(input())
*T, = map(int, input().split())
cnt_D = Counter(D)
cnt_T = Counter(T)
print('YES' if sum((cnt_T - cnt_D).values()) == 0 else 'NO')

Solution (Python):
import collections
import bisect

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

D.sort()
T2 = collections.Counter(T)

for i in T2.keys():
    if T2[i] > bisect.bisect_right(D, i) - bisect.bisect_left(D, i):
        print("NO")
        exit()

print("YES")

Solution (Python):
n = int(input())
d = {}
for i in input().split():
  if i not in d:
    d[i] = 1
  else:
    d[i] += 1
m = int(input())
if m > n:
  print('NO')
  exit()
for j in input().split():
  if j not in d or d[j] == 0:
    print('NO')
    exit()
  else:
    d[j] -= 1
print('YES')

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)
d_key = list(d.keys())
t_key = list(t.keys())

p = len(d_key)
d_key += t_key
q = set(d_key)

if p != len(q):
    print('NO')
    exit()

for i in t_key:
    if t[i] > d[i]:
        print('NO')
        exit()

print('YES')

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

cnt = defaultdict(int)
for d in D:
  cnt[d] += 1
for t in T:
  cnt[t] -= 1

answer = 'YES' if min(cnt.values()) >= 0 else 'NO'
print(answer)

Solution (Python):
N = int(input())
D = [int(x) for x in input().split()]
M = int(input())
T = [int(x) for x in input().split()]
flag = True
di = {}
for i in D:
    if(i in di):
        di[i]+=1
    else:
        di[i]=1
for i in T:
    if(i not in di):
        flag=False
        break
    elif(di[i]<=0):
        flag=False
        break
    else:
        di[i]-=1

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

Solution (Python):
from collections import Counter
n = int(input())
Ds = Counter(list(map(int,input().split())))
m = int(input())
Ts = Counter(list(map(int,input().split())))
check = True
for key,value in Ts.items():
    if key not in Ds:
        check = False
        break
    elif Ds[key]<value:
        check = False
        break
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()
i=0
j=0
while i<m and j<n:
    if t[i]==d[j]:
        i+=1
        j+=1
    elif t[i]<d[j]:
        print("NO")
        exit()
    else:
        j+=1
print("YES")

Solution (Python):
n = int(input())
d_array = [int(x) for x in input().split()]
d_dict = {}
for d in d_array:
    d_dict.setdefault(d, 0)
    d_dict[d] += 1
m = int(input())
t_array = sorted([int(x) for x in input().split()])

try:
    for t in t_array:
        if d_dict[t] > 0:
            d_dict[t] -= 1
        else:
            print("NO")
            break
    else:
        print("YES")
except KeyError:
    print("NO")
    exit()

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

cD = Counter(D)

for t in T:
    if cD.get(t,0) == 0:
        print('NO')
        exit()
    else:
        cD[t] -= 1

print("YES")

Solution (Python):
from collections import defaultdict
N = int(input())
Ds =  list(map(int,input().split(" ")))
M = int(input())
Ts =  list(map(int,input().split(" ")))

prob = defaultdict(lambda :0)
for d in Ds:
    prob[d] += 1

ans = "YES"
for t in Ts:

    if prob[t] == 0:
        ans = "NO"
    prob[t] -= 1
print(ans)

Solution (Python):
N = int(input())
Ds = list(map(int,input().split()))
M = int(input())
Ts = list(map(int,input().split()))

sDs = [-1]+sorted(Ds)
sTs = sorted(Ts)

ind = 0
for t in sTs:
    flg = False
    for j in range(ind+1,len(sDs)):
        if sDs[j] == t:
            ind = j
            flg = True
            break
    if not flg:
        print("NO")
        break
if flg:
    print("YES")

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 k,v in T.items():
    if (not D[k]) or (D[k]<v):
        print("NO")
        exit()
print("YES")

Solution (Python):
n = int(input())
a = sorted(list(map(int,input().split())))
m = int(input())
b = sorted(list(map(int,input().split())))
i = 0
for t in b:
  f = 0
  while i<n:
    if a[i] == t:
      f = 1
      i += 1
      break
    i += 1
  if f == 0:
    print("NO")
    quit()
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()))
cd=Counter(d)
ct=Counter(t).most_common()
for i,j in ct:
    if cd[i]<j:
        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()
di=0
f=0
for ti in range(m):
    if di<n:
        while d[di]!=t[ti]:
            if d[di]>t[ti]:
                f=1
                break
            di+=1
        di+=1
    if f==1:
        break
if f==1:
    print('NO')
else:
    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()]
p=1
w={}
for i in d:
    if i in w: w[i]+=1
    else: w[i]=1
for i in t:
    if i in w and w[i]>0:
        w[i]-=1
    else:
        p=0
        break
print(["NO","YES"][p])

Solution (Python):

"""
B - Problem Set
https://atcoder.jp/contests/code-festival-2017-qualb/tasks/code_festival_2017_qualb_b

"""
import sys

from collections import Counter

def solve(N, D, M, T):
    have = Counter(D)
    required = Counter(T)
    return 'NO' if required - have else 'YES'


def main(args):
    N = int(input())
    D = [int(d) for d in input().split()]
    M = int(input())
    T = [int(t) for t in input().split()]
    ans = solve(N, D, M, T)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

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

i=0
for j in range(M):
    while(D[i]<T[j] and i<N):
        i+=1
        if i==N:
            break
    if i==N:
        print("NO")
        break
    elif D[i]>T[j]:
        print("NO")
        break
    else:
        i+=1
else:
    print("YES")

Solution (Python):
from collections import Counter

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

D.subtract(T)
print("NO" if -D else "YES")

Solution (Python):
from collections import Counter

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

for t in T:
    if D[t] <= 0:
        print("NO")
        quit()
    if t in D:
        D[t] -= 1
print("YES")

Solution (Python):
def main():
	n = int(input())
	d = list(map(int, input().split()))
	dic = {}
	for i in d:
		if i in dic:
			dic[i] = dic[i]+1
		else:
			dic[i] = 1
	m = int(input())
	t = list(map(int, input().split()))
	for i in t:
		if not(i in dic) or dic[i] == 0:
			print("NO")
			return
		else:
			dic[i] = dic[i] - 1
	print("YES")
	return
main()

Solution (Python):
from collections import Counter as ct
N=int(input())
Q=[int(i) for i in input().split()]
Qdict=ct(Q)
M=int(input())
R=[int(i) for i in input().split()]
Rdict=ct(R)
YES=all([Qdict[d]>=num for d,num in Rdict.items()])
print("NYOE S"[YES::2])

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()]
cD,cT=collections.Counter(D),collections.Counter(T)
flag=1
for x in set(T):
  if cT[x]>cD[x]:
    flag=0
print("YES" if flag==1 else "NO")

Solution (Python):
n = int(input())
d  =list(map(int,input().split()))
d.sort()
m = int(input())
t = list(map(int,input().split()))
t.sort()
i = 0
for x in t:
    while d[i] < x:
        i += 1
    if d[i] == x:
        i += 1
    else:
        print("NO")
        exit()
print("YES")

Solution (Python):
from itertools import accumulate
from math import*
from collections import deque
from collections import defaultdict
from itertools import permutations
from heapq import*
from collections import Counter
from itertools import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = 10**18
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

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

Solution (Python):


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

def array_count(arr):
    arr_target = [[]]
    cnt = 1
    for i in range(1,len(arr)):
        if arr[i] == arr[i-1]:
            cnt += 1
        else:
            arr_target.append([arr[i-1],cnt])
            cnt = 1
    arr_target.append([arr[len(arr)-1],cnt])
    del arr_target[0]
    return arr_target

d.sort()
t.sort()

d = array_count(d)
t = array_count(t)

for i in range(len(t)):
    t[i][1] = -1 * t[i][1]
    d.append(t[i])

d.sort()

for i in range(1,len(d)):
    if d[i-1][0] == d[i][0]:
        d[i-1][1] = d[i-1][1] + d[i][1]
        d[i][1] = 0

flag = True

for i in range(len(d)):
    if d[i][1] < 0:
        flag = False
        break

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

Solution (Python):
N = int(input())
d = list(map(int, input().split()))
d.sort()
M = int(input())
t = list(map(int, input().split()))
t.sort()
idx = 0
for i in range(N):
    if idx != M and d[i] == t[idx]:
        idx += 1
if idx == M:
    print('YES')
else:
    print('NO')

Solution (Python):
n=int(input())
arr1=list(map(int,input().split()))
arr1=sorted(arr1)
m=int(input())
arr2=list(map(int,input().split()))
arr2=sorted(arr2)
pos=0
for i in range(n):
  if arr1[i]==arr2[pos]:
    pos+=1
  if pos==m:
    print('YES')
    break
else:
  print('NO')

Solution (Python):
N = int(input())
Ds = [int(x) for x in input().split()]
M = int(input())
Ts = [int(x) for x in input().split()]\

ND = {}
for D in Ds:
    if not D in ND:
        ND[D] = 0
    ND[D] += 1
NT = {}
for T in Ts:
    if not T in NT:
        NT[T] = 0
    NT[T] += 1

ans = True
for T in NT.keys():
    if not T in ND:
        ans = False
        break
    if NT[T] > ND[T]:
        ans = False
        break

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

Solution (Python):
n=int(input())
d=dict()
for a in map(int,input().split()):
  if a not in d:
    d[a]=1
  else:
    d[a]+=1
m=int(input())
t=dict()
for a in map(int,input().split()):
  if a not in t:
    t[a]=1
  else:
    t[a]+=1
  if a not in d:
    d[a]=0
ans="YES"
for i in t.keys():
  if not t[i]<=d[i]:
    ans="NO"
print(ans)