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:
n = int(input())
dl = list(map(int,input().split()))
m = int(input())
tl = list(map(int,input().split()))

from collections import defaultdict
dic1 = defaultdict(int)
dic2 = defaultdict(int)

for d in dl:
    dic1[d] += 1
for t in tl:
    dic2[t] += 1

for t in dic2:
    if dic1[t] < dic2[t]:
        print("NO")
        exit()
print("YES")

Submission status: Accepted

Solution code:
n = int(input())
d = {}
for v in list(map(int, input().split())):
    if v in d:
        d[v] += 1
    else:
        d[v] = 1

m = int(input())
for v in list(map(int, input().split())):
    if v in d and d[v] > 0:
        d[v] -= 1
    else:
        print("NO")
        exit()
print("YES")

Submission status: Accepted

Solution code:
a = int(input())
l = list(map(int,input().split()))
b= int(input())
L = list(map(int,input().split()))
from collections import Counter
c = Counter(l)
C = Counter(L)

for i in C:
    if C[i] > c[i]:
        print('NO')
        exit()
print('YES')

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()))
ca = Counter(a)
cb = Counter(b)
for k,v in cb.items():
  if ca[k]<v:
    print("NO")
    break
else:
  print("YES")

Submission status: Accepted

Solution code:
def examA():
    S = SI()
    F = "FESTIVAL"
    ans = S[:-(len(F))]
    print(ans)
    return

def examB():
    N = I()
    d = defaultdict(int)
    D = LI()
    for t in D:
        d[t] +=1
    M = I()
    T = LI()
    for t in T:
        if d[t]==0:
            print("NO")
            return
        d[t] -=1
    print("YES")
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examB()

"""

"""

Submission status: Accepted

Solution code:
from sys import stdin
from itertools import groupby
n = int(stdin.readline().rstrip())
d = list(map(int,stdin.readline().rstrip().split()))
m = int(stdin.readline().rstrip())
t = list(map(int,stdin.readline().rstrip().split()))
d.sort()
t.sort()
now = 0
for i in d:
    if i == t[now]:
        now += 1
    if now == m:
        print("YES")
        exit()
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()))

count = {}

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

for i in range(m):
    if t[i] not in count.keys():
        print("NO")
        break
    if count[t[i]] == 0:
        print("NO")
        break
    else:
        if t[i] not in count.keys():
            print("NO")
            break
        else:
            count[t[i]] -=1
    if i == m-1:
        print("YES")

Submission status: Accepted

Solution code:
N=int(input())
D=sorted(list(map(int,input().split(' '))))
M=int(input())
T=sorted(list(map(int,input().split(' '))))
D_cnt=0
T_cnt=0
while T_cnt<M and D_cnt<N:
    if D[D_cnt]==T[T_cnt]:
        D_cnt += 1
        T_cnt += 1
    else:
        D_cnt += 1
if T_cnt == M:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
from collections import Counter
import sys

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

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

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

for k, v in T_count.items():
    if D_count[k] < v:
        print('NO')
        sys.exit()

print('YES')

Submission status: Accepted

Solution code:
from collections import Counter
import sys

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

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

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

for k in T_count:
    if D_count[k] < T_count[k]:
        print('NO')
        sys.exit()

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)
ans = 'YES'
for i in ct.keys():
    if cd[i] < ct[i]:
        ans = 'NO'
        break
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
Dcounter = Counter(list(map(int, input().split())))
M = int(input())
Tcounter = Counter(list(map(int, input().split())))
for key in Tcounter.keys():
    if Dcounter.get(key, 0) < Tcounter[key]:
        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()))

from collections import Counter
c = Counter()

for di in D:
    c[di] += 1

for ti in T:
    c[ti] -= 1

# print(c)

r = True
for k, v in c.items():
    if v < 0:
        r = False

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

flag = True
if N < M:
    flag = False
else:
    i = 0
    for ti in T:
        find = False
        while i < N:
            if ti == D[i]:
                find = True
                i += 1
                break
            else:
                i += 1
        if not find:
            flag = False

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

