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: Time Limit Exceeded

Solution code:
import bisect
N = int(input())
D = list(map(int,input().split()))
M = int(input())
T = list(map(int,input().split()))
T.sort()
for i in range(N):
    b = bisect.bisect_left(T,D[i])
    if b<M and D[i]==T[b]:
        del T[b]
        M-=1
print("YES" if M==0 else "NO")

Submission status: Time Limit Exceeded

Solution code:
import bisect
N = int(input())
D = list(map(int,input().split()))
M = int(input())
T = list(map(int,input().split()))
T.sort()
for i in range(N):
    b = bisect.bisect_left(T,D[i])
    if b<M and D[i]==T[b]:
        T[b] = 0
        T.sort()
print("YES" if T.count(0)==M else "NO")

Submission status: Time Limit Exceeded

Solution code:
import bisect

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

for t in T:
    bl=bisect.bisect_left(D,t)
    if D[bl]==t:
        del D[bl]
    else:
        print('NO')
        exit()
print('YES')

Submission status: Time Limit Exceeded

Solution code:
import sys
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))
for i in range(m):
    if t[i] in d:
        d.remove(t[i])
    else:
        print('NO')
        sys.exit()
print('YES')

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))
for i in T:
	if i in D:
		D.remove(i)
	else:
		print("NO")
		exit()
print("YES")

Submission status: Time Limit Exceeded

Solution code:
import collections

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

D.sort()
T2 = collections.Counter(T)

for i in T2.keys():
    if T2[i] > D.count(i):
        print("NO")
        exit()

print("YES")

Submission status: Time Limit Exceeded

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)
d_key = d.keys()
t_key = t.keys()

for i in t_key:
    if i not in d_key or t[i] > d[i]:
        print('NO')
        exit()

print('YES')

Submission status: Time Limit Exceeded

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

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

dict_d = {}
for i in d:
    dict_d[i] = D.count(i)

for i in T:
    if i not in d:
        print('NO')
        exit()
    else:
        if dict_d[i] > 0:
            dict_d[i] -= 1
        else:
            print('NO')
            exit()

print('YES')

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
D = [int(i) for i in input().split()]
d = set(D)
M = int(input())
T = [int(i) for i in input().split()]

dict_d = {}
for i in d:
    dict_d[i] = D.count(i)

for i in T:
    if i not in d:
        print('NO')
        exit()
    else:
        if dict_d[i] > 0:
            dict_d[i] -= 1
        else:
            print('NO')
            exit()

print('YES')

Submission status: Time Limit Exceeded

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

for i in T:
    if i not in D:
        print('NO')
        exit()
    else:
        D.remove(i)

print('YES')

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
D = [int(x) for x in input().split()]
M = int(input())
T = [int(x) for x in input().split()]
flag = True
for i in T:
    if(i in D):
        D.pop(D.index(i))
    else:
        flag=False
if(flag):
    print('YES')
else:
    print('NO')

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))
for i in range(m):
    if d.count(t[i])>0:
        d.remove(t[i])
    else:
        print("NO")
        exit()
print("YES")

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
D = [int(i)-1 for i in input().split()]
M = int(input())
T = [int(i)-1 for i in input().split()]

flag = True

for t in T:
    if t in D:
        D.remove(t)
    else:
        flag = False
        break

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
D = [int(i) for i in input().split()]
D.sort()
M = int(input())
T = [int(i) for i in input().split()]
T.sort()
cnt = [0]*M
s = 0
for n in range(N):
    d = D[n]
    for m in range(s,M):
        if T[m] == d:
            T[m] = 0
            s = m
            cnt[m] += 1
            break

if sum(cnt) == M:
    print('YES')
else:
    print('NO')

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
D = [int(i) for i in input().split()]
D.sort()
M = int(input())
T = [int(i) for i in input().split()]
T.sort()
cnt = [0]*M
s = 0
for n in range(N):
    d = D[n]
    for m in range(s,M):
        if T[m] == d:
            T[m] = 0
            s = m
            cnt[m] += 1
            break

if sum(cnt) == M:
    print('YES')
