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:
# -*- coding: utf-8 -*-

# CODE FESTIVAL 2017 A
# Problem B

if __name__ == '__main__':
    from collections import Counter

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

    for t_key, t_value in ts.items():
        if (ds[t_key] - t_value) < 0:
            print('NO')
            exit()

    print('YES')

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

count_D = collections.Counter(D)
count_T = collections.Counter(T)

ans = 'YES'
for k,v in count_T.items():
  if count_D[k] < v:
    ans = 'NO'
    break
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
from bisect 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,tc,flag = sorted(d),Counter(t),True
for i in tc.most_common():
	if bisect(d,i[0])-bisect(d,i[0]-1)<i[1]:
		flag = False
		break
if flag: print("YES")
else: print("NO")

Submission status: Accepted

Solution code:
N = int(input())
Ds = list(map(int,input().split()))
dif = {}
for D in Ds:
  if D in dif:
    dif[D] += 1
  else:
    dif[D] = 1
M = int(input())
Ts = list(map(int,input().split()))
for T in Ts:
  if T not in dif:
    print('NO')
    exit()
  else:
    if 0 < dif[T]:
      dif[T] -= 1
    else:
      print('NO')
      exit()
print('YES')

Submission status: Accepted

Solution code:
N=int(input())
D=[int(i) for i in input().split()]
M=int(input())
T=[int(i) for i in input().split()]
D.sort()
T.sort()
d=dict()
t=dict()
for i in range(N):
    if not D[i] in d:
        d[D[i]]=1
    d[D[i]]+=1
for i in range(M):
    if not T[i] in t:
        t[T[i]]=1
    t[T[i]]+=1
S=set(T)
for i in S:
    if not i in d:
        print("NO")
        exit()
    if d[i]<t[i]:
        print("NO")
        exit()
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 k,v in T.items():
    if D[k]<v:
        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()))

dd = {}
tt ={}
for i in t:
    if i in tt:
        tt[i] += 1
    else:
        tt[i] = 1
        dd[i] = 0
for i in d:
    if i in dd:
        dd[i] += 1
    else:
        dd[i] =1


ans = 'YES'
for i in tt:
    if tt[i] > dd[i]:
        ans = 'NO'
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict

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

    L = set(D+T)
    D_count = defaultdict(int)
    T_count = defaultdict(int)

    for d in D: D_count[d] += 1
    for t in T: T_count[t] += 1

    for t in T_count:
        if t not in D_count: D_count[t] = 0
        if D_count[t] < T_count[t]:
            print("NO")
            return
    
    print("YES")
    return

a()

Submission status: Accepted

Solution code:
n = int(input())
d = input().split()
b1 = dict()
for i in d:
    b1[i] = b1.get(i, 0) + 1##b1[難易度]=手持ちの問題案で, 該当する難易度の問題数

m = int(input())
t = input().split()
b2 = dict()
for i in t:
    b2[i] = b2.get(i, 0) + 1##b2[難易度]=予選に使う問題セットで, 該当する難易度の問題数

for tKey in b2.keys():
    if not(tKey in b1) or (b2[tKey] > b1[tKey]):
        print('NO')
        exit()       
print('YES')

Submission status: Accepted

Solution code:
import sys
from collections import Counter


n=int(input())
Dc=Counter(input().split())
m=int(input())
Tc=Counter(input().split())
for key,val in Tc.items():
    if(val>Dc[key]):
        print("NO")
        sys.exit()
print("YES")

Submission status: Accepted

Solution code:
from collections import Counter


def main():
    """
    1 ≤ N  ≤ 2 * 10^5
    1 ≤ Di ≤ 10^9
    1 ≤ M  ≤ 2 * 10^5
    1 ≤ Ti ≤ 10^9

    N*M: TLE
    """
    N = int(input())
    D = map(int, input().split())
    M = int(input())
    T = map(int, input().split())

    f(N, D, M, T)


def f(N, D, M, T):
    c = Counter(D)
    for t in T:
        if c[t] == 0:
            print("NO")
            return

        c[t] -= 1

    print("YES")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import collections
n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))
dcounter = collections.Counter(d)
tcounter = collections.Counter(t)
check = True
for i in tcounter.items():
	if dcounter[i[0]] < i[1]:
		check = False
if check:
	print('YES')
else:
	print('NO')

Submission status: Accepted

