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())
d=list(map(int,input().split()))
d=sorted(d)
m=int(input())
t=list(map(int,input().split()))
t=sorted(t)
flag=True 
if n<m:
    flag=False
else:
    t_num=[] #tの数字の内訳
    bef=t[0]
    ren=1
    for i in range(1,m):
        if bef!=t[i]:
            t_num.append([bef,ren])
            bef=t[i]
            ren=1
        else:
            ren+=1
    t_num.append([bef,ren])
    kind=len(t_num)
    
    
    now=0
    ren=0
    for i in range(n):
        if t_num[now][0]==d[i]:
            ren+=1
        else: 
            if ren!=0: #カウントしてる途中で切り替わる
                if t_num[now][1]<=ren:
                    now+=1
                    ren=0
                    if kind==now: #ok
                        break
                    if t_num[now][0]==d[i]:
                        ren+=1
                else:
                    flag=False
                    break
        #print(ren)
        #print(t_num[now][0])
    if ren!=0: #カウントしてる途中で終わる
        if t_num[now][1]<=ren:
            now+=1
    if now<kind: #ng
        flag=False
print("YES" if flag else "NO")

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())))
if t-d=={}:
    print("YES")
else:
    print("NO")

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

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

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

Submission status: Accepted

Solution code:
from collections import Counter as c
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
flag = True
d_c = c(d)
t_c = c(t)
if n<m: flag = False
else: 
    for i,j in t_c.items():
        if d_c[i] < j:
            flag = False
            break
print('YES' if flag else 'NO')

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()))
need = Counter(T)
aru = Counter(D)
for k in need:
    if aru[k] < need[k]:
        print('NO')
        exit()
print('YES')

Submission status: Accepted

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

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

# print('D, T', D, T)

for key, value in T.items():
    if D.get(key) is None:
        print('NO')
        exit()
    if D.get(key) < value:
        print('NO')
        exit()
print('YES')

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())
a=list(map(int,input().split()))
x=int(input())
b=list(map(int,input().split()))
from collections import Counter
c=Counter(a)
d=Counter(b)

for x,y in d.items():
    if y>c[x]:
        print('NO')
        exit()
print('YES')

Submission status: Accepted

Solution code:
n = int(input())
D = list(map(int,input().split()))
m = int(input())
T = list(map(int,input().split()))
ans = "YES"
dict = {}
keyword = set(D) | set(T)
for d in keyword:
    dict.update({d:0})
for d in D:
    dict[d]+=1
for t in T:
    dict[t]-=1
    if dict[t]<0:
        ans = "NO"
        break
print(ans)

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

def Topo_sort(x,y):
    co = cl.Counter(n for m in x.values() for n in m)
    S = cl.deque([i for i in range(y) if co[i] == 0])
    while S:
        n = S.popleft()
        yield n
        for i in x[n]:
            co[i] -= 1
            if co[i] <= 0:
                S.append(i)
    
    """
    if sum(co.values()) != 0:
        print(1)
        exit()
    else:
        print(0)
        exit()
    """
    #閉路検出(1が存在,0が存在しない)
# g = cl.dafaultdict(set)に有向グラフを作成し(g[~] != ~ ,yはノード数) リストが帰ってくる
n = onem()

d = l()


po = cl.defaultdict(int)

for i in range(n):
    po[str(d[i])] += 1

M = onem()

t = l()

for i in range(M):
    if po[str(t[i])]:
        po[str(t[i])] -= 1
    else:
        print("NO")
        break
else:
    print("YES")

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
def main():
    # D, Tは文字数カウントするだけだからint型にする必要なし.
    n = int(input())
    D = input().split()
    m = int(input())
    T = input().split()
    dic = dict()
    
    # 辞書はDだけで十分.Counterより速い.
    for d in D:
        # dic.get(d)と比べると, if in の方が速い.
        if d in dic:
            dic[d] += 1
        else:
            dic[d] = 1
            
    for t in T:
        if t not in dic or dic[t] == 0:
            print('NO')
            return
        else:
            dic[t] -= 1
    print('YES')
main()

Submission status: Accepted

Solution code:
def main():
    # D, Tは文字数カウントするだけだからint型にする必要なし.
    n = int(input())
    D = input().split()
    m = int(input())
    T = input().split()
    dic = dict()
    
    # 辞書はDだけで十分.Counterより速い.
    for d in D:
        # dic.get(d)と比べると, if in の方が速い.
        if d in dic:
            dic[d] += 1
        else:
            dic[d] = 1
            
    for t in T:
        if t not in dic or dic[t] == 0:
            print('NO')
            return
        else:
            dic[t] -= 1
    print('YES')
