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())
a=list(map(int,input().split()))
m=int(input())
b=list(map(int,input().split()))
d_a={}
d_b={}
flg=0
for i in range(n):
  d_a[a[i]]=d_a.get(a[i],0)+1
for i in range(m):
  d_b[b[i]]=d_b.get(b[i],0)+1
for i in b:
  c=d_a.get(i,0)
  if c < d_b[i]:
    flg=1
if flg == 1:
  print('NO')
else:
  print('YES')

Submission status: Accepted

Solution code:
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)

N=l()[0]
D=l()
M=l()[0]
T=l()
d={}
t={}
for i in range(N):
    if(D[i] not in d):
        d[D[i]]=0
    d[D[i]]+=1

for i in range(M):
    if(T[i] not in t):
        t[T[i]]=0
    t[T[i]]+=1
ans="YES"
for ks  in  t:
    if(ks not in d or d[ks]<t[ks]):
        ans="NO"
        break
print(ans)

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict

N = int(input())
D = list(map(int, sys.stdin.readline().rsplit()))
M = int(input())
T = list(map(int, sys.stdin.readline().rsplit()))
q = defaultdict(int)

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

for t in T:
    if q[t] > 0:
        q[t] -= 1
    else:
        print("NO")
        exit()

print("YES")

Submission status: Accepted

Solution code:
import collections

def answer(ds, ts):
    dsDic = collections.Counter(ds)
    tsDic = collections.Counter(ts)
    for k, v in tsDic.items():
        if dsDic.get(k) is None: return 'NO'
        if tsDic[k] > dsDic[k]:
            return 'NO'
    return 'YES'

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

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()
flg_no = 0
index_start=0
for i in range(m):
  index=index_start
  flg_fin=0
  while index < n:
    if d[index] == t[i]:
      index_start=index+1
      flg_fin=1
      break
    index+=1
  if flg_fin == 0:
    print('NO')
    flg_no = 1
    break
if flg_no == 0:
  print('YES')

Submission status: Accepted

Solution code:
from collections import defaultdict

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

prepared = defaultdict(int)

for d in ds:
    prepared[d] += 1

for t in ts:
    if prepared[t] > 0:
        prepared[t] -= 1
    else:
        print('NO')
        exit(0)

print('YES')

Submission status: Accepted

Solution code:
from collections import Counter as C
input()
D=C(list(map(int,input().split())))
input()
T=C(list(map(int,input().split())))
for t in T:
  if T[t]>D[t]:
    print('NO')
    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()))
d = Counter(d)
t = Counter(t)
f = 1
for a,b in t.items():
    if d[a] < b:
        f = 0
        break
print("YES" if f else "NO")

Submission status: Accepted

Solution code:
input()
*a, = map(int, input().split())
input()
*b, = map(int, input().split())
c = {}
d = {}
for i in a:
    c[i] = c.get(i, 0)+1
for i in b:
    d[i] = d.get(i, 0)+1
if all(c.get(i, 0) >= d[i] for i in d.keys()):
    print('YES')
else:
    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()))
print("NO" if T-D else "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()))
D.subtract(T)
print("NO" if -D else "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()))
print("YES" if all(D[key]>=value for key,value in T.items()) else "NO")

Submission status: Accepted

Solution code:
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")
        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()))
d,t={},{}
for key in D:
    if key in d:
        d[key]+=1
    else:
        d[key]=1
for key in T:
    if key in t:
        t[key]+=1
    else:
        t[key]=1
flag=True
for key in list(set(T)):
    if key not in d or t[key]>d[key]:
        flag=False