Solution code:
import collections
n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))
dcounter = collections.Counter(d)
tcounter = collections.Counter(t)
check = True
for i in tcounter.items():
	if dcounter[i[0]] < i[1]:
		check = False
if check:
	print('YES')
else:
	print('NO')

Submission status: Accepted

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

D.sort();T.sort()
di = 0
ti = 0
while True:
     d = D[di];t=T[ti]
     if d==t:
         di+=1;ti+=1
     elif d>t:
         print("NO")
         exit()
     elif t>d:
         di+=1
     if ti >= len(T):
         print("YES")
         exit()
     if di >= len(D):
         print(di)
         print("NO")
         exit()

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 t in dic and dic[t] >= 1:
        dic[t] -= 1
    else:
        print("NO")
        exit()
print("YES")

Submission status: Accepted

Solution code:
def solve():
    N = int(input())
    D = list(map(int, input().split()))
    M = int(input())
    T = list(map(int, input().split()))
    prepared_map = {}
    necessary_map = {}
    for i in D:
        if not i in prepared_map.keys():
            prepared_map[i] = 1
        else:
            prepared_map[i] = prepared_map[i] + 1
        if not i in necessary_map.keys():
            necessary_map[i] = 0
    for i in T:
        if not i in necessary_map.keys():
            necessary_map[i] = 1
        else:
            necessary_map[i] = necessary_map[i] + 1
        if not i in prepared_map.keys():
            prepared_map[i] = 0
    if all(prepared_map[k] >= necessary_map[k] for k in necessary_map.keys()):
        print("YES")
    else:
        print("NO")

solve()

Submission status: Accepted

Solution code:
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")


def main():
    N = int(input())
    D_list = list(map(int, input().split()))
    M = int(input())
    T_list = list(map(int, input().split()))

    c = Counter(D_list)
    for t in T_list:
        if c[t] <= 0:
            print("NO")
            return
        c[t] -= 1
    print("YES")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter

N = int(input())
D = [int(i) for i in input().split()]
M = int(input())
T = [int(i) for i in input().split()]

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

for k, v in t.items():
    if d[k] < v:
        print('NO')
        break
else:
    print('YES')

Submission status: Accepted

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

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

dc = collections.Counter(d)
tc = collections.Counter(t)
s = [0 for i in range(len(tc))]
for i,index in enumerate(tc):
    s[i] = dc[index]-tc[index]
    

print('YES' if all(list(map(lambda x : x >= 0 , s))) else 'NO')

Submission status: Accepted

Solution code:
import sys
N=input()
a={}
for i in raw_input().split():
	#print i
	if i in a:
		a[i]=a[i]+1
	else:
		a[i]=1
#print a


M=input()
for j in raw_input().split():
	#print j
	if j in a:
		a[j]=a[j]-1
		if a[j]<0:
			print "NO"
			sys.exit()
	else:
			print "NO"
			sys.exit()		

print "YES"

Submission status: Accepted

Solution code:
import sys
N=int(input())
D=list(map(int,input().split()))
M=int(input())
T=list(map(int,input().split()))
D.sort()
T.sort()
for i in range(M-1,-1,-1):
  while D:
    q=D.pop()
    if T[i]==q:
      #print(i)
      break
    elif T[i]>q:
      print("NO")
      sys.exit()
  else:
    print("NO")
    sys.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()))
d.subtract(t)
print("NO" if -d else "YES")

Submission status: Accepted

Solution code:
from collections import Counter
n = input()
d = Counter(map(int, input().split()))
m = input()
t = Counter(map(int, input().split()))
d.subtract(t)
print("NO" if -d else "YES")

Submission status: Accepted

Solution code:
N = int(input())
D = sorted(map(int, input().split()))
M = int(input())
T = sorted(map(int, input().split()))
i = 0
for t in T:
    while D[i] < t:
        i += 1
    if D[i] == t:
        i += 1
    else:
        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()))
res = True
dic = {}
for i in range(N):
  if D[i] in dic:
    dic[D[i]] += 1
  else:
    dic[D[i]] = 1
for j in range(M):
  if (dic.get(T[j], 0) == 0):
    res = False
    break
  else:
    dic[T[j]] -= 1
if(res):
  print("YES")
else:
  print("NO")

Submission status: Accepted

Solution code:
from collections import defaultdict


def main():
    dic = defaultdict(lambda: 0)
    _ = input()
    d_list = [int(i) for i in input().split()]
    for d in d_list:
        dic[d] += 1

    flag = True
    _ = input()
    m_list = [int(i) for i in input().split()]
    for m in m_list:
        dic[m] -= 1
        if dic[m] < 0:
            flag = False
            break
    if flag: print("YES")
    else: print("NO")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import collections

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

