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:
from collections import deque
n=int(input())
dl=deque(sorted(list(map(int,input().split()))))
m=int(input())
tl=deque(sorted(list(map(int,input().split()))))
while tl:
    t=tl.popleft()
    while(dl):
        d=dl.popleft()
        if t==d:
            break
    else:
        break
else:
    print('YES')
    exit()
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()))

cntD = Counter(D)
for t in T:
    if cntD[t] <= 0:
        print('NO')
        break
    cntD[t] -= 1
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()))

cD = Counter(D)
cT = Counter(T)

kD = set(cD.keys())

for k, v in cT.items():
  if k not in kD or cD[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()

a = 0
b = 0
cnt = 0
last = t[-1]
for i in range(a, n):
    for j in range(b, m):
        if d[i] == t[j]:
            cnt += 1
            b = j+1
            break
        elif d[i] < t[j]:
            break

if cnt == m:
    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()))
cd = Counter(D)
ct = Counter(T)
flag = True
for k, v in ct.items():
    if v > cd[k]:
        flag = False
print('YES' if flag else 'NO')

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_count = Counter(d)
for k, v in Counter(t).items():
    if k not in d_count.keys():
        print("NO")
        exit()
    elif d_count[k] < v:
        print("NO")
        exit()
print("YES")

Submission status: Accepted

Solution code:
from collections import Counter


def isOk():
    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 not k in cd:
            ans = "NO"
            break
        if v > cd[k]:
            ans = "NO"
            break
    return ans


print(isOk())

Submission status: Accepted

Solution code:
def main():
    from collections import defaultdict

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

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

    for T_ in T:
        d[T_] -= 1
        if d[T_] < 0:
            return 'NO'

    return 'YES'


if __name__ == '__main__':
    print(main())

Submission status: Accepted

Solution code:
import sys
import collections


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n = int(input().rstrip('\n'))
    d = collections.Counter(list(map(int, input().rstrip('\n').split())))
    m = int(input().rstrip('\n'))
    t = collections.Counter(list(map(int, input().rstrip('\n').split())))
    for k, v in t.items():
        if v > d[k]:
            print("NO")
            exit()
    print("YES")


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
from collections import defaultdict as dd
n=int(input())
a=list(map(int,input().split()))
m=int(input())
b=list(map(int,input().split()))
d = dd(int)
d2=dd(int)
for i in range(n):
  d[a[i]]+=1
for i in range(m):
  d2[b[i]]+=1
for k in sorted(d2.keys()):
  if d2[k] > d[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()))


List = {}
for i in D:
    if List.get(i,None)==None:
        List[i]=1
    else:
        List[i]+=1


for i in T:
    if List.get(i,None)==None:
        print("NO")
        exit()
    else:
        if(List[i]==1):
            del List[i]
        else:
            List[i]-=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()))

from collections import Counter
c=Counter(d)
for i in range(m):
    if c[t[i]]==0:
        print("NO")
        exit()
    else:
        c[t[i]]-=1

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()))
d_list.sort()
t_list.sort()
i = 0
j = 0
while True: #mについて
    if j == m:
        print("YES")
        exit()
    elif i == n:
        print("NO")
        exit()
    if t_list[j] == d_list[i]:
        j += 1
        i += 1
    else:
        i += 1

Submission status: Accepted

Solution code:
import sys
import collections


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n = int(input().rstrip('\n'))
    d = collections.Counter(list(map(int, input().rstrip('\n').split())))
    m = int(input().rstrip('\n'))
    t = collections.Counter(list(map(int, input().rstrip('\n').split())))
    for k, v in t.items():
        if k not in d:
            print("NO")
            exit()
        else:
            if v > d[k]:
                print("NO")
                exit()
    print("YES")


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

import  bisect
from collections import  Counter
D.sort()
T.sort()
tmpa=Counter(D)
tmpt=Counter(T)
cnt=0
for i in range(M):
    hnt=T[i]
    v=True
    if tmpt[hnt]<=tmpa[hnt]:
        continue
    else:
        v=False
        print("NO")
        exit()