flag = True
if N < M:
    flag = False
else:
    d_ind = 0
    find = False
    for i in range(M):
        for j in range(d_ind, N):
            if T[i] == D[j]:
                find = True
                d_ind = j+1
                break
        if not find:
            flag = False
            break
        find = False

if flag:
    print('YES')
else:
    print('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()))
Tcount = Counter(T)
Dcount = Counter(D)
flag = 'YES'
for n,c in Tcount.items():
    if n not in Dcount or c > Dcount[n]:
        flag = 'NO'
        break
print(flag)

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()))
Tcount = Counter(T)
flag = 'YES'
Dcount = Counter(D)
for n,c in Tcount.items():
    if n not in Dcount:
        flag = 'NO'
        break
    if c > Dcount[n]:
        flag = 'NO'
        break
print(flag)

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
L1 = list(map(int,input().split()))
m = int(input())
L2 = list(map(int,input().split()))
li1 = Counter(L1)
li2 = Counter(L2)

flag = False
for i in range(m):
    if li1[L2[i]] >= li2[L2[i]]:
        flag = True
    else:
        flag = False
        break
if flag:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def S_():
    return input()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

from functools import reduce
ans=0
n=I()
d=Counter(LI())
m=I()
t=Counter(LI())

ans='YES'
for i,j in t.items():
    if d[i]<j:
        ans='NO'
print(ans)

Submission status: Accepted

Solution code:
import sys
import collections as c
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))

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

for test in T.keys():
	if D[test] >= T[test]:
		continue
	else:
		print("NO")
		sys.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)

for k, v in cT.items():
    if k not in cD or cD[k] < v:
        print('NO')
        break
else:
    print('YES')

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    D = [int(i) for i in input().split()]
    from collections import Counter, defaultdict
    D_c = defaultdict(int, Counter(D))
    M = int(input())
    T = [int(i) for i in input().split()]
    for t in T:
        if D_c[t] > 0:
            D_c[t] -= 1
        else:
            return print("NO")
    print("YES")


if __name__ == '__main__':
    main()

Submission status: Accepted

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

c = M
for i in range(N):
    #print("i : ", i)
    if c == 0:
        break
    elif D[i] == T[M - c]:
        #print("c : ", c)
        c -= 1

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

from collections import Counter

a=Counter(D)
b=Counter(T)

for keys in b:
  if keys not in a:
    print("NO")
    break
  else:
    if b[keys]>a[keys]:
      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()))
a={}
if m>n:
  print('NO')
else:
  for i in range(n):
    if d[i] not in a:
      a[d[i]]=1
    else:
      a[d[i]]+=1
  for i in range(m):
    if t[i] in a:
      a[t[i]]-=1
      if a[t[i]]==0:
        del a[t[i]]
    else:
      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
cD = Counter(D)
cT = Counter(T)

ans = 'YES'
for k in cT:
    if (k not in cD.keys()) or (cT[k] > cD[k]):
        ans = 'NO'
        break
print(ans)

Submission status: Accepted

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

if N < M:
    print('NO')
else:
    D.sort()
    T.sort()
    cnt = 0
    i = 0
    for t in T:
        while i < N:
            if D[i] == t:
                cnt += 1
                i += 1
                break
            i += 1
    if cnt == M: print('YES')
    else: print('NO')

Submission status: Accepted

Solution code:
import collections

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

D_count = collections.Counter(D)
T_count = collections.Counter(T)
flag = 0
for key, value in T_count.items():
    if key not in D_set:
        flag = 1
        print("NO")
        break
    else:
        if D_count[key] < value:
            flag = 1
            print("NO")
            break


# flag = 0
# for t in T:
#     try:
#         D.remove(t)
#     except ValueError:
#         flag = 1
#         print("NO")
#         break
if flag == 0:
    print("YES")

Submission status: Accepted

Solution code:
def check(s_di):
  for di in range(s_di,N):
    if D[di] == t:
      return di+1
  return None