else:
    print('NO')

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
D = [int(i) for i in input().split()]
M = int(input())
T = [int(i) for i in input().split()]
cnt = [0]*M
for n in range(N):
    d = D[n]
    for m in range(M):
        if T[m] == d:
            T[m] = 0
            cnt[m] += 1
            break

if sum(cnt) == M:
    print('YES')
else:
    print('NO')

Submission status: Time Limit Exceeded

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

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

d.sort()
t.sort()

def array_count(arr):
    arr_target = [[]]
    cnt = 1
    for i in range(1,len(arr)):
        if arr[i] == arr[i-1]:
            cnt += 1
        else:
            arr_target.append([arr[i-1],cnt])
            cnt = 1
    arr_target.append([arr[len(arr)-1],cnt])
    del arr_target[0]
    return arr_target

d = array_count(d)
t = array_count(t)

flag = True
for i in range(len(t)):
    temp = -1
    for j in range(len(d)):
        if d[j][0] == t[i][0]:
            temp = j
    if temp == -1:
        flag = False
        break
    if d[temp][1] >= t[i][1]:
        pass
    else:
        flag = False
        break

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
a = [int(i) for i in input().split()]
M = int(input())
b = [int(i) for i in input().split()]
a.sort()
b.sort()
p=0
for i in range (len(b)):
    for j in range(len(a)):
        if b[i] == a[j]:
            a = a[j+1:N]
            break
        else:
            if j ==len(a)-1:
                print("NO")
                p =1
                break
    if p ==1:
        break    
    if i == len(b)-1:
        print("YES")

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
d = list(map(int,input().split()))
d.sort()
m = int(input())
t = list(map(int,input().split()))
t.sort()
for x in d:
    if x > t[0]:
        break
    elif x ==t[0]:
        t.pop(0)
    else:
        continue
    if len(t)==0:
        break
if len(t)==0:
    print("YES")
else:
    print("NO")

Submission status: Time Limit Exceeded

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

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

d.sort()
t.sort()

flag = True
for i in range(len(t)):
    if t[i] in d:
        del d[d.index(t[i])]
    else:
        flag = False
        break

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
d = list(map(int,input().split()))
d.sort()
m = int(input())
t = list(map(int,input().split()))
t.sort()
for x in d:
    if x == t[0]:
        t.pop(0)
    if len(t)==0:
        break
if len(t)==0:
    print("YES")
else:
    print("NO")

Submission status: Time Limit Exceeded

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

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

d.sort()
t.sort()

flag = True
for i in range(len(t)):
    if t[i] in d:
        del d[d.index(t[i])]
    else:
        flag = False
        break

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

Submission status: Time Limit Exceeded

Solution code:
n,d,m,t,ans=int(input()),list(map(int,input().split())),int(input()),list(map(int,input().split())),"YES"
for i in t:
  if i in d:del d[d.index(i)]
  else:ans="NO";break
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
D = [int(_) for _ in input().split()]
M = int(input())
T = [int(_) for _ in input().split()]

D = sorted(D)
T = sorted(T)
Dstart = 0
flag = True

for i in T:
    for j in D[Dstart:]:
        Dstart += 1
        if i == j:
            break
        elif i < j:
            flag = False
            break
        if Dstart == N:
            flag = False
    if not flag:
        break

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
D = [int(_) for _ in input().split()]
M = int(input())
T = [int(_) for _ in input().split()]

D = sorted(D)
T = sorted(T)
Dstart = 0
flag = True

for i in T:
    for j in D[Dstart:]:
        Dstart += 1
        if i == j:
            break
        if Dstart == N:
            flag = False
    if not flag:
        break

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

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
D=sorted(list(map(int,input().split(' '))))
M=int(input())
T=sorted(list(map(int,input().split(' '))))
ans='YES'
for t in set(T):
  if T.count(t)>D.count(t):
    ans='NO'
    break
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
D=list(map(int,input().split(' ')))
M=int(input())
T=list(map(int,input().split(' ')))
ans='YES'
for t in set(T):
  if T.count(t)>D.count(t):
    ans='NO'
    break
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
D=list(map(int,input().split(' ')))
M=int(input())
T=list(map(int,input().split(' ')))
ans='YES'
for t in T:
  if t not in D:
    ans='NO'
    break
  else:
    D.pop(D.index(t))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