if v:
    print("YES")

Submission status: Accepted

Solution code:
def solve(n, d, m, t):
    d = sorted(d)
    t = sorted(t)
    i = 0
    for j in range(m):
        while (i < n) and (d[i] < t[j]):
            i += 1
        if (i == n) or (d[i] != t[j]):
            return "NO"
        i += 1
    return "YES"

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

Submission status: Accepted

Solution code:
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
D = list(map(int, sys.stdin.readline().split()))
M = int(sys.stdin.readline())
T = list(map(int, sys.stdin.readline().split()))

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

ok = True
for c in counts.values():
    ok &= c >= 0
if ok:
    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()))
for i in t.keys():
    if d[i]<t[i]:
        print('NO')
        break
else:
    print('YES')

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
d = inpl()
m = inp()
t = inpl()
cntd = Counter(d)
cntt = Counter(t)
for key in cntt:
    if cntt[key] > cntd[key]:
        print('NO')
        break
else:
    print('YES')

Submission status: Accepted

Solution code:
from sys import stdin
from collections import defaultdict
dic_d = defaultdict(int)
dic_t = defaultdict(int)
N = int(stdin.readline().rstrip())
for D in stdin.readline().rstrip().split():
    if D in dic_d:
        dic_d[D] += 1
    else:
        dic_d[D] = 1

M = int(stdin.readline().rstrip())
for T in stdin.readline().rstrip().split():
    if T in dic_t:
        dic_t[T] += 1
    else:
        dic_t[T] = 1
flag = True
for i in dic_t.keys():
    if dic_t[i] > dic_d[i]:
        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()))	
data={}
for i in range(n):
    if d[i] not in data:
        data[d[i]]=1
    else:
        data[d[i]]+=1
key=0
for i in range(m):
    if t[i] not in data:
        key=1
        break
    else:
        if data[t[i]]>0:
            data[t[i]]-=1
        else:
            key=1
            break
if key==0:
    print("YES")
else:
    print("NO")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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()
flag2 = True
pos = 0

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

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

Submission status: Accepted

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


if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
# 2019/09/23

from collections import Counter
n=int(input())
d=Counter(list(map(int,input().split())))
m=int(input())
t=Counter(list(map(int,input().split())))

for k,v in t.items():
    d[k]=d.get(k,0)-v
    if d[k]<0:
        print('NO')
        exit()
print('YES')

Submission status: Accepted

Solution code:
from collections import Counter
N=int(input())
D=list(map(int,input().split()))
d=Counter(D)
M=int(input())
T=list(map(int,input().split()))
t=Counter(T)
ans="YES"
for k in list(t.keys()):
  if d[k]<t[k]:
    ans="NO"
    break
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
m=int(input())
b=list(map(int,input().split()))
a.sort()
b.sort()
j=0
for i in range(n):
	if a[i]==b[j]:
		j+=1
	if j==m:
		break
if j==m:
	print("YES")
else:
	print("NO")

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

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

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

print('YES')

Submission status: Accepted

Solution code:
def main():

    # N = int(input())
    # S = input()
    # N, M = map(int, input().split())

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

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

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

Submission status: Accepted

Solution code:
N = int(input())
Ds = list(map(int, input().split()))
M = int(input())
Ts = list(map(int, input().split()))
nsD = {}
for D in Ds:
  if D not in nsD: nsD[D] = 0
  nsD[D] += 1
nsT = {}
for T in Ts:
  if T not in nsT: nsT[T] = 0
  nsT[T] += 1
ok = True
for T in nsT:
  nT = nsT[T]
  if T not in nsD or nT > nsD[T]:
    ok = False
    break
if ok:
  print("YES")
else:
  print("NO")

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

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");quit()
print("YES")

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:
  while D:
    d = D.pop()
    if t==d : break
  else:
    print("NO")
    break