print("YES" if flag 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()

ok = True
idx = 0
for t in T:
  hasSame = False
  while idx <= N-1 and D[idx] <= t:
    d = D[idx]
    idx += 1
    if d == t:
      hasSame = True
      break

  if not hasSame:
    ok = False
    break
      
if ok:
  print('YES')
else:
  print('NO')

Submission status: Accepted

Solution code:
import collections
N = int(input())
D = collections.Counter(map(int,input().split()))
M = int(input())
T = collections.Counter(list(map(int,input().split())))
for key in T.keys():
    if T[key] > D[key]:
        print('NO')
        exit()
print('YES')

Submission status: Accepted

Solution code:
from collections import defaultdict

N = int(input())
Ds = defaultdict(int)
for k in list(map(int, input().split())):
    Ds[k] += 1
M = int(input())
Ts = defaultdict(int)
for k in list(map(int, input().split())):
    Ts[k] += 1
ans = 'YES'
for k in Ts:
    if Ts[k] > Ds[k]:
        ans = 'NO'
        break
print(ans)

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

problemsinHand = defaultdict(int)
problemsNeeded = defaultdict(int)

for d in D:
    problemsinHand[d] += 1
for t in T:
    problemsNeeded[t] += 1

for key, value in list(problemsNeeded.items()):
    if value > problemsinHand[key]:
        print('NO')
        quit()

print('YES')

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    ddic = {}
    tlis = []
    dlis = list(map(int, input().split()))
    m = int(input())
    tlis = list(map(int, input().split()))
    for d in dlis:
        if d in ddic:
            ddic[d] += 1
        else:
            ddic[d] = 0
    for t in tlis:
        if t in ddic and ddic[t] >= 0:
            #print(t,tlis, dlis)
            ddic[t] -= 1
        else:
            #print(t,tlis, dlis)
            print("NO")
            exit()
    print("YES")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))
import collections
cd = collections.Counter(t)
ct = collections.Counter(d)

ans = 1
for i in range(m):
    if ct[t[i]] < cd[t[i]]:
        ans = 0
if ans == 0:
    print("NO")
else:
    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()))

ddict = defaultdict(int)
for i in d:
    ddict[i] += 1

for j in t:
    if ddict[j] >= 1:
        ddict[j]-=1
    else:
        print('NO')
        break
else:
    print('YES')

Submission status: Accepted

Solution code:
from collections import Counter
input()
c1 = Counter(map(int, input().split()))
input()
c2 = Counter(map(int, input().split()))
print("YES" if all(c1[k] >= v for k, v in c2.items()) else "NO")

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    def main():

        n=int(input())
        d=list(map(int,input().split()))
        m=int(input())
        t=list(map(int,input().split()))
        from collections import Counter
        dd=Counter(d)
        tt=Counter(t)
        for key,value in tt.items():
            if dd[key]<value:
                return 'NO'
        return 'YES'
    print(main())
resolve()

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
D = Counter(map(int,input().split()))
m = int(input())
for i in map(int,input().split()):
    try:
        D[i] -= 1
        if D[i] < 0:
            print("NO")
            break
    except:
        print("NO")
        break
else:
    print("YES")

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

while len(T) > 0:
    t = T.pop()
    flag = True
    while flag:
        if len(D) <= 0:
            print("NO")
            exit()
        d = D.pop()
        if d == t:
            flag = False
        elif d < t:
            print("NO")
            exit()
        else:
            continue

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()))
cnt_d, cnt_t = defaultdict(int), defaultdict(int)
for dif in d:
    cnt_d[dif] += 1

for t_dif in t:
    cnt_t[t_dif] += 1

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

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

for i in T:
  if d[i] < t[i]:
    print("NO")
    exit()
    
print("YES")

Submission status: Accepted

Solution code:
from collections import defaultdict
D=defaultdict(int)
E=defaultdict(int)
n=int(input())
l=map(int,input().split())
for i in l:
    D[i]+=1
m=int(input())
e=map(int,input().split())
for j in e:
    E[j]+=1
for i in E.keys():
    if E[i]>D[i]: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())))

flag = True

for t, num in T.items():
    # print(t, num)
    if D[t] < num:
        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 = {}
for i in range(n):
    if d[i] not in D:
        D[d[i]] = 1
    else:
        D[d[i]] += 1
T = {}
for j in range(m):
    if t[j] not in T:
        T[t[j]] = 1
    else:
        T[t[j]] += 1