N = int(input())
D = sorted(list(map(int,input().split())))
M = int(input())
T = sorted(list(map(int,input().split())))
s_di = 0
for t in T:
  res = check(s_di)
  if res is None:
    print('NO')
    exit()
  else:
    s_di = res
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()
j = 0
for i in range(N):
    if D[i] == T[j]:
        j += 1
    if j == M:
        print('YES')
        exit()
print('NO')

Submission status: Accepted

Solution code:
N=int(input())
a=list(map(int,input().split()))
M=int(input())
t=list(map(int,input().split()))
import collections
ac=collections.Counter(a)
tc=collections.Counter(t)

for task in tc.items():
  if task[0] not in ac or ac[task[0]]<task[1]:
    print("NO")
    break
else:
  print("YES")

Submission status: Accepted

Solution code:
N=int(input())
a=list(map(int,input().split()))
M=int(input())
t=list(map(int,input().split()))
import collections
ac=collections.Counter(a)
tc=collections.Counter(t)

for task in tc.items():
  if task[0] not in ac:
    print("NO")
    exit(0)
  elif ac[task[0]]<task[1]:
    print("NO")
    exit(0)
print("YES")

Submission status: Accepted

Solution code:
input()
D = {}
for a in [int(a) for a in input().split()]:
    if a not in D: D[a] = 0
    D[a] += 1

input()
for a in [int(a) for a in input().split()]:
    if a not in D: D[a] = 0
    D[a] -= 1

for a in D:
    if D[a] < 0:
        print("NO")
        break
else:
    print("YES")

Submission status: Accepted

Solution code:
from collections import defaultdict
def main():
    N = int(input())
    D = defaultdict(int)
    for d in input().split():
        D[int(d)] += 1
    M = int(input())
    T = defaultdict(int)
    for t in input().split():
        T[int(t)] += 1
    
    for diff,num in T.items():
        if D[diff]>=num:
            pass
        else:
            print("NO")
            exit()
    print("YES")

    

if __name__ == "__main__":
    main()

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()))
a = collections.Counter(d)
b = collections.Counter(t)

for i in b.keys():
	if i not in a:
		print ("NO")
		exit()
	if b[i] > a[i]:
		print ("NO")
		exit()
	#print(i,b[i])
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()

cnt=0
 
for i in range(n):
    if d[i]==t[cnt]:
        cnt+=1
    elif d[i]<t[cnt]:
        pass
    else:
        print('NO')
        exit()
    
    if cnt==m:
        print('YES')
        exit()

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

label = 0
count = 0
ans = 1
for i in t:
    check = 0
    for j in range(label,n):
        if i == d[j]:
            label = j + 1
            check = 1
            break
    if check == 0:
        ans = 0
        break
if ans == 0:
    print('NO')
else:
    print('YES')

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:
  if d[i] < t[i]:
    print('NO')
    exit()
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()]

d = sorted(d)
t = sorted(t)

left = 0
ans = 'YES'
for i in range(m):
    if t[i] < d[left]:
        ans='NO'
        break
    elif t[i] == d[left]:
        left+=1
        if i!= m-1 and left >=n:
            ans = 'NO'
            break
    else:
        while t[i] != d[left]:
            left+=1
            if left >= n:
                ans='NO'
                break
        left+=1
        if left>=n:
            ans = 'NO'
            break
print(ans)

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

cnt = Counter(D)
for t in T :
  if cnt[t] == 0 :
    print('NO')
    break
  else :
    cnt[t] -= 1
else :
  print('YES')

Submission status: Accepted

Solution code:
N = int(input())
D = sorted(list(map(int,input().split())))
M = int(input())
T = sorted(list(map(int,input().split())))
cur = 0
flag = 0
for i in range(N):
    if cur<M and D[i]==T[cur]:
        cur += 1
    elif cur<M and D[i]<T[cur]:
        continue
    elif cur==M:
        break
    else:
        flag = 1
        break
if flag==0:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
from collections import defaultdict
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 = defaultdict(int)
for i in range(N):
  d[D[i]] += 1