for i in t:
  if i in d:
    d.remove(i)
  else:
    print("NO")
    exit()
print("YES")

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
D = list(map(int,input().split()))
m = int(input())
T = list(map(int,input().split()))
for i in range(m):
    if T[i] in D:
        del D[D.index(T[i])]
    else:
        print("NO")
        exit()
print("YES")

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
d = list(int(i) for i in input().split())
m = int(input())
t = list(int(i) for i in input().split())
for i in t:
  if not i in d:
    print('NO')
    exit()
  d.remove(i)
print('YES')

Submission status: Time Limit Exceeded

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

if N < M:
    print('NO')
else:
    F = True
    for t in T:
        if (t in D) == False:
            F = False
            break
        else:
            del D[D.index(t)]
    if F:
        print('YES')
    else:
        print('NO')

Submission status: Time Limit Exceeded

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



if n >= m:
    for i in d:
        if i in t:
            t.remove(i)
if len(t) == 0:
    print("YES")
else:
    print("NO")

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=list(map(int,input().split()))
m=int(input())
b=list(map(int,input().split()))
p=list(set(b))
c=0
for i in range(len(p)):
    if b.count(p[i])>a.count(p[i]):
        c=1
print("YES"if c!=1else"NO")

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=list(map(int,input().split()))
m=int(input())
b=list(map(int,input().split()))
a=[i for i in a if i in b]
p=list(set(b))
c=0
for i in range(len(p)):
    if b.count(p[i])>a.count(p[i]):
        c=1
print("YES"if c!=1else"NO")

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


s = set(d)
val = []
for i in s:
    val.append(d.count(i))
else:
    dd = dict(zip(s,val))

ss = set(t)
for i in ss:
    if i not in s:
        print("NO")
        exit()
for i in range(m):
    dd[t[i]] -= 1
    if dd[t[i]] < 0:
        print("NO")
        exit()
else:
    print("YES")
"""
d.sort()
t.sort()
for i in t:
    try:
        d.remove(i)
    except:
        print("NO")
        exit()
else:
    print("YES")
"""

Submission status: Time Limit Exceeded

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

"""
s = set(d)
val = []
for i in s:
    val.append(d.count(i))
else:
    dd = dict(zip(s,val))

ss = set(t)
for i in ss:
    if i not in s:
        print("NO")
        exit()
for i in t:
    dd[i] -= 1
    if dd[i] < 0:
        print("NO")
        exit()
else:
    print("YES")
"""
d.sort()
t.sort()
for i in t:
    try:
        d.remove(i)
    except:
        print("NO")
        exit()
else:
    print("YES")

Submission status: Time Limit Exceeded

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

"""
s = set(d)
val = []
for i in s:
    val.append(d.count(i))
else:
    dd = dict(zip(s,val))

ss = set(t)
for i in ss:
    if i not in s:
        print("NO")
        exit()
for i in t:
    dd[i] -= 1
    if dd[i] < 0:
        print("NO")
        exit()
else:
    print("YES")
"""

for i in t:
    try:
        d.remove(i)
    except:
        print("NO")
        exit()
else:
    print("YES")

Submission status: Time Limit Exceeded

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


s = set(d)
val = []
for i in s:
    val.append(d.count(i))
else:
    dd = dict(zip(s,val))

ss = set(t)
for i in ss:
    if i not in s:
        print("NO")
        exit()
for i in t:
    dd[i] -= 1
    if dd[i] < 0:
        print("NO")
        exit()
else:
    print("YES")

Submission status: Time Limit Exceeded

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


s = set(d)
val = []
for i in s:
    val.append(d.count(i))
else:
    dd = dict(zip(s,val))

for i in t:
    if i not in s:
        print("NO")
        exit()
    dd[i] -= 1
    if dd[i] < 0:
        print("NO")
        exit()
else:
    print("YES")