main()

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    D = map(int, input().split())
    m = int(input())
    T = map(int, input().split())
    dic = dict()
    
    # 辞書はDだけで十分.Counterより速い.
    for d in D:
        if d in dic:
            dic[d] += 1
        else:
            dic[d] = 1
            
    for t in T:
        if t not in dic or dic[t] == 0:
            print('NO')
            return
        else:
            dic[t] -= 1
    print('YES')
main()

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    D = map(int, input().split())
    m = int(input())
    T = map(int, input().split())
    dic = dict()
    
    # 辞書はDだけで十分.Counterより速い.
    for d in D:
        if dic.get(d):
            dic[d] += 1
        else:
            dic[d] = 1
            
    for t in T:
        if t not in dic or dic[t] == 0:
            print('NO')
            return
        else:
            dic[t] -= 1
    print('YES')
main()

Submission status: Accepted

Solution code:
from collections import Counter
def main():
    n = int(input())
    D = map(int, input().split())
    m = int(input())
    T = map(int, input().split())
    C = Counter(D)
    for t in T:
        if t not in C or C[t] == 0:
            print('NO')
            return
        else:
            C[t] -= 1
    print('YES')
main()

Submission status: Accepted

Solution code:
from collections import Counter
def main():
    n = int(input())
    D = sorted(map(int, input().split()))
    m = int(input())
    T = sorted(map(int, input().split()))
    CD = Counter(D)
    CT = Counter(T).items()
    for i, c in CT:
        if CD[i] < c:
            print('NO')
            return
    print('YES')
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()))

cd = Counter(D)
ct = Counter(T)

ans = True
for i in ct.keys():
    if cd[i] < ct[i]:
        ans = False
        break
print('YES' if ans else 'NO')

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    d = LI()
    m = II()
    t = LI()
    d.sort()
    t.sort()
    i = 0
    for j in range(m):
        while i < n and d[i] < t[j]:
            i += 1
        if i >= n:
            print("NO")
            return
        if d[i] == t[j]:
            i += 1
        elif d[i] > t[j]:
            print("NO")
            return
    print("YES")
    return


#main
if __name__ == '__main__':
    solve()

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 k, v in t.items():
    if k not in d  or d[k]<v:
        print('NO')
        exit()

print('YES')

Submission status: Accepted

Solution code:
# B
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))
D.sort()
T.sort()
cnt = 0
ans = "YES"
for i in range(M):
    now = T[i]
    for j in range(cnt, N):
        if now > D[j]:
            pass
        elif now == D[j]:
            cnt = j+1
            break
        else:
            ans = "NO"
            break
print(ans)

Submission status: Accepted

Solution code:
import sys
from collections import Counter
input = sys.stdin.readline

n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
dif = sorted(list(Counter(d).items()))
check = sorted(list(Counter(t).items()))
cnt = 0
len_check = len(check)
for i, j in dif:
    if i == check[cnt][0]:
        if j >= check[cnt][1]:
            cnt += 1
        else:
            print('NO')
            exit()
    if cnt == len_check:
        print('YES')
        exit()
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 = sorted(D)
T = sorted(T)

import collections

A = collections.Counter(D)
B = collections.Counter(T)

ok = 0
for i in B:
    if A[i] >= B[i]:
        continue
    else:
        ok = 1
        break
if ok == 1:
    print("NO")
else:
    print("YES")

Submission status: Accepted

Solution code:
N=int(input())
T=[int(i) for i in input().split()]
M=int(input())
D=[int(i) for i in input().split()]
if M>N:
  print('NO')
else:
  cnt={}
  for t in T:
    cnt[t]=[0,0]
  for d in D:
    cnt[d]=[0,0]
  for t in T:
    cnt[t][0]+=1
  for d in D:
    cnt[d][1]+=1
  ans='YES'
  for key in cnt:
    n,m=cnt[key]
    if n<m:
      ans='NO'
  print(ans)

Submission status: Accepted

Solution code:
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N = iin()
D = collections.Counter(iln())
M = iin()
T = collections.Counter(iln())

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

cd = Counter(d)
ct = Counter(t)

ans = "YES"
for k, v in ct.items():
    if cd[k] < v:
        ans = "NO"

print(ans)

Submission status: Accepted

Solution code:
def main():
    questions = int(input())
    difficulty = sorted(list(map(int, input().split())))
    problems = int(input())
    problem_set = sorted(list(map(int, input().split())))
    d_index = 0
    count = 0
    for i in range(problems):
        while d_index < questions and difficulty[d_index] < problem_set[i]:
            d_index += 1
        if difficulty[d_index] == problem_set[i]:
            count += 1
            d_index += 1
        else:
            break
    print("YES" if count == problems else "NO")


if __name__ == '__main__':
    main()

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