DS=collections.Counter(D)
TS=collections.Counter(T)

for i,k in TS.items():

    if k > DS[i]:
        print('NO')
        exit()

print('YES')

Submission status: Accepted

Solution code:
n = int(input())
d = sorted(list(map(int,input().split())))
m = int(input())
t = sorted(list(map(int,input().split())))
didx = 0
tidx = 0
while tidx < m and didx < n:
    if d[didx] == t[tidx]:
        didx += 1; tidx += 1
    elif d[didx] < t[tidx]:
        didx += 1
    else:
        print("NO")
        break
else:
    if tidx == m:
        print("YES")
    else:
        print("NO")

Submission status: Accepted

Solution code:
from collections import defaultdict

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

di = defaultdict(lambda: 0)

for i in d:
    di[i] += 1
      
ans = "YES" 
      
for i in t:
    if (i not in di) or (di[i] == 0):
        ans = "NO"
        break
    else:
        di[i] -= 1
         
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
d = input().split()
m = int(input())
t = input().split()
 
dic = dict()
 
for di in d:
    if di in dic:
        dic[di] += 1
    else:
        dic[di] = 1
 
ans = "YES"
for ti in t:
    if ti not in dic or dic[ti] == 0:
        ans = "NO"
        break
    else:
        dic[ti] -= 1
 
print(ans)

Submission status: Accepted

Solution code:

q=input()
x=[int(i) for i in input().split()]
cnt=input()
y=[int(i) for i in input().split()]

if max(x) >= max(y):
    MAX=max(x)
else:
    MAX=max(y)

dic = {}

for k in x :
    if k in dic.keys() :
        dic[k] += 1
    else :
        dic[k] = 1
    
for i in y :
    if i in dic.keys() :
        dic[i] -= 1
        if dic[i] == -1 :
            print('NO')
            exit()
    else :
        print('NO')
        exit()
print('YES')

Submission status: Accepted

Solution code:
n=int(input())

l  = input()
l =[int(i) for i in l.split()]
v ={}
for i in l :
    if  i in v:
        v[i]+=1
    else:v[i] = 1
m = int(input())
l = input()
l = [int(i) for i in l.split()]
t = 1
for i in l :
    if not(i in v) :
        t= 0
        break
    else:
        v[i]-=1
        if v[i]<0:
            t=0
            break
if t==1:
    print("YES")
if t==0:
    print("NO")

Submission status: Accepted

Solution code:

def main():
    N = int(input())
    D = [int(n) for n in input().split()]
    M = int(input())
    T = [int(n) for n in input().split()]
    d_dict = {}
    t_dict = {}
    for i in D:
        d_dict[i] = d_dict.get(i, 0) + 1
    for i in T:
        t_dict[i] = t_dict.get(i, 0) + 1

    ok = True
    for k in t_dict.keys():
        if d_dict.get(k, 0) < t_dict[k]:
            ok = False
            break

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

def main():
    N = int(input())
    D = [int(n) for n in input().split()]
    M = int(input())
    T = [int(n) for n in input().split()]
    # print(N)
    # print(D)
    # print(M)
    # print(T)
    d_dict = {}
    t_dict = {}
    for i in D:
        d_dict[i] = d_dict.get(i, 0) + 1
    for i in T:
        t_dict[i] = t_dict.get(i, 0) + 1
    # print(d_dict)
    # print(t_dict)

    ok = True
    for k in t_dict.keys():
        if d_dict.get(k, 0) < t_dict[k]:
            ok = False
            break

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

M = int(input())
T = input().split()
flg = True
for i in range(M):
    if T[i] in D:
        D[T[i]] -= 1
        if D[T[i]] < 0:
            print('NO')
            flg = False
            break
    else:
        print('NO')
        flg = False
        break
if flg:
    print('YES')

Submission status: Accepted

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

d.sort()
t.sort()
a = 0

for x in t:
    for i in range(a, n):
        if d[i] > x:
            print('NO')
            exit()
        if x == d[i]:
            a = i+1
            break

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

summary_d = {}
summary_t = {}

for i in range(0, len(d)):
    summary_d[d[i]] = summary_d.get(d[i],0) + 1

for i in range(0, len(t)):
    summary_t[t[i]] = summary_t.get(t[i],0) + 1