#print(d)
for i in range(M):
  if not d[T[i]]:
    print("NO")
    exit()
  d[T[i]] -= 1
print("YES")

Submission status: Accepted

Solution code:
from collections import Counter, defaultdict

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

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

for i in range(M):
    ti = T[i]
    if ti not in memo:
        print("NO")
        exit()
    if memo[ti] == 0:
        print("NO")
        exit()
    memo[ti] -= 1

print("YES")

Submission status: Accepted

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

D.sort()
T.sort()
l = 0
for i in range(M):
    while True:
        if D[l] == T[i]:
            l += 1
            break
        elif D[l] > T[i]:
            print("NO")
            sys.exit()
        l += 1
        
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()
j = 0
for i in range(M):
    if j==N:
        print('NO')
        break
    if T[i]>=D[j]:
        while T[i]>D[j]:
            j += 1
        if T[i]==D[j]:
            j += 1
        else:
            print('NO')
            break
    else:
        print('NO')
        break
else:
    print('YES')

Submission status: Accepted

Solution code:
import heapq

def heap(h):
    hlst = list(map(int, input().split()))
    for i in hlst:
        heapq.heappush(h, i)
N = int(input())
d = []
heap(d)
M = int(input())
t = []
heap(t)

ans = 'YES'
for j in range(M):
    tmpT = heapq.heappop(t)
    for i in range(N):
        tmpD = heapq.heappop(d)
        if tmpT == tmpD:
            break
        if tmpT < tmpD:
            ans = 'NO'
            break
    if ans == 'NO':
        break

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int, input().split()))

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

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

for i in range(m):
    if t[i] not in memo:
        print("NO")
        exit()
    if memo[t[i]] == 0:
        print("NO")
        exit()
    memo[t[i]] -= 1
print("YES")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000)
INF = 1<<32

YES = "YES"  # type: str
NO = "NO"  # type: str

def solve(N: int, D: "List[int]", M: int, T: "List[int]"):
    
    D.sort()
    T.sort()

    from bisect import bisect_left, bisect_right

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


    for i in range(M):
        lf = bisect_left(D, T[i])
        ri = bisect_right(D, T[i])
        if lf != ri:
            D[lf] = 0
        else:
            print(NO)
            exit()

    print(YES)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    D = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    M = int(next(tokens))  # type: int
    T = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    solve(N, D, M, T)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

d_li.sort()
t_li.sort()

check = 0

for i in range(n):
    if d_li[i] == t_li[check]:
        check += 1
        
    if check == m:
        print("YES")
        exit()
else:
    print("NO")

Submission status: Accepted

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

d_li.sort()
t_li.sort()

check = 0

for i in range(n):
    if d_li[i] == t_li[check]:
        check += 1
        
    if check == m:
        print("YES")
        exit()
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()

count=0

for i in range(n):
    if d[i]==t[count]:
        count+=1
    elif d[i]<t[count]:
        pass
    else:
        print('NO')
        exit()
    
    if count==m:
        print('YES')
        exit()

Submission status: Accepted

Solution code:
from collections import Counter as c
n=int(input())
d=[int(i) for i in input().split()]
m=int(input())
t=[int(i) for i in input().split()]
D=c(d)
T=c(t)
print("NO" if sum(T[i]>D[i] for i in T) else "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_c=Counter(d)
t_c=Counter(t)
for i in t_c.keys():
    if t_c[i]>d_c[i]:
        print('NO')
        exit()
print('YES')

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
A = Counter(list(map(int, input().split())))
M = int(input())
B = Counter(list(map(int, input().split())))

ok = True
for k, v in B.items():
    if not k in A.keys():
        ok = False
        break
    elif A[k] < v:
        ok = False
        break
print("YES" if ok else "NO")

Submission status: Accepted

Solution code:
from collections import Counter

input()
d = Counter(input().split())
input()
t = Counter(input().split())

if all(ti in d and d[ti] >= tc for ti, tc in t.items()):
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
D = Counter(input().split())
m = int(input())
for i, j in Counter(input().split()).items():
    if i not in D or D[i] < j:
        print("NO")
        exit()
print("YES")

Submission status: Accepted

Solution code:
n = int(input())

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

m = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())

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