else:
  print("YES")

Submission status: Accepted

Solution code:
import collections

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

for i in T.keys():
    if not i in D.keys():
        print("NO")
        exit()
    else:
        if T[i] > D[i]:
            print("NO")
            exit()
print("YES")

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 i in T_dict.keys():
    if not i in D_dict.keys():
        print("NO")
        exit()
    else:
        if T_dict[i]>D_dict[i]:
            print("NO")
            exit()
print("YES")

Submission status: Accepted

Solution code:
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))
d_dict = {}
for d in D:
    if d not in d_dict:
        d_dict[d] = 0
    d_dict[d] += 1
 
count = 0
for t in T:
    if t in d_dict and d_dict[t] > 0:
        d_dict[t] -= 1
        count += 1
if count == M:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))
d_dict = {}
for d in D:
    if d not in d_dict:
        d_dict[d] = 0
    d_dict[d] += 1

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

Submission status: Accepted

Solution code:
import collections

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

for item in e:
  if d[item]>b[item]:
    print("NO")
    exit()
    
print("YES")

Submission status: Accepted

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

dicD = {}
dicT = {}

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

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

for t in dicT:
    if (t not in dicD) or (dicT[t] > dicD[t]):
        print("NO")
        break
else:
    print("YES")

Submission status: Accepted

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

dicD = {}
dicT = {}

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

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

for t in dicT:
    if t not in dicD:
        print("NO")
        break
    elif dicT[t] > dicD[t]:
        print("NO")
        break
else:
    print("YES")

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
n = int(input())

ht = {}

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

m = int(input())

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

print("YES")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
c1 = Counter([int(_) for _ in input().split()])
M = int(input())
c2 = Counter([int(_) for _ in input().split()])
for a,b in c2.items():
    if c1[a]<b:
        print('NO')
        exit()
print('YES')

Submission status: Accepted

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

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


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

Submission status: Accepted

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

  print(ans)

main()

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

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

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

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

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#G
def G():

    return

#H
def H():

    return

#I
def I_():

    return

#Solve
if __name__ == "__main__":
    C()

Submission status: Accepted

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

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

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

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 d in D:
  dic1.setdefault(d,0)
  dic1[d]+=1
for t in T:
  dic1.setdefault(t,0)
  dic2.setdefault(t,0)
  dic2[t]+=1

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

Submission status: Accepted

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

M = int(input())
for i in input().split():
    if i not in counter or counter[i] == 0:
        print('NO')
        exit()
    else:
        counter[i] -= 1
print('YES')

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

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

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

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

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


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

print("YES")

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

Submission status: Accepted

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

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

for key in tcnt.keys():
    if tcnt[key] > dcnt[key]:
        print("NO")
        exit()
print("YES")

Submission status: Accepted

Solution code:
import numpy as np

n = int(input())

d = list(map(int,input().split()))

m = int(input())

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


pd = {}
sd = {}

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

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


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

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

Submission status: Accepted

Solution code:
from collections import defaultdict

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

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

Submission status: Accepted

Solution code:
# code-festival-2017-qualbB - Problem Set
from collections import Counter


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


if __name__ == "__main__":
    main()

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
from collections import Counter
n=int(input())
d=Counter(list(map(int,input().split())))
m=int(input())
t=Counter(list(map(int,input().split())))
k=list(t.keys())
for i in range(len(k)):
    if d[k[i]]<t[k[i]]:
        print('NO')
        sys.exit()
print('YES')

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

Submission status: Accepted

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

n = 0
for t in T:
    for i in range(n, N):
        if D[i] == t:
            n = i + 1
            break
        if D[i] > t:
            print('NO')
            exit()
        if i == N - 1:
            print('NO')
            exit()
print('YES')

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import bisect

n = int(input())
d = [int(i) for i in input().split()]
m = int(input())
t = [int(i) for i in input().split()]

d.sort()
t.sort()

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

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import Counter

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