for k in T:
    try:
        if T[k] <= D[k]:
            continue
        else:
            print('NO')
            break
    except:
        print('NO')
        break
else:
    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()))

memo = defaultdict(int)

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

for t in T:
    memo[t] -= 1

memo = list(memo.values())
memo.sort()

print("YES" if memo[0] >= 0 else "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()))
Ddic = defaultdict(int)
Tdic = defaultdict(int)

for d in D:
    Ddic[d] += 1
for t in T:
    Tdic[t] += 1
for n, v in Tdic.items():
    Ddic[n] -= v
dv = Ddic.values()
if all(i >= 0 for i in dv):
    print("YES")
else:
    print("NO")

Submission status: Accepted

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

Dc = Counter(Dlist)
Tc = Counter(Tlist)
for k, v in Tc.items():
    if Dc[k] < v:
        print("NO")
        break
else:
    print("YES")

Submission status: Accepted

Solution code:
N=int(input())
import collections
D= collections.Counter(list(map(int,input().split())))
M=int(input())
T= collections.Counter(list(map(int,input().split())))
for i,j in T.items():
   if D[i] >= j:
      pass
   else:
      print("NO")
      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()))

d = Counter(D)
flag = True

for t in T:
    if d[t] == 0:
        flag = False
    else:
        d[t] -= 1
print('YES' if flag else 'NO')

Submission status: Accepted

Solution code:
from collections import defaultdict

N = int(input())
D = list(map(int, input().split()))
kind = defaultdict(int)
for d in D:
  kind[d] += 1

M = int(input())
T = list(map(int, input().split()))
for t in T:
  kind[t] -= 1
  if kind[t] < 0:
    print('NO')
    quit()

print('YES')

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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)

for k,v in ct.items():
    if v > cd[k]:
        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()))
if N<M:
  print('NO')
  exit()
  
A={}
B={}
for i in D:
  if i not in A:
    A[i]=0
  A[i]+=1
  
for i in T:
  if i not in B:
    B[i]=0
  B[i]+=1
  
for i in B.keys():
  if not i in A:
    print('NO')
    exit()
  if A[i]<B[i]:
    print('NO')
    exit()
print('YES')

Submission status: Accepted

Solution code:
import collections

def main():
    N = int(input())
    D = [int(_) for _ in input().split()]
    M = int(input())
    T = [int(_) for _ in input().split()]
    Dd = collections.Counter(D)
 
    if N < M:
        print("NO")
        return

    for i in range(M):
        target = T[i]
        if Dd[target] >= 1:
            Dd[target] = Dd[target] - 1
        else:
            print("NO")
            return
    
    print("YES")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))
dic1 = {}
dic2 = {}
for i in d:
    if i in dic1:
        dic1[i] += 1
    else:
        dic1[i] = 1
for i in t:
    if i in dic2:
        dic2[i] += 1
    else:
        dic2[i] = 1
for i in t:
    if i not in dic1:
        print("NO")
        exit()
    elif dic1[i] < dic2[i]:
        print("NO")
        exit()
print("YES")

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
l = Counter(list(map(int,input().split())))
m = int(input())
t = list(map(int,input().split()))
#print(l)
if n<m:
  print("NO")
  exit()
for j in t:
  if ( j in l ) and l[j]>=1:
    l[j] -= 1
 #   print(l)
    continue
  else:
    print("NO")
    exit()
else:
  print("YES")

Submission status: Accepted

Solution code:
n = int(input())
d_list = list(map(int, input().split()))
m = int(input())
t_list = list(map(int, input().split()))

sorted_d = sorted(d_list)
sorted_t = sorted(t_list)

d_index = 0
d_len = len(sorted_d)
for t in sorted_t:
    found = False
    for i in range(d_index, d_len):
        if t < sorted_d[i]:
            print('NO')
            exit()
        if t == sorted_d[i]:
            d_index = i+1
            found = True
            break
    if not found:
        print('NO')
        exit()