Submission status: Time Limit Exceeded

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

for i in t:
    if i in d:
        d.remove(i)
    else:
        print("NO")
        exit()
else:
    print("YES")

Submission status: Time Limit Exceeded

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

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

# if N < M:
#     print('NO')
# else:
ind = 0
for t in T:
    for i,d in enumerate(D[ind:]):
        if d == t:
#            print(ind,D[ind:])
            ind += i + 1
            break
    else:
        print('NO')
        exit()
    if M - t > N - ind + 1:
        print('NO')
        exit()

print('YES')

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))
judge = "YES"
for i in range(M):
	if D.count(T[i]) >= 1:
		D.remove(T[i])
	else:
		judge = "NO"
		break

print(judge)

Submission status: Time Limit Exceeded

Solution code:
# N, M, K = map(int, input().split())
# N = int(input())
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))
flag = False
ans_flag = True
# iは欲しい難易度
for i in T:
    # jは用意された問題の難易度
    for n, j in enumerate(D):
        if i == j:
            D.pop(n)
            # print(D)
            flag = True
            break
    if flag == False:
        print("NO")
        ans_flag = False
        break
    else:
        flag = False
if ans_flag == True:
    print("YES")

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))
 
Z = []
for i in range(N):
    for j in range(M):
        if D[i] == T[j]:
            Z.append(T[j])
            T[j] = 0
            break
 
if len(Z) < len(T):
    print("NO")
else:
    print("YES")

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))
x=0
d.sort()
t.sort()
for i in range(m):
  if t[i] in d:
    d.remove(t[i])
  else:
    x=1
    break
if x==0:print('YES')
else:print('NO')

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))
x=0
for i in range(m):
  if t[i] in d:
    d.remove(t[i])
  else:
    x=1
    break
if x==0:print('YES')
else:print('NO')

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=list(map(int, input().split()))
m=int(input())
b=list(map(int, input().split()))
b2=set(b)
ans='YES'
for i in b:
    if a.count(i)<b.count(i):
        ans='NO'
        break
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def binarySearch(list_a, key):
    left = 0
    right = len(list_a)
    while left < right:
        mid = (left + right) // 2
        if list_a[mid] == key:
            return mid
            break
        elif key < list_a[mid]:
            right = mid
        else:
            left = mid+1
    else:
        return "NOT_FOUND"

n = int(input())
list_d = list((map(int, input().split())))
m = int(input())
list_t = list((map(int, input().split())))

list_d.sort()

for number in list_t:
    ind = binarySearch(list_d, number)
    if ind != "NOT_FOUND":
        del list_d[ind]
    else:
        print("NO")
        break
else:
    print("YES")

Submission status: Time Limit Exceeded

Solution code:
def binarySearch(list_a, key):
    left = 0
    right = len(list_a)
    while left < right:
        mid = (left + right) // 2
        if list_a[mid] == key:
            return mid
            break
        elif key < list_a[mid]:
            right = mid
        else:
            left = mid+1
    else:
        return "NOT_FOUND"


n = int(input())
list_d = list((map(int, input().split())))
m = int(input())
list_t = list((map(int, input().split())))

list_d.sort()
for number in list_t:
    ind = binarySearch(list_d, number)
    if ind != "NOT_FOUND":
        del list_d[ind]
    else:
        print("NO")
        break
else:
    print("YES")

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
for i in t:
    if i in d:
        d.remove(i)
    else:
        print("NO")
        exit()
print("YES")

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
s=sorted(list(map(int,input().split())))
m=int(input())
t=sorted(list(map(int,input().split())))
for i in s:
    if i in t:
        t.remove(i)
if t==[]:
    print("YES")
else:
    print("NO")

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
n=int(input())
s=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))
ss=Counter(s)
tt=Counter(t)
s1=list(ss.keys())
s2=list(ss.values())
for i,j in tt.items():
    if i not in s:
        print("NO")
        exit()
    if s2[s1.index(i)]<j:
        print("NO")
        exit()
print("YES")

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
d = [int(i) for i in input().split()]
m = int(input())
t = [int(i) for i in input().split()]
*p, = t
c = []
for i in d:
    if i in t:
        c.append(i)
        t.remove(i)
