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: Wrong Answer

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

print "YES"

Submission status: Wrong Answer

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


for i in T:
	for j in D:
		#print i,j
		#print D
		if j==-1:
			continue
		if i==j:
			D[D.index(j)]=-1
			break
		elif D.index(j)==len(D)-1 and i!=j:
			print "NO"
			sys.exit()
		else:
			continue

print "YES"

Submission status: Wrong Answer

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: Wrong Answer

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 not di[i] or (di[i] == 0):
        ans = "No"
        break
    else:
        di[i] -= 1
         
print(ans)

Submission status: Wrong Answer

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)

x.sort()
y.sort()
num=0
for k in range(len(y)) :
    for i in range(num, len(x)) :
       if i == k :
           del x[i]
           num = i
           break
    if i+1 == len(x) :
        print('NO')
        exit()
print('YES')

Submission status: Wrong Answer

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)
MAX=1
z=[0]*MAX

print('YES')

Submission status: Wrong Answer

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)

z=[0]*1

print('YES')

Submission status: Wrong Answer

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)
z=[0]*1
print('YES')

Submission status: Wrong Answer

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)

print('YES')

Submission status: Wrong Answer

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



print('YES')

Submission status: Wrong Answer

Solution code:
import sys

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

for k in range(len(y)) :
    for i in range(len(x)) :
        if x[i] == y[k] :
            del x[i]
            break
        if x[i] > y[k] :
            print('NO')
            sys.exit()
if j == 0 :
    print('OK')

Submission status: Wrong Answer

Solution code:
q=input()
x=[int(i) for i in input().split()]
cnt=input()
j=0
y=[int(i) for i in input().split()]
x.sort()
y.sort()

for k in range(len(y)) :
    for i in range(len(x)) :
        if x[i] == y[k] :
            del x[i]
            break
        if i+1 == len(x) :
            print('NO')
            j=1
if j == 0 :
    print('OK')

Submission status: Wrong Answer

Solution code:
q=input()
x=[int(i) for i in input().split()]
cnt=input()
j=0
y=[int(i) for i in input().split()]
for k in range(len(y)) :
    for i in range(len(x)) :
        if x[i] == y[k] :
            del x[i]
            break
    if i+1 == len(x) :
        print('NO')
        j=1
        break
if j==0 :
    print('YES')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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)
 
s = 0
k = 0
for i in t:
    while(1):
        if s == len(d):
            break
        if d[s] == i:
            s += 1
            k += 1
            break
        else:
            s += 1
        
    
if k == len(t):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
Dstr = input().split()
D = []
for i in range(N):
    D.append(int(Dstr[i]))
sortedD = sorted(D, key = int)   

M = int(input())
Tstr = input().split()
T = []
for i in range(M):
    T.append(int(Tstr[i]))
sortedT = sorted(T, key = int)    

end = 0

for i in range(M):
    Ti = sortedT[-(i+1)]
    
    for j in range(N):
        Di = sortedD[-(j+1)]
        if Ti > Di:
            print('NO')
            end = 1
            break
            
        if Ti == Di:
            del sortedD[-(j+1)] 
            break
            
    if end == 1:
        break
           
if end == 0:
    print('YES')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import numpy as np

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

result = True
for i in t:
    index = list(np.where(d==i)[0])
    if(len(index)>0):
        if(len(index)>1):
            index = index[0]
        else:
            index = int(index[0])
        print(index)
        d = np.delete(d,index,0)
    else:
        result = False
        break
print ("YES") if result else print("NO")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import numpy as np

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

result = True
for i in t:
    try:
        index = int(list(np.where(d==i))[0])
        np.delete(d,index,0)
    except TypeError:
        result = False
        break
print ("YES") if result else print("NO")

Submission status: Wrong Answer

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

D = sorted(D, reverse=True)
T = sorted(T, reverse=True)


i = 0
j = 0

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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: Wrong Answer

Solution code:
N = input()
D = [i for i in input()]
M = input()
T = [i for i in input()]
for t in T:
    if t in D:
        D.remove(t)
    else:
        print("NO")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
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")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
def nibutan(x):
    low = 0
    high = len(d)-1
    mid = (low + high) // 2
    while (low<=high):
        if x == d[mid]:
            break
        elif x > d[mid]:
            low = mid + 1
        elif x < d[mid]:
            high = mid - 1
        mid = (low + high) // 2
    if d[mid] == x:
        return mid
    else:
        return -1

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

d.sort()
frag = True
for tmp in t:
    place = nibutan(tmp)
    if place == -1:
        frag = False
        break
    else:
        del d[place]
        if len(d) == 0:
            frag = False
            break