import collections
d_frq_dict = collections.Counter(D)

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    d = list(map(int, input().split()))
    m = int(input())
    t = list(map(int, input().split()))
    d.sort()
    t.sort()
    x = -1
    y = -1
    while x < n and y < m-1:
        x += 1
        y += 1
        while x < n and d[x] != t[y]:
            x += 1
    if x < n:
        print("YES")
    else:
        print("NO")

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

from collections import Counter
cd = Counter(d)
ct = Counter(t)

for tt in ct.items():
    if tt[1] > cd[tt[0]]:
        print("NO")
        break
else:
    print("YES")

Submission status: Accepted

Solution code:
def main():
  n = int(input())
  m = list(input_list())
  d = int(input())
  t = list(input_list())
  if n < d:
    print('NO')
    exit()
  mc = collections.Counter(m)
  tc = collections.Counter(t)
  for key, count in tc.items():
    if mc[key] < count:
      print('NO')
      exit()
  print('YES')
  
def input_list():
  return map(int, input().split())

def input_list_str():
  return map(str, input().split())

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

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

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

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

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c 

import math
import fractions
import collections
from functools import reduce
main()

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()
index = 0
for i in range(m):
    if index >= n:
        print("NO")
        exit()
    while index < n and t[i] != d[index]:
        index += 1
    if index >= n:
        print("NO")
        exit()
    if t[i] != d[index]:
        print("NO")
    else:
        index += 1
print("YES")

Submission status: Accepted

Solution code:
import sys
from collections import Counter
n = int(input())
ds = [int(i) for i in sys.stdin.readline().split()]
ds = Counter(ds)
m = int(input())
ts = [int(i) for i in sys.stdin.readline().split()]
ts = Counter(ts)
flg = True
for t, value in ts.items():
    if ds.get(t) is None or ds.get(t) < value:
        flg = False
        break
if flg:
    print("YES")
else:
    print("NO")

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()]
d = collections.Counter(d_)
t = collections.Counter(t_)
for ti in t_:
    if d[ti] == 0:
        print("NO")
        exit()
    else:
        d[ti] -= 1
print("YES")

Submission status: Accepted

Solution code:
def main():
    *A, = map(int, open(0).read().split())
    N = A[0]
    D = A[1:N + 1]
    M = A[N + 1]
    T = A[N + 2:]
    # print(N, D, M, T)
    D.sort()
    T.sort()
    di = 0
    for t in T:
        if di >= N:
            print('NO')
            return
        d = D[di]
        while d < t and di < N:
            di += 1
            d = D[di]
        if d != t:
            print('NO')
            return
        di += 1
    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()))
l1=[]
l2=[]
c1=Counter(D)
c2=Counter(T)
flag=1
val1=list(c1.values())
key1=list(c1.keys())
val2=list(c2.values())
key2=list(c2.keys())

for i in range(len(val1)):
    l1.append([key1[i],val1[i]])
for i in range(len(val2)):
    l2.append([key2[i],val2[i]])

for i in range(len(val2)):
    if c1[l2[i][0]]<l2[i][1]:
        flag=0
if flag==0:
    print("NO")
else:
    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()))

x = Counter(d)
y = Counter(t)

res = True
for p,q in y.items():
    if p not in x.keys():
        res = False
        break
    elif x[p] < q:
        res = False
        break
print('YES' if res 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()))
from collections import Counter as co
h=co(d)
p=co(t)
x='YES'
for i in p:
  if p[i]>h.get(i,0):
    x='NO'
    break
print(x)

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()))
 
counter1 = Counter(d)
counter2 = Counter(t)
 
for k, v in counter2.items():
    if counter1[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()))
from collections import Counter
D=Counter(D)
dic_D={}
for i in D.most_common():
  dic_D[i[0]]=i[1]
T=Counter(T)
ret = 'YES'
for i in T.most_common():
  if i[0] in dic_D:
    if dic_D[i[0]]<i[1]:
      ret = 'NO'
      break
  else:
    ret = 'NO'
    break
print(ret)

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 Counter
D=Counter(D)
dic_D={}
for i in D.most_common():
  dic_D[i[0]]=i[1]
T=Counter(T)
ret = 'YES'
for i in T.most_common():
  if i[0] in dic_D:
    if dic_D[i[0]]<i[1]:
      ret = 'NO'
      break
  else:
    ret = 'NO'
    break
print(ret)

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

counter1 = Counter(d)
counter2 = Counter(t)

for k, v in counter2.items():
    if counter1[k] < v:
        print('NO')
        exit()
print('YES')

Submission status: Accepted

