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 1600s.

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



Sample input:
5
3 1 4 1 5
3
5 4 3


Sample output:
YES

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
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:])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
from collections import*
n=int(input())
d=Counter(map(int,input().split()))
m=int(input())
t=Counter(map(int,input().split()))
#print(d,t)
for k,v in t.items():
    if d[k]<v:
        print("NO")
        exit()
print("YES")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)
#print(D)
#print(T)
for key in T:
    if D[key] < T[key]:
        print('NO')
        exit()

print('YES')

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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)
# print(d.most_common())
# print(t.most_common())
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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict

dict = defaultdict(int) #lamda:0

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

Submission status: Accepted

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

Submission status: Accepted

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