if frag:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
class EndLoop(Exception):
    pass


def solve():
    while 1:
        try:
            N = int(input())
            D = list(map(int, input().split(" ")))
            M = int(input())
            T = list(map(int, input().split(" ")))
            if N < M:
                print("NO")
                break

            i = 0
            while 1:
                if i == M - 1:
                    break
                elif T[i] in D:
                    D.remove(T[i])
                else:
                    print("NO")
                    raise EndLoop
                i += 1
                    
            print("YES")
            break
        except:
            break


solve()

Submission status: Wrong Answer

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: Wrong Answer

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

for d in D:
    if d in T:
        T.remove(d)
    if len(T)==0:
        print("YES")
        quit()
print("NO")

Submission status: Wrong Answer

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)


if T[0] in D:
    first = D.index(T[0])
    if T == D[first:M+first]:
         res = 'YES'
    else:
        res = 'NO'
else:
    res = 'NO'

print(res)

Submission status: Wrong Answer

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)

s = 0
k = 0
for i in t:
    while(1):
        if s == len(d):
            break
        if d[s] == i:
            s += 1
            k += 1
            break
        else:
            s += 1
        
    
if k == len(t):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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: Wrong Answer

Solution code:
n = input()
d = [int(i) for i in input().split(" ")]

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


d_set = set(d)
d_set = list(d_set)
t_set = set(t)
t_set = list(t_set)

flag =0

if len(t_set) != len(d_set):
    flag = 1
else:
    for s in t_set:
        if d.count(s) < t.count(s):
            flag = 1
            break


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

Submission status: Wrong Answer

Solution code:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

N = int(input())
D = input().split(" ")
M = int(input())
T = input().split(" ")


if len(D) < len(T):
	print("NO")
	exit(0)

D.sort()
T.sort()

i = 0
j = 0

while True:
	if i > M-1:
		print("YES")
		break
	elif D[j] == D[i] :
		i += 1
		j += 1

	else:
		j += 1

		if j > N - 1:
			print("NO")
			break

		elif D[j] > D[i]:
			print("NO")
			break

Submission status: Wrong Answer

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

    d = list(D)
    for i in T:
        if i in d:
            d[D.index(i)] = 0
        else:
            print('NO')
            break
    else:
        print('YES')

main()

Submission status: Wrong Answer

Solution code:
from collections import Counter

if __name__ == '__main__':
    N = int(input())
    D = list(map(int, input().split()))
    M = int(input())
    T = list(map(int, input().split()))

    counter_d = Counter(D)
    counter_t = Counter(T)

    ans = "Yes"
    for point, num in counter_t.items():

        if counter_d.get(point) is None or counter_d.get(point) < num:
            ans = "No"
            break

    print(ans)

Submission status: Wrong Answer

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

if len(T) > len(D):
    print("NO")
    sys.exit()
else:
    for i in T:
        if i in T:
            T.remove(i)
        else:
            print("NO")
            sys.exit()
print("YES")

Submission status: Wrong Answer

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

if t_set <= d_set:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

searched = []
if N < M:
    print('NO')
else:
    flag = True
    for i in range(M):
        if T[i] in searched:
            if D.count(T[i]) < T.count(T[i]):
                flag = False
                break
        searched.append(T[i])
    if flag:
        print('YES')
    else:
        print('NO')

Submission status: Wrong Answer

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

for t in T:
    if t in D:
        D.remove(t)
    else:
        print("NO")
        quit()
print("YES")

Submission status: Wrong Answer

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):
    a = T[i]
    if a in D:
        D.remove(a)
        ans = 'Yes'
    else:
        ans = 'No'
        break
print(ans)

Submission status: Wrong Answer

Solution code:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

N = int(input())
D = input().split(" ")
M = int(input())
T = input().split(" ")

D.sort()
T.sort()
j = 0

for i in T:
	if D[j] == i :
		continue
	else:
		j += 1

		if j > N - 1:
			print("NO")
			exit(0)

		elif D[j] > i:
			print("NO")
			exit(0)

print("YES")

Submission status: Wrong Answer

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

for t in T:
    try:
        D.remove(t)
    except:
        print("NO")
        quit()
if D:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

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

cou = 0
if N >= M:
    for i in range(M):
        if T[i] in D:
            D.remove(T[i])
            cou += 1
        else:
            x = 'No'
            break
            
    if cou == M:
        x = 'Yes'
else:
    x = 'No'

print(x)

Submission status: Wrong Answer

Solution code:
n1=int(input())
a=input().split()
n2=int(input())
n=0
for i in input().split():
    try:
        a.remove(i)
    except:
        n=1