m = int(input())

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

for i, j in y.items():
    if x.get(i, 0) < j:
        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()))

x = dict()
for i in d:
    x[i] = x.get(i, 0) + 1

y = dict()
for i in t:
    y[i] = y.get(i, 0) + 1

for i, j in y.items():
    if x.get(i, 0) < j:
        print("NO")
        exit()
print("YES")

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
D = Counter(input().split())
m = int(input())
T = Counter(input().split())
for i in T.keys():
  if i not in D or D[i] < T[i]:
    print("NO")
    exit()
print("YES")

Submission status: Accepted

Solution code:
from collections import Counter

N=int(input())
D=list(map(int,input().split()))
CD=Counter(D)
# print(CD) #DB
M=int(input())
T=list(map(int,input().split()))
CT=Counter(T)
# print(CT) #DB

f=True
for Ti in CT.keys():
    if CD[Ti]<CT[Ti]:
        f=False
        break

print('YES' if f 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()))

d_c=Counter(d)
t_c=Counter(t)
for i in t_c.keys():
    if t_c[i]>d_c[i]:
        print('NO')
        exit()
print('YES')

Submission status: Accepted

Solution code:
from collections import defaultdict

n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
dic = defaultdict(lambda: 0)
ans = "YES"
for i in d:
  dic[i] += 1
for i in t:
  dic[i] -= 1
  if dic[i] == -1:
    ans = "NO"
    break
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter


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

    d = Counter(D)
    t = Counter(T)
    for key, value in t.items():
        if d[key] < value:
            print('NO')
            exit()
    else:
        print('YES')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# B - Problem Set
from collections import defaultdict
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
n = input()
D = list(map(int,input().split()))
m = input()
T = list(map(int,input().split()))

DD = defaultdict(int)

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

for t in T:
    DD[t] -= 1
    if DD[t]<0:
        print('NO')
        exit()

print('YES')

Submission status: Accepted

Solution code:
import sys

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

dic = {}
for i in range(N):

    if D[i] not in dic:
        dic[D[i]] = 1
    else:
        dic[D[i]] += 1

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

for i in T:

    if i not in dic:
        print ("NO")
        sys.exit()

    elif dic[i] == 0:
        print ("NO")
        sys.exit()

    else:
        dic[i] -= 1

print ("YES")

Submission status: Accepted

Solution code:
from sys import exit, stdin
from collections import Counter
N = int(stdin.readline().rstrip())
D = Counter([int(_) for _ in stdin.readline().rstrip().split()])
M = int(stdin.readline().rstrip())
T = Counter([int(_) for _ in stdin.readline().rstrip().split()])
for k, v in T.items():
    if k not in D or D[k] < v:
        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()))

if N < M:
    print("NO")
    exit(0)
tableD = collections.defaultdict(int)
tableT = collections.defaultdict(int)
for i in range(N):
    tableD[D[i]] += 1
for i in range(M):
    tableT[T[i]] += 1

for x in tableT:
    if tableD[x] >= tableT[x]:
        continue
    else:
        print("NO")
        exit(0)
print("YES")

Submission status: Accepted

Solution code:
from collections import Counter


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

    d = Counter(D)
    t = Counter(T)
    for key, value in t.items():
        if d.get(key, 0) < value:
            print('NO')
            exit()
    else:
        print('YES')


if __name__ == '__main__':
    main()

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)
for key, value in t.items():
    if d.get(key, 0) < value:
        print('NO')
        exit()
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()))

grA = dict(collections.Counter(d))
grB = dict(collections.Counter(t))
#print(grA,grB)

for numB,cntB in grB.items():
  #print(numB,grA[numB])
  try:
    if grA[numB] < cntB:
      print("NO")    
      exit()
  except KeyError:
    print("NO")    
    exit()
    
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 i, v in t.items():
    if d[i] < v:
        print("NO")
        exit()
print("YES")