c.sort()
p.sort()
if c == p:
    print('YES')
else:
    print('NO')

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
t_ = list(set(t))
for i in range(len(t_)):
  if t.count(t_[i]) > d.count(t_[i]):
    print("NO")
    exit()
print("YES")

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
for i in range(m):
  if t.count(t[i]) > d.count(t[i]):
    print("NO")
    exit()
print("YES")

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
for i in range(m):
  if t[i] in set(d):
    d.remove(t[i])
  else:
    print("NO")
    exit()
print("YES")

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
for i in range(m):
  if t[i] in d:
    d.remove(t[i])
  else:
    print("NO")
    exit()
print("YES")

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
for i in range(m):
  if t[i] in d:
    d.remove(t[i])
  else:
    print("NO")
    exit()
print("YES")

Submission status: Time Limit Exceeded

Solution code:
input()
s=input()
input()
for t in input().split():
  if s.find(t)<0:
    print('NO')
    break
  s=s.replace(t,'',1)
else:
  print('YES')

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))
ans = "YES"
T_set = set(T)
T_set = list(T_set)
for i in range(len(T_set)):
	if D.count(T_set[i]) < T.count(T_set[i]):
		ans = "NO"
		break
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()
    
    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

            else:

                flg = 0
    finally:

        return array_result

arr_data = getinputdata()

n = int(arr_data[0][0])
arr=[int(x) for x in arr_data[1]]

m = int(arr_data[2][0])
arr_problem=[int(x) for x in arr_data[3]]

chkflg=True

for v in arr_problem:
    
    if v in arr:
        
        arr.pop(arr.index(v))
    else:
        
        chkflg=False
        break
        
        
print("YES" if chkflg else "NO")

Submission status: Time Limit Exceeded

Solution code:
import sys

N = list(input())
D_li = list(map(int,input().split()))
M = list(input())
T_li = list(map(int,input().split()))

for i in T_li:
	if i in D_li:
		D_li.remove(i)
	else:
		print('NO')
		sys.exit()

print('YES')

Submission status: Time Limit Exceeded

Solution code:
input()
s=input().split()
a=[]
for i in s:
 a.append(int(i))
a.sort()
input()
s=input().split()
b=[]
for i in s:
 b.append(int(i))
b.sort()
while len(a)>0:
    if a[0]==b[0]:
        del(a[0])
        del(b[0])
        if len(b)==0:
            break
    elif a[0]<b[0]:
        del(a[0])
    else:
        a=[]
if len(b)==0:
    print("YES")
else:
    print("NO")

Submission status: Time Limit Exceeded

Solution code:
input()
a=list(map(int,input().split()))
a.sort()
input()
b=list(map(int,input().split()))
b.sort()
while len(a)>0:
    if a[0]==b[0]:
        del(a[0])
        del(b[0])
        if len(b)==0:
            break
    elif a[0]<b[0]:
        del(a[0])
    else:
        a=[]
if len(b)==0:
    print("YES")
else:
    print("NO")

Submission status: Time Limit Exceeded

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()
Dd={}
Td={}
Ds=set(D)
Ts=set(T)
for i in Ds:
    Dd[i]=D.count(i)
for i in Ts:
    Td[i]=T.count(i)
for i in Td.keys():
    if(i in Dd):
        if(Td[i]>Dd.get(i)):
            print("NO")
            sys.exit()
    else:
        print("NO")
        sys.exit()
print("YES")

Submission status: Time Limit Exceeded

Solution code:
import sys


n=int(input())
D=list(map(int,input().split()))
M=int(input())
T=list(map(int,input().split()))
for i in T:
    if(i not in D):
        print("NO")
        sys.exit()
    else:
        D.remove(i)
print("YES")

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
lis = list(map(int,input().split()))
d = int(input())
li = list(map(int,input().split()))
for i in range(d):
    if li[i] in lis:
        lis.remove(li[i])
    else:
        print("NO")
        exit()