if n==1:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

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: Wrong Answer

Solution code:
def solve():
    while 1:
        N = int(input())
        D = list(map(int, input().split(" ")))
        M = int(input())
        if N < M:
            print("NO")
            break
        T = list(map(int, input().split(" ")))

        for t in T:
            if t not in D:
                print("NO")
                break

        print("YES")
        break


solve()

Submission status: Wrong Answer

Solution code:
a = int(input())
b = list(map(int, input().split()))
c = int(input())
d = list(map(int, input().split()))
ans = "Yes"
for i in range(c):
    if d[i] in b:
        b.remove(d[i])
    else:
        ans = "No"
        break
print(ans)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
# d = list(map(int, input().split())
D = collections.Counter(input())
m = int(input())
# t = list(map(int, input().split())
T = collections.Counter(input())
for k,v in T.items():
    if k not in D or D[k] < v:
        print('NO')
        exit()
print('YES')

Submission status: Wrong Answer

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

indexD=0
indexT=0
while indexD<len(D) and indexT<len(T):
	if D[indexD]==T[indexT]:
		indexD+=1
		indexT+=1
	else:
		indexD+=1
if indexT==len(T):
	print("Yes")
else:
	print("No")

Submission status: Wrong Answer

Solution code:
def solve():
    while 1:
        N = int(input())
        D = list(map(int, input(" ")))
        M = int(input())
        if N < M:
            print("NO")
            break   
        T = list(map(int, input(" ")))
        
        for t in T:
            if t not in D:
                print("NO")
                break
        
        print("YES")
        break

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 not in d:
        print("NO")
        exit()
    d.pop(d.index(i))
print("YES")

Submission status: Time Limit Exceeded

Solution code:
import collections

n = int(input())
dd = list(map(int, input().split()))
m = int(input())
tt = list(map(int, input().split()))
cd = collections.Counter(dd)
ct = collections.Counter(tt)

if m > n:
  print('NO')
  exit()
        

for t in tt: 
  if t in dd and ct[t] <= cd[t]:
    continue
  else:
    print('NO')
    exit()
print('YES')

Submission status: Time Limit Exceeded

Solution code:
import collections

n = int(input())
dd = list(map(int, input().split()))
m = int(input())
tt = list(map(int, input().split()))
cd = collections.Counter(dd)
ct = collections.Counter(tt)

for t in tt:
 
  if t in dd and ct[t] <= cd[t]:
    continue
  else:
    print('NO')
    exit()
print('YES')

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
l1 = list(map(int,input().split()))
m = int(input())
l2 = list(map(int,input().split()))

for i in range(m):
    if l2[i] in l1:
        l1.remove(l2[i])
    else:
        print('NO')
        break
else:
    print('YES')

Submission status: Time Limit Exceeded

Solution code:
def list_difference(list1, list2):
    result = list1.copy()
    for value in list2:
        if value in result:
            result.remove(value)

    return result

n=int(input())
l1=list(map(int,input().split()))
m=int(input())
l2=list(map(int,input().split()))

x=list_difference(l2,l1)


if x==[]: print('YES')
else: print('NO')

Submission status: Time Limit Exceeded

Solution code:
def list_difference(list1, list2):
    result = list1.copy()
    for value in list2:
        if value in result:
            result.remove(value)
    return result

n=int(input())
l1=list(map(int,input().split()))
m=int(input())
l2=list(map(int,input().split()))

x=list_difference(l2,l1)

if x==[]: print('YES')
else: print('NO')

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
dd = list(map(int, input().split()))
m = int(input())
tt = list(map(int, input().split()))

for t in tt:
  if dd.count(t) >= tt.count(t):
    continue
  else:
    print('NO')
    exit()
print('YES')

Submission status: Time Limit Exceeded

Solution code:
from collections import deque
N = int(input())
D = deque(sorted(list(map(int, input().split()))))
M = int(input())
T = deque(sorted(list(map(int, input().split()))))
ans = 'YES'
for i in range(M):
  prb = T.pop()
  #print(D, T, prb)
  if prb in D:
    D.remove(prb)
  else:
    ans = 'NO'
    break
print(ans)

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

D_=list(set(D))
T_=list(set(T))
flg=True
for a in T_:
    if a not in D_:
        flg=False
if flg:
    for t_ in list(set(T)):
        #print(t_)
        #print(t[str(t_)], d[str(t_)])
        if t[str(t_)] <= d[str(t_)]:
            pass
        else:
            flg=False
if flg:
    print("YES")
else:
    print("NO")