Solution code:
n=int(input())
d=list(map(int,input().split()))
m=int(input())
a=list(map(int,input().split()))
ans="NO"
if n>=m:
    d.sort()
    a.sort()
    cnt_n=0
    cnt_m=0
    while cnt_m<m:
        if d[cnt_n]==a[cnt_m]:
            cnt_n+=1
            cnt_m+=1
        else:
            cnt_n+=1
        if n-cnt_n<m-cnt_m:
            break
    if cnt_m==m:
        ans="YES"
print(ans)

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 v <= c1[k]:
        continue
    else:
        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()

flag = 0
ans = ["NO", "YES"]

lp = 0

for i in range(len(t)):  # 要求
    for j in range(lp, len(d)):  # 供給
        if (d[j] > t[i]):
            break
        elif (d[j] == t[i]):
            lp = j+1
            flag += 1
            break

print(ans[flag == len(t)])

Submission status: Accepted

Solution code:
n = int(input())
datn = list(map(int, input().split()))
m = int(input())
datm = list(map(int, input().split()))
import collections
d = collections.defaultdict(int)
for i in range(n):
    d[datn[i]] += 1
f = True
for j in range(m):
    c = d[datm[j]]
    if c == 0:
        f = False
    d[datm[j]] -= 1
print("YES" if f  else "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("YNEOS"[not all(k in D and D[k]>=v for k,v in T.items())::2])

Submission status: Accepted

Solution code:
from collections import Counter

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

for i in range(M):
    if 0 < D[T[i]]:
        D[T[i]] -= 1
    else:
        print("NO")
        break
else:
    print("YES")

Submission status: Accepted

Solution code:
import collections
n=int(input())
dp=collections.Counter(int(x) for x in input().split())
m=int(input())
tp=collections.Counter(int(x) for x in input().split())
ans="YES"
for k,v in tp.items():
    if dp[k]<v:
        ans="NO"
        break
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
dD = input().split()
m = int(input())
dT = input().split()
d = dict()

for di in dD:
    if di in d:
        d[di] += 1
    else:
        d[di] = 1

ans = 'YES'
for ti in dT:
    if ti not in d or d[ti]==0:
        ans = 'NO'
        break
    else:
        d[ti] -= 1
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()))

d.sort()
t.sort()
d_cnt=0
for i in range(len(t)):
        found=False
        for j in range(d_cnt,len(d)):
                if t[i]==d[j]:
                        d_cnt=j+1
                        found=True
                        break
        if not found:
                print("NO")
                exit()
print("YES")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

import collections
n = int(input())
d = collections.Counter([int(x) for x in input().split()])
m = int(input())
t = collections.Counter([int(x) for x in input().split()])
for k, v in t.items():
    if d[k] < v:
        print("NO")
        exit()
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()
now = 0
for x in t:
    if now == n:
        print("NO")
        exit()
    while d[now] != x:
        now += 1
        if now == n:
            print("NO")
            exit()
    now += 1

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

c_d = dict(collections.Counter(D))
c_t = dict(collections.Counter(T))
ans = 'YES'

for k,v in c_t.items():
  if (k in c_d and c_t[k] <= c_d[k]):
    continue
  else:
    ans = 'NO'
    break
print(ans)

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()))
Flg = "YES"

c1 = Counter(D)
c2 = Counter(T)

for i, val in c2.items():
    if(c1[i] < val):
        Flg = "NO"
        break
print(Flg)

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

c1 = Counter(d)
c2 = Counter(t)

flg = True

for k,v in c2.items():
    if c1[k] < v:
        flg = False
        break
    
print('YES' if flg 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()))

dic = {}
for d in D:
    if d in dic.keys():
        dic[d] += 1
    else:
        dic[d] = 1

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

print('YES')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    _ = input()
    D = sorted([int(x) for x in input().split()])
    _ = input()
    T = sorted([int(x) for x in input().split()])

    current = 0
    for elem in T:
        while D[current] < elem:
            current += 1

        if D[current] > elem:
            print("NO")
            return

        current += 1

    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()))
dmap = {}
for i in range(n):
    dmap[d[i]] = dmap.get(d[i], 0) + 1
# print(dmap)
tmap = {}
for i in range(m):
    tmap[t[i]] = tmap.get(t[i], 0) + 1
# print(tmap)
for i in range(m):
    if dmap.get(t[i], -1) == -1 or dmap.get(t[i], -1) < tmap[t[i]]:
        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()))
dd,tt=collections.Counter(d),collections.Counter(t)
for k,v in tt.items():
  if dd.get(k)==None:
    print("NO")
    exit()
  elif dd.get(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())))
now = 0
for i in range(len(b)) :
	while now < n and a[now] < b[i] :
		now += 1
	if a[now] != b[i] :
		print("NO")
		exit()
	now += 1
	if now == n and i != m - 1 :
		print("NO")
		exit()
print("YES")