print('YES')

Submission status: Accepted

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

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

Submission status: Accepted

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

dc=Counter(d);tc=Counter(t)
for ti in tc:
    if ti not in dc:
        print("NO")
        exit()
    if dc[ti]<tc[ti]:
        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()))

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

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

d1 = {}
for d in D:
    if d not in d1:
        d1[d] = 1
    else:
        d1[d] += 1
d2 = {}
for t in T:
    if t not in d2:
        d2[t] = 1
    else:
        d2[t] += 1

for k2, v2 in d2.items():
    if k2 not in d1:
        print('NO')
        exit()
    else:
        v1 = d1[k2]
        if v1 < v2:
            print('NO')
            exit()
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
D.sort()
d = Counter(D)
T.sort()
t = Counter(T)

answer = 'YES'

for i in range(M):
    if t[T[i]] > d[T[i]]:
        answer = 'NO'
        break
        
print(answer)

Submission status: Accepted

Solution code:
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

n = I()
d = sorted(LI())
m = I()
t = sorted(LI())

j = 0
for i in range(m):
    while t[i] != d[j]:
        j += 1
        if j == n:
            print('NO')
            exit(0)
    j += 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()))
dd=dict()
td=dict()
for i in d:
    if i in dd:
        dd[i]+=1
    else:
        dd[i]=1
for i in t:
    if i in td:
        td[i]+=1
    else:
        td[i]=1
for i,j in td.items():
    if i not in dd:
        print('NO')
        exit()
    elif dd[i]<j:
        print('NO')
        exit()
print('YES')

Submission status: Accepted

Solution code:
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions

import copy

# import heapq
# from collections import deque
# import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    n = ni()
    d = na()
    m = ni()
    t = na()

    d_set = set(d)
    d_cnt = collections.Counter(d)

    for ti in t:
        if ti in d_set and d_cnt[ti] > 0:
            d_cnt[ti] -= 1
        else:
            print("NO")
            exit(0)

    print("YES")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import *
n=int(input())
d=list(map(int,input().split()))
dc=Counter(d)
m=int(input())
t=list(map(int,input().split()))
tc=Counter(t)
s=set(d)|set(t)
for i in s:
  if dc[i]<tc[i]:
    print('NO')
    exit()
print('YES')

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from collections import Counter

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

Submission status: Accepted

Solution code:
from collections import Counter

def main():
    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 k, v in T.items():
        if D[k] < v:
            print('NO')
            return
    print('YES')

main()

Submission status: Accepted

Solution code:
n = int(input())
d = input().split()
m = int(input())
t = input().split()
dic = {}

for a in range(n):
  if d[a] not in dic:
    dic[d[a]] = 1
  else:
    dic[d[a]] += 1

con = 0

for b in range(m):
  if t[b] not in dic or dic[t[b]] == 0:
    print("NO")
    break
  elif t[b] in dic:
    dic[t[b]] -= 1
    con += 1

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

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

from collections import Counter
 
d_count = Counter(D)
t_count = Counter(T)
for k,v in t_count.items():
    if k not in d_count:
        print('NO')
        exit()
    if d_count[k]< v:
        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()))

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

dic = defaultdict(int)

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

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

Submission status: Accepted

Solution code:
from collections import Counter
 
 
def solve():
    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:
            return 'NO'
    return 'YES'
 
 
print(solve())

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

from collections import defaultdict

n = ni()
d = na()
m = ni()
t = na()

dic = defaultdict(int)
for i in range(n):
    dic[d[i]] += 1

flag = True
for i in range(m):
    if dic[t[i]] == 0:
        flag = False
    dic[t[i]] -= 1

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

Submission status: Accepted

Solution code:
from collections import Counter

def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
p = Counter(iil())
m = iil()
t = Counter(iil())

#print(p)
#print(t)

flag = True
for k,v in t.items():
    if p.get(k,0) < v:
        flag = False
print('YES' if flag else 'NO')

Submission status: Accepted