Submission status: Time Limit Exceeded

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)
cntt = Counter(T)
ok = True
for t in T:
    if t not in D:
        ok = False
    elif cntt[t] > cntd[t]:
        ok = False
if ok:
    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 m > n:
    print('NO')
    exit()
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())
dl = list(map(int, input().split()))
m = int(input())
tl = list(map(int, input().split()))

tl_s = list(set(tl))
for t in tl:
    if tl.count(t) <= dl.count(t):
        continue
    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()))
d.sort()
t.sort()
D=set(d)
T=set(t)
for i in T:
  if i not in D:
    print('NO')
    exit()
  else:
    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()))
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()))
di={}
ti={}
for i in range(m):
  if t[i] not in ti:
    ti[t[i]]=1
  else:
    ti[t[i]]+=1
  if t[i] not in di:
    di[t[i]]=d.count(t[i])
for i in ti:
  if ti[i]>di[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()))
s=set(t)
S=set(d)
if len(s)>len(S):
  print('NO')
  exit()
for i in s:
  if d.count(i)<t.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()))
s=set(t)
for i in s:
  if d.count(i)<t.count(i):
    print('NO')
    exit()
print('YES')

Submission status: Time Limit Exceeded

Solution code:
#38 B - Problem Set
N = int(input())
D = list(map(int,input().split()))
M = int(input())
T = list(map(int,input().split()))

result = 'YES'
for t in T:
    if not(t in D):
        result = 'NO'
        break
    D.remove(t)
print(result)

Submission status: Time Limit Exceeded

Solution code:
import bisect
N = int(input())
D = list(map(int, input().split()))
D.sort()
M = int(input())
T = list(map(int, input().split()))
for i in range(M):
    t = T[i]
    idx = min(bisect.bisect_left(D, t), len(D) - 1)
    d = D[idx]
    if t == d:
        D.pop(idx)
    else:
        print('NO')
        exit()
print('YES')

Submission status: Time Limit Exceeded

Solution code:
import bisect
N = int(input())
D = list(map(int, input().split()))
D.sort()
M = int(input())
T = list(map(int, input().split()))
for i in range(M):
    t = T[i]
    for j in range(N):
        idx = min(bisect.bisect_left(D, t), len(D) - 1)
        d = D[idx]
        if t == d:
            D.pop(idx)
            break
    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()))
D_flags = [True] * N
for i in range(M):
    t = T[i]
    for j in range(N):
        d = D[j]
        if t == d and D_flags[j]:
            D_flags[j] = False
            break
    else:
        print('NO')
        exit()
print('YES')

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
NNN = map(int,input().split())
NN = list(NNN)
M = int(input())
MMM = map(int,input().split())
MM = list(MMM)
jisyo = {}
for i in MM:
  if i not in jisyo:
    jisyo[i] = 1
  else:
    jisyo[i] +=1

for i in NN:
  for j,k in jisyo.items():
    if i == j:
      jisyo[j] -=1
      
count = 0

for j,k in jisyo.items():
  if k > 0:
    count +=1
if count > 0:
  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()))
ans = ''
for i in range(m):
  if t[i] in d:
    d.pop(d.index(t[i]))
  else:
    ans = 'NO'
    break
if ans == '':
  ans = 'YES'
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()))

flag = True
if N < M:
  flag = False
else:
  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 = list(map(int, input().split()))
M = int(input())
T = list(map(int, 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:
import bisect
 
n = int(input())
d = sorted(list(map(int,input().split())))
m = int(input())
t = list(map(int,input().split()))
d.append(10**9+1)

flg = True
for i in range(m):
  index = bisect.bisect_left(d,t[i])
  if t[i] == d[index]:
    del d[index]
  else:
    flg = False
    break
 
print('YES' if flg else 'NO')

Submission status: Time Limit Exceeded

Solution code:
import bisect

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

flg = True
for i in range(m):
  if t[-1]>d[-1]:
    flg = False
    break
  else:
    index = bisect.bisect_left(d,t[i])
    if t[i] == d[index]:
      del d[index]
    else:
      flg = False
      break

print('YES' if flg else 'NO')

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
D=list(map(int,input().split()))
D=sorted(D)
M=int(input())
T=list(map(int,input().split()))
T=sorted(T)
for num in T:
    if num in D:
        D.remove(num)
    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):
    try:
        z = d.index(t[i])
    except ValueError:
        print('NO')
        exit(0)
    else:
        d.pop(z)

print('YES')

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
input()
d = input().split()
input()
t = input().split()
a = sum(d.count(i) < t.count(i) for i in set(t))
print("YNEOS"[a > 0::2])