result = {}

for k,v in summary_t.items():
    result[k] = summary_d.get(k,0) - v

if min(result.values()) >= 0:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:

def spaceinput():
    return list(map(int,input().split(" ")))


M=spaceinput()
P=sorted(spaceinput())
N=spaceinput()
T=sorted(spaceinput())

false=False
k=0
for st in T:
    #print(st,k)
    for kk in range(k,len(P)):
        if st==P[kk]:
            k=kk+1
            break

        #print(P[k])

        if P[kk]>st:
            false=True
            break






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

Submission status: Accepted

Solution code:
def solve():
    while 1:
        try:
            N = int(input())
            D = list(map(int, input().split(" ")))
            M = int(input())
            T = list(map(int, input().split(" ")))
            D_dict = {}
            T_dict = {}
            for d in D:
                if d not in D_dict:
                    D_dict[d] = 1
                else:
                    D_dict[d] += 1

            for t in T:
                if t not in T_dict:
                    T_dict[t] = 1
                else:
                    T_dict[t] += 1

            for key, val in T_dict.items():
                if key not in D_dict:
                    print("NO")
                    raise EndLoop
                else:
                    if val > D_dict[key]:
                        print("NO")
                        raise EndLoop

            print("YES")
            break
        except:
            break


solve()

Submission status: Accepted

Solution code:
from collections import Counter
N = input()
D = Counter([i for i in input().split()])
M = input()
T = Counter([i for i in input().split()])
for key, value in T.items():
    try:
        if D[key] < value:
            print("NO")
            break
    except:
        print("NO")
        break
else:
    print("YES")

Submission status: Accepted

Solution code:
from collections import defaultdict

input()
d_list = input().split(" ")
input()
t_list = input().split(" ")

d_dict = defaultdict(lambda: 0)
for d in d_list:
    d_dict[d] += 1

t_dict = defaultdict(lambda: 0)
for t in t_list:
    t_dict[t] += 1

yes = True
for k, v in t_dict.items():
    if v > d_dict[k]:
        print("NO")
        yes = False
        break
if yes:
    print("YES")

Submission status: Accepted

Solution code:
dict ={}
raw_input()
for i in raw_input().split():
 if i in dict:
  dict[i]=dict[i]+1
 else:
  dict[i]=1

raw_input()
for i in raw_input().split():
 if i in dict:
  dict[i]=dict[i]-1
  if dict[i]<0:
   print "NO"
   exit()
 else:
  print "NO"
  exit()
print "YES"

Submission status: Accepted

Solution code:
N = int(input())
D = [int(i) for i in input().strip().split(' ')]
M = int(input())
D2 = [int(i) for i in input().strip().split(' ')]
D.sort()
D2.sort()

if M > N:
  print("NO")
else:
  d2idx = 0
  for i in range(len(D)):
    if D[i] == D2[d2idx]:
      d2idx += 1
    if d2idx >= len(D2):
      break
  print("YES" if d2idx == len(D2) else "NO")

Submission status: Accepted

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

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

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

    for key, val in t.items():
        if key in d.keys():
            d[key] -= val
            if d[key] < 0:
                ans = 'NO'
                break
        else:
            ans = 'NO'
            break
    else:
        ans = 'YES'

    print(ans)

main()

Submission status: Accepted

Solution code:
n=input()
a=sorted(map(int,raw_input().split()))
m=input()
b=sorted(map(int,raw_input().split()))
if n<m:print "NO"
else:
    i=0
    j=0
    while i<m:
        if b[i]==a[j]:
            i+=1
            j+=1
        elif b[i]<a[j]:
            break
        else:
            j+=1
            if j>=n: break
    print "YES" if i==m 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 = sorted(D)
T = sorted(T)


i = len(D)-1
j = len(T)-1

flag = True
while(0<=i and 0<=j):
    if D[i] > T[j]:
        i -= 1
    elif D[i] == T[j]:
        i -= 1
        j -= 1
    else:
        flag = False
        break
        
if flag == False or (i<=-1 and j>-1):
    print("NO")
else:
    print("YES")

Submission status: Accepted

Solution code:
import sys
N = int(input().strip())
D = list(map(int, input().strip().split(" ")))
print(N, len(D), file=sys.stderr)

import collections
Dd = collections.defaultdict(int)
for d in D:
    Dd[d] += 1