print("YES")

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
D = list(map(int,input().split()))
M = int(input())
T = list(map(int,input().split()))
for i in T:
    if i in D:
        D.pop(D.index(i))
    else:
        print("NO")
        exit()
print("YES")

Submission status: Time Limit Exceeded

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

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

d.sort()
t.sort()

p = 0
for i in range(len(t)):
    for j in range(p,len(d)):
        if(t[i] == d[j]):
            t[i] = 0
            d[j] = 0
            p = j
            break
            
print('YES' if sum(t) == 0 else 'NO')

Submission status: Time Limit Exceeded

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

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

d.sort()
t.sort()

p = 0
for i in range(len(t)):
    for j in range(p,len(d)):
        if(t[i] == d[j]):
            t[i] = 0
            d[j] = 0
            p = j
            
print('YES' if sum(t) == 0 else 'NO')

Submission status: Time Limit Exceeded

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

D.sort()
T.sort()

#print N
#print D
#print M
#print T

no=0
for i in range(M):
	for j in range(no,N):
		#print i,j,T[i],D[j]
		if T[i]==D[j]:
			no=j+1
			break
		elif T[i]!=D[j] and j==N-1:
			print "NO"
			sys.exit()

print "YES"

Submission status: Time Limit Exceeded

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

for t in set(T):
    if D.count(t) < T.count(t):
        print('NO')
        exit()
        
print('YES')

Submission status: Time Limit Exceeded

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

for ti in t:
    if ti in d:
        d.remove(ti)
    else:
        ans = "NO"
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
lstD = []
lstT = []
lstD.extend( list(map(int, input().split())) )
m = int(input())
lstT.extend( list(map(int, input().split())) )

ans = 0
for i in range(m):
    if (lstT[i] in lstD) == True:
        ans += 1
        lstD.remove(lstT[i])
if ans == m:
    print("YES")
else:
    print("NO")

Submission status: Time Limit Exceeded

Solution code:
import collections


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

TS=collections.Counter(T)

for i,k in TS.items():
    if k > D.count(i):
        print('NO')
        exit()

print('YES')

Submission status: Time Limit Exceeded

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

for i in T:
    if T.count(i)>D.count(i):
        print('NO')
        exit()

print('YES')

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
D=list(map(int,input().split()))
M=int(input())
T=list(map(int,input().split()))
TS=set(T)
for i in TS:
    if T.count(i)>D.count(i):
        print('NO')
        exit()

print('YES')

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
Dstr = input().split()
D = []
for i in range(N):
    D.append(int(Dstr[i]))
M = int(input())
T = input().split()

for i in range(M):
    
    Ti = int(T[i])
    
    if not Ti in D:
        print('NO')
        break
    else:
        indexD = D.index(Ti)
        del D[indexD]
else:
    print('YES')

Submission status: Time Limit Exceeded

Solution code:
import bisect
s=input()
s=input().split()
t=input()
t=input().split()
for i in range(len(s)):
 s[i]=int(s[i])
for i in range(len(t)):
 t[i]=int(t[i])
s.sort()
t.sort()
f=False
for c in t:
 i=bisect.bisect_left(s,c)
 if s[i]!=c:
  print("NO")
  f=True
  break
 else:
  s.pop(i)
if not f:
 print("YES")

Submission status: Time Limit Exceeded

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

for i in range(M):
    if T[i] in D:
        D.remove(T[i])
        ans += 1

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

Submission status: Time Limit Exceeded

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

for x in t:
    if x in d:
        d.remove(x)
    else:
        print('NO')
        exit()

print('YES')

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))
if M > N:
    print("NO")
else:
    D.sort()
    T.sort()
    for i in T:
        if T.count(i) > D.count(i):
            print("NO")
            break
        else:
            D.remove(i)
            T.remove(i)
    else:
        print("YES")

Submission status: Time Limit Exceeded

Solution code:
n=raw_input()
nlist=raw_input().split(' ')
m=raw_input()
mlist=raw_input().split(' ')
flag=1
for ml in mlist:
 try:
  nlist.remove(ml)
 except ValueError:
  print "NO"
  flag=0
  break
if flag:print "YES"