Solution code:
from collections import Counter


def solve():
    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:
            return 'NO'
    return 'YES'


print(solve())

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(int)
for d in D:
    dic[d] += 1

for t in T:
    if dic[t]:
        dic[t] -= 1
    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()))
dic = {}
for d in D:
  if d in dic:
    dic[d] += 1
  else:
    dic[d] = 1

flg = True
for t in T:
  if t in dic:
    if dic[t] == 0:
      flg = False
      break
    else:
      dic[t] -= 1
  else:
    flg = False
    break
if flg:
  print('YES')
else:
  print('NO')

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
d.sort()
t.sort()

idx_d, idx_t = 0, 0
while idx_t < m and idx_d < n:
    if d[idx_d] == t[idx_t]:
        idx_d += 1
        idx_t += 1
    elif d[idx_d] > t[idx_t]:
        print("NO")
        exit()
    else:
        idx_d += 1
if idx_t < m - 1:
    print("NO")
else:
    print("YES")

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int, input().split()))
p = {}
for i in d:
  if i not in p:
    p[i] = 1
  else:
    p[i] += 1
m = int(input())
t = list(map(int, input().split()))
for i in t:
  if i not in p or p[i] == 0:
    print('NO')
    break
  else:
    p[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()))

from collections import Counter

dc = Counter(d)
dt = Counter(t)

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

d.sort()
t.sort()

from collections import deque

d = deque(d)
t = deque(t)

while len(t) > 0 and len(d) > 0:
	if d[0] == t[0]:
		d.popleft()
		t.popleft()
	else:
		d.popleft()

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

Submission status: Accepted

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

M = int(input())

for t in map(int, input().split()):
    if t in D:
        if D[t] > 0:
            D[t] -= 1
        else:
            print("NO")
            exit()
    else:
        print("NO")
        exit()

print("YES")

Submission status: Accepted

Solution code:
import sys
from collections import Counter
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7



def main():
    N = int(readline())
    D = list(map(int, readline().split()))
    M = int(readline())
    T = list(map(int, readline().split()))
    count_D = Counter(D)
    count_T = Counter(T)
    ans = 'YES'
    for key, value in count_T.items():
        if count_D[key]<value:
            ans = 'NO'
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import collections
def main():
    n = int(input())
    d = list(map(int,input().split()))
    m = int(input())
    t = list(map(int,input().split()))

    if n < m:
        print('NO')
        return

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

    for i, k in enumerate(cnt_t.keys()):
        if cnt_d[k] >= cnt_t[k]:
            continue
        else:
            print('NO')
            return
    print('YES')


if __name__ == '__main__':
    main()

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(int)
for d in D:
  dic[d] += 1
for t in T:
  if dic[t] > 0:
    dic[t] -= 1
  else:
    print("NO")
    exit()
print("YES")

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline


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

    D.sort()
    T.sort()

    ans = "YES"
    d = 0
    for t in T:
        found = False
        for i in range(d, N):
            if D[i] == t:
                found = True
                d = i + 1
                break
        if not found:
            ans = "NO"
            break
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import Counter
 
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')
        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()))
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 or di[i]==0:
        print('NO')
        break
    di[i] -= 1
else:
    print('YES')

Submission status: Accepted

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

dic = {}
for i in range(N):
  if L[i] in dic:
    dic[L[i]] += 1
  else:
    dic[L[i]] = 1

ans = 'YES'
for i in range(M):
  if T[i] in dic:
    if dic[T[i]] > 0:
      dic[T[i]] -= 1
    else:
      ans = 'NO'
      break
  else:
    ans = 'NO'
    break

print(ans)

Submission status: Accepted

Solution code:
import collections
import sys
readline = sys.stdin.readline

n = int(input())
d = collections.Counter([int(x) for x in readline().rstrip().split()])
m = int(input())
t = collections.Counter([int(x) for x in readline().rstrip().split()])
for i in t.items():
    if i[1] > d[i[0]]:
        print("NO")
        exit()
print("YES")