M = int(input().strip())
T = list(map(int, input().strip().split(" ")))
print(M, len(T), file=sys.stderr)
Td = collections.defaultdict(int)
for t in T:
    Td[t] += 1

for k,v in Td.items():
    if Dd[k] < v:
        print("NO")
        exit(0)
print("YES")
exit(0)

Submission status: Accepted

Solution code:
import sys
from collections import Counter
N = int(input())
D = Counter([int(c) for c in input().split()])
M = int(input())
T = Counter([int(c) for c in input().split()])
for t in T.items():
  if D[t[0]] < t[1]:
    print('NO')
    sys.exit()
print('YES')

Submission status: Accepted

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

D_dic = {k: 0 for k in D}
T_dic = {k: 0 for k in T}

for i in range(N):
    d = D[i]
    if D_dic[d]:
        a = D_dic[d] + 1
        D_dic[d] = a
    else:
        D_dic[d] = 1
    
for j in range(M):
    t = T[j]
    if T_dic[t]:
        b = T_dic[t] + 1
        T_dic[t] = b
    else:
        T_dic[t] = 1

cou = 0
if N >= M:
    for k in range(M):
        tk = T[k]
        try:
            if D_dic[tk]:
                c = D_dic[tk] - 1
                D_dic[tk] = c
                cou += 1
            else:
                x = 'NO'
                break
        except KeyError:
            x = 'NO'
            break
            
    if cou == M:
        x = 'YES'
else:
    x = 'NO'

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

res = 'YES'
counter_d = Counter(D)
counter_t = Counter(T)

set_t = list(set(T))
for i in set_t:
    if counter_d[i] < counter_t[i]:
        res = 'NO'
        break

print(res)

Submission status: Accepted

Solution code:
import sys
n = int(input())
d = {}
for i in input().split():
    if i in d:
        d[i] += 1
    else:
        d[i] = 1

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

Submission status: Accepted

Solution code:
n = int(input())
D = sorted([int(_) for _ in input().split()])
m = int(input())
T = sorted([int(_) for _ in input().split()])

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

res = "YES"

for i in T:
  if i not in D or T[i] > D[i]:
    res = "NO"
    break

print(res)

Submission status: Accepted

Solution code:
n = int(input())
d = {}
inp = map(int, input().split())

for i in inp:
    if i not in d:
        d[i] = 1
    else:
        d[i] += 1

n = int(input())
inp = map(int, input().split())

fl = 0
for i in inp:
    if i in d:
        if d[i] == 0:
            fl = 1
            break
        d[i] -= 1
    else:
        fl = 1
        break

if fl == 0:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
import collections

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


if n < m :
    print("NO")
else :
    dic = collections.defaultdict(int)
    for dd in d :
        dic[dd] += 1
    
    for tt in t :
        dic[tt] -= 1
        if dic[tt] < 0 :
            print("NO")
            break
    else :
        print("YES")

Submission status: Accepted

Solution code:
from collections import deque
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
a = deque(sorted(d))
b = deque(sorted(t))
flag = 0
if n >= m:
    for i in range(n):
        if a[0] == b[0]:
            b.popleft()
        a.popleft()
        if len(b) == 0:
            print("YES")
            flag = 1
            break
if flag == 0:
    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()))


def countNumber(LIST):
    cnt = {}
    for l in LIST:
        try:
            cnt[l] += 1
        except KeyError:
            cnt[l] = 1
    return cnt


countD = countNumber(D)
countT = countNumber(T)

flag = True
for i in countT.keys():
    try:
        if countD[i] < countT[i]:
            flag = False
    except KeyError:
        flag = False
        break

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

Submission status: Accepted

Solution code:
from sys import stdin, stdout
from collections import defaultdict
def readLine_int_list():return list(map(int, stdin.readline().split()))
def main():
    d = defaultdict(lambda: 0)
    t = defaultdict(lambda: 0)
    
    n=int(input())
    _d=readLine_int_list()
    for i in _d:
        d[i] += 1
        
    m = int(input())
    _t = readLine_int_list()
    
    for i in _t:
        t[i] += 1
    
    ans = "YES"
    for i in t:
        if i in d:
            if t[i] - d[i] > 0:
                ans = "NO"
                break
        else:
            ans = "NO"
            break
    print(ans)
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n=int(input())
dic={}
ds=[int(s)for s in input().split(" ")]
for d in ds:
    if d in dic:dic[d]+=1
    else:dic[d]=1
m=int(input())
ts=sorted([int(s)for s in input().split(" ")])
f=True
for t in ts:
    if t not in dic or dic[t]==0:
        print("NO")
        f=False
        break
    else:dic[t]-=1
if f:print("YES")

Submission status: Accepted

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

import sys

line = sys.stdin.readline().strip()
n = int(line)
parts = sys.stdin.readline().strip().split()
nvals = map(int,parts)
nhash = {}

for item in nvals:
    if nhash.has_key(item):
        nhash[item] += 1
    else:
        nhash[item] = 1

line = sys.stdin.readline().strip()
m = int(line)
parts = sys.stdin.readline().strip().split()
mvals = map(int,parts)
mhash = {}

for item in mvals:
    if mhash.has_key(item):
        mhash[item] += 1
    else:
        mhash[item] = 1

for item in mhash.keys():
    if nhash.has_key(item) and mhash[item] <= nhash[item]:
        pass
    else:
        print "NO"
        sys.exit()

print "YES"

Submission status: Accepted

Solution code:
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
import itertools
n=i1()
d=sorted(i2())
m=i1()
t=sorted(i2())
def a():
 j=0
 for i in range(m):
    while t[i]!=d[j]:
        if t[i]<d[j]:
            print("NO")
            return 0
        j+=1
    j+=1

 print("YES")
a()

Submission status: Accepted

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

dic = dict()

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

ans = "YES"
for ti in t:
    if ti not in dic or dic[ti] == 0:
        ans = "NO"
        break
    else:
        dic[ti] -= 1

print(ans)

Submission status: Accepted

Solution code:
import sys

n = int(input())
d = input().split()
m = int(input())
t = input().split()

dic = {}
for i in d:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1

for j in t:
    if j not in dic:
        print('NO')
        sys.exit()

    dic[j] -= 1
    if dic[j] < 0:
        print('NO')
        sys.exit()

print('YES')

Submission status: Accepted

Solution code:
n = int(raw_input())
d = sorted(map(int,raw_input().split(" ")))
m = int(raw_input())
t = sorted(map(int,raw_input().split(" ")))

dic = {}
dic2 = {}

for a in t:
  if a not in dic:
    dic[a]=1
  else:
    dic[a] += 1

for a in d:
  if a not in dic2:
    dic2[a]=1
  else:
    dic2[a] += 1

for a in dic:
  if a not in dic2:
    print "NO"
    exit(0)
  if dic[a] > dic2[a]:
    print "NO"
    exit(0)

print "YES"

Submission status: Accepted

Solution code:
import sys
n = input()
d = [int(i) for i in raw_input().split()]
m = input()
t = [int(i) for i in raw_input().split()]

dd = {}
tt = {}

for ddd in d:
    dd.setdefault(ddd,0)
    dd[ddd] += 1

for ttt in t:
    tt.setdefault(ttt,0)
    tt[ttt] += 1




for search in tt.keys():
    if search in dd:
        if tt[search] > dd[search]:
            
            print 'NO'
            sys.exit()

    else:
        print 'NO'
        sys.exit()

print 'YES'

Submission status: Accepted

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

from collections import Counter
cntD = Counter(D)
cntT = Counter(T)

for key, value in cntT.items():
    if cntD[key] < value:
        print('NO')
        break
else:
    print('YES')

Submission status: Accepted

Solution code:
from collections import defaultdict

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

    counter1 = defaultdict(int)
    counter2 = defaultdict(int)

    for d in D:
        counter1[d] += 1
    for t in T:
        counter2[t] += 1

    for t, cnt in counter2.items():
        if counter1[t] < cnt:
            print("NO")
            return

    print("YES")

foo()

Submission status: Accepted

Solution code:
def main():    
    N = int(input())
    D = [int(i) for i in input().split()]
    M = int(input())
    D.sort()
    T = [int(i) for i in input().split()]
    T.sort()

    point = 0
    for t in T:
        for p in range(point, N):
            if D[p] < t:
                continue
            elif D[p] == t:
                point = p+1
                #print(D[p])
                break

            elif D[p] > t:
                print('NO')
                return 
    print('YES')
    return

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict
D = defaultdict(int)
N = int(input())
for s in map(int,input().split()):
	D[s] += 1

T = defaultdict(int)
M = int(input())
for s in map(int,input().split()):
    T[s] += 1

for key,value in T.items():
   if not(key in D):
       print("NO")
       exit()
   else:
       if value > D[key]:
           print("NO")
           exit()

else:
    print("YES")