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:
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()
i=0
c=0
j=0
while i <M and c==0:
    while j <N and T[i]>D[j]:
        j+=1
    if j<N and T[i]==D[j]:
        D.pop(j)
        i+=1
    else:
        c=1
if c==0:
    p="YES"
else:
    p="NO"
print(p)

Submission status: Time Limit Exceeded

Solution code:
def check(list_a, a):
    if a in list_a:
        list_a.remove(a)
        return False
    else:
        return True

N = input()
D = [int(i) for i in input().split(" ")]
M = input()
T = ["NO" for i in input().split() if check(D,int(i))]
if T:
    print("NO")
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:
  fl=nlist.index(ml)
  nlist[fl]=0
 except ValueError:
  print "NO"
  flag=0
  break
if flag: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()]
D.sort()
i=0
c=0
while i <M and c==0:
    j=0
    while j <N and T[i]>D[j]:
        j+=1
    if j<N and T[i]==D[j]:
        D.pop(j)
        i+=1
    else:
        c=1
if c==0:
    p="YES"
else:
    p="NO"
print(p)

Submission status: Time Limit Exceeded

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:
        d = np.delete(d,int(list(np.where(d==i)[0])[0]),0)
    except IndexError:
        result = False
        break
print ("YES") if result else print("NO")

Submission status: Time Limit Exceeded

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])
        d = np.delete(d,index,0)
    else:
        result = False
        break
print ("YES") if result else print("NO")

Submission status: Time Limit Exceeded

Solution code:
mondai_num = int(input())
mondai_nums = [int(i) for i in input().split()]
need_num = int(input())
need_nums = [int(i) for i in input().split()]

need_nums_set = list(set(need_nums))


bool = True
for i in range(len(need_nums_set)):
    if need_nums.count(need_nums_set[i]) > mondai_nums.count(need_nums_set[i]):
        bool = False
        break


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

Submission status: Time Limit Exceeded

Solution code:
import bisect

N = int(input())
listD = list(map(int,input().split()))
listD.sort()
M = int(input())
listT = list(map(int,input().split()))
listT.sort()

flag = "YES"

def bsearch(seq,value):
    index = bisect.bisect_left(seq,value)
    if index >= len(seq) or seq[index] != value:
        return None
    return index

for _ in listT:
    if bsearch(listD,_) == None:
        flag = "NO"
        break
    else:
        listD.remove(_)

print(flag)

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.remove(T[i])
        ans.append(T[i])

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

Submission status: Time Limit Exceeded

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

if len(d) < len(t):
    print("NO")
    exit()

t_size = len(t)
t_sorted = sorted(t)
reg = [] 
for i in range(0, t_size-2):
    if t_sorted[i] == t_sorted[i+1]:
        reg.append(t_sorted[i])
    else:
        reg.append(t_sorted[i]+".*")

reg.append(t_sorted[t_size-1])

reg_pattern = re.compile("".join(reg));
match = re.search(reg_pattern,"".join(sorted(d)))    

if match:
    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 i in range(M):
    
    try:
        del D[D.index(T[i])]
    except:
        print('NO')
        break
        
else:
    print('YES')

Submission status: Time Limit Exceeded

Solution code:
mondai_num = int(input())
mondai_nums = [int(i) for i in input().split()]
need_num = int(input())
need_nums = [int(i) for i in input().split()]


bool = True
for i in range(need_num):
    if need_nums.count(need_nums[i]) > mondai_nums.count(need_nums[i]):
        bool = False


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

Submission status: Time Limit Exceeded

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

M = int(input().strip())
T = list(map(int, input().strip().split(" ")))
print(M, len(T), file=sys.stderr)

for t in T:
    if t not in D:
        print("NO")
        exit(0)
    D.remove(t)
print("YES")
exit(0)

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

result = True
for i in t:
    if i in d:
        d.remove(i)
    else:
        result = False
        break

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

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):
    
    try:
        del D[D.index(int(T[i]))]
    except:
        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()))
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:
        print("YES")

Submission status: Time Limit Exceeded

Solution code:
n = input()
d = input().split()
n = input()
t = input().split()
def p2(d,t):
    for i in t:
        try: d.remove(i)
        except: return("NO")
    return("YES")

print(p2(d,t))

Submission status: Time Limit Exceeded

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

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

    for i in T:
        if i in D:
            problem[i] -= 1
            if problem[i] < 0:
                ans = 'NO'
                break
        else:
            ans = 'NO'
            break
    else:
        ans = 'YES'

    print(ans)

main()

Submission status: Time Limit Exceeded

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

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

# D = [1, 2, 3]
# T = [1, 2, 3]
flg = True
for t in T:
    old_D = list(D)
    for i, d in enumerate(D):
        if t == d:
            D.pop(i)
            # print(D)
            # print(old_D)
            break
    if old_D == D:
        flg = False
        print('NO')
        break

if flg:
    print('YES')

Submission status: Time Limit Exceeded

Solution code:
n = input()
d = input().split()
n = input()
t = input().split()
def p2(d,t):
    for i in t:
        if i in d: d.remove(i)
        else: return("NO")
    return("YES")

print(p2(d,t))

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()]
x=0
for i in range(M):
    if T[i] in D:
        D.remove(T[i])
    else:
        x+=1
if x==0:
    print("YES")
else:
    print("NO")

Submission status: Time Limit Exceeded

Solution code:
n1=input()
a=input().split()

n2=input()

try:
    for i in input().split():
        a.remove(i)
except:
    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()))

D = sorted(D)
T = sorted(T)

res = 'YES'
for i in range(M):
    if T[i] in D:
        D.pop(D.index(T[i]))
    else :
        res = 'NO'
        break
print(res)

Submission status: Time Limit Exceeded

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:
    if len(d) == 0:
        frag = False
        break
    place = nibutan(tmp)
    if place == -1:
        frag = False
        break
    else:
        del d[place]

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
d = input().split()
m = int(input())
l = input().split()
ans = 0
for i in l:
    for k in d:
        if i == k:
            ans = ans +1
            d.remove(k)
            break
        else:
            continue
if ans == m:
    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()))

res = "YES"

for i in T:
  if i in D:
    D.remove(i)
  else:
    res = "NO"
    break

print(res)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
d = input().split()
m = int(input())
l = input().split()
ans = 0
for i in l:
    for k in d[:]:
        if i == k:
            ans = ans +1
            d.remove(k)
            break
        else:
            continue
if ans == m:
    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()))

count_T = Counter(T)

for num, cnt in count_T.most_common():
    if D.count(num) < cnt:
        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()))

result = True
for i in t:
    if i in d:
        d.remove(i)
    else:
        result = False

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

Submission status: Time Limit Exceeded

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
    else:
        del d[place]
if frag:
    print("YES")
else:
    print("NO")

Submission status: Time Limit Exceeded

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 D:
            D.remove(i)
        else:
            print("NO")
            sys.exit()
print("YES")

Submission status: Time Limit Exceeded

Solution code:
a = 0
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
for num in t:
    if not num in d:
        a = 1
        break
    else:
        b = d.index(num)
        d.pop(b)

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

Submission status: Time Limit Exceeded

Solution code:
value = int(input())
have_array = input().split()
have_array = [int(x) for x in have_array]

value2 = int(input())
problem_array = input().split()
problem_array = [int(x) for x in problem_array]


error = True
for i in range(0, value2):
    if have_array.count(problem_array[i]) < problem_array.count(problem_array[i]):
        error = False
        break
print("YES" if error == True else "NO")

Submission status: Time Limit Exceeded

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

Solution code:
#-*- coding: utf-8 -*-
 
import sys
 
n = int(raw_input())
d = map(int, raw_input().split())
m = int(raw_input())
t = map(int, raw_input().split())
ret = "YES"
 
if n < m:
    ret = "NO"
else:
    for i in range(m):
        if not t[i] in d:
            ret = "NO"
        else:
            d.remove(t[i])
 
print ret

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 :
    s = set(t)
    for ss in s :
        if d.count(ss) < t.count(ss) :
            print("NO")
            break
    else :
        print("YES")

Submission status: Time Limit Exceeded

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

            for t in T:
                if t in D:
                    D.remove(t)
                else:
                    print("NO")
                    raise EndLoop

            print("YES")
            break
        except:
            break


solve()

Submission status: Time Limit Exceeded

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)

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

for item in mvals:
    if item in nvals:
        nvals.remove(item)
    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()))

searched = []
if N < M:
    print('NO')
else:
    flag = True
    for i in range(M):
        if T[i] not 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: Time Limit Exceeded

Solution code:
from sys import stdin, stdout
def readLine_int_list():return list(map(int, stdin.readline().split()))
def main():
    n=int(input())
    d=readLine_int_list()
    m=int(input())
    t=readLine_int_list()
    
    set_d = set(d)
    set_t = set(t)
    ans = "YES"
    if len(set_t - set_d) > 0:
        ans = "NO"
    else:
        for i in set_t:
            t_cnt = t.count(i)
            d_cnt = d.count(i)
            if t_cnt - d_cnt > 0:
                ans = "NO"
    print(ans)
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

import sys

n = int(raw_input())
d = map(int, raw_input().split())
m = int(raw_input())
t = map(int, raw_input().split())
d.sort()
t.sort()
ret = "YES"

if n < m:
    ret = "NO"
else:
    for i in range(m):
        if not t[i] in d:
            ret = "NO"
        else:
            d.remove(t[i])

print ret

Submission status: Time Limit Exceeded

Solution code:
a = int(input())
b = input().split()
c = int(input())
d = input().split()
ans = "YES"
b.sort(key=int)
d.sort(key=int)
for i in range(c):
    if d[i] in b:
        b.remove(d[i])
    else:
        ans = "NO"
        break
print(ans)

Submission status: Time Limit Exceeded

Solution code:
value = int(input())
have_array = input().split()
have_array = [int(x) for x in have_array]

value2 = int(input())
problem_array = input().split()
problem_array = [int(x) for x in problem_array]

try:
    for i in range(0, value2):
        have_array.remove(problem_array[i])
except ValueError:
    print("NO")

if len(have_array) == value - len(problem_array):
    print("YES")

Submission status: Time Limit Exceeded

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


for t in T:
	while(D[0] < t):
		D.pop(0)
	if D[0] == t:
		D.pop(0)
	else:
		print("NO")
		exit(0)
print("YES")

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
ds=[int(s)for s in input().split(" ")]
m=int(input())
ts=[int(s)for s in input().split(" ")]
f=True
for t in ts:
    if t not in ds:
        print("NO")
        f=False
        break
    else:ds.pop(ds.index(t))
if 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()))

if n < m :
    print("NO")
else :
    for tt in t :
        if tt in d :
            idx = d.index(tt)
            d[idx] = -1
        else :
            print("NO")
            break
    else :
        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()))

result = True
for i in t:
    if i in d:
        d.remove(i)
    else:
        result = False

print ("YES") if result 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()))

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

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

Solution code:

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

flag = 1
for i in t:
    if i in d: d.remove(i)
    else: flag=0; break

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
D = input().split()
M = int(input())
T = input().split()
judge = 0

for t in T:
    if t in D:
        D.remove(t)
    else:
        judge = 1
        break

if judge == 0:
    print("YES")
else:
    print("NO")

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):
    if not int(T[i]) in D:
        print('NO')
        break
    else:
        del D[D.index(int(T[i]))]
else:
    print('YES')

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
a = int(input())
b = input().split()
c = int(input())
d = 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: Time Limit Exceeded

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
for s in t_set:
    if(d.count(s) < t.count(s)): flag = 1


if flag == 1:
    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()))

flag = 0
for i in range(m):
    if t[i] in d:
        d.remove(t[i])
    else:
        flag = 1
        break

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

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin, stdout
def readLine_int_list():return list(map(int, stdin.readline().split()))
def main():
    n=int(input())
    d=readLine_int_list()
    m=int(input())
    t=readLine_int_list()
    f = True
    for i in t:
        if i in d:
            d.pop(d.index(i))
        else:
            f = False
            break
    if f:
        print("YES")
    else:
        print("NO")
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
#!usr/bim/python
#! -*- coding: utf-8 -*-

n = raw_input()
n = int(n)

dl = raw_input()
dl = dl.split()
dl = map(int,dl)

m = raw_input()
m = int(m)

tl = raw_input()
tl = tl.split()
tl = map(int,tl)

status = 0

for t in tl:
    if t in dl:
        dl.remove(t)
    else:
        status = 1
        break

if status == 0:
    print "YES"
else:
    print "NO"

Submission status: Time Limit Exceeded

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

dic = {}

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

for a in dic:
  if dic[a] > d.count(a):
    print "NO"
    exit(0)

print "YES"

Submission status: Time Limit Exceeded

Solution code:
if __name__ == '__main__':
    N = int(input())
    D = [int(i) for i in input().split()]
    M = int(input())
    T = [int(j) for j in input().split()]
    for k in T:
        if k in D:
            D.remove(k)
        else:
            print('NO')
            exit(0)
    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")
        break
else:
    print("YES")

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
d = input().split()
m = int(input())
t = 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:
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: 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:
 if ml in nlist:
  nlist[nlist.index(ml)]=0
 else:
  flag=0
  print "NO"
  break
if flag:print "YES"

Submission status: Time Limit Exceeded

Solution code:
import bisect

def index(a, x):
    'Locate the leftmost value exactly equal to x'
    i = bisect.bisect_left(a, x)
    if i != len(a) and a[i] == x:
        return [1,i]
    return [0,0]


N=int(raw_input())
D=sorted(map(int, raw_input().split()))
M=int(raw_input())
T=sorted(map(int, raw_input().split()))

ans=["NO","YES"]
a=1

for t in T:
    [a,i]=index(D,t)
    if a==0: break
    D.pop(i)
print ans[a]

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 p in t:
    if p in d:
        i = d.index(p)
        d[i] = 0
    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()]

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

Submission status: Time Limit Exceeded

Solution code:
# def makelist(n, m):
#     return [[0 for i in range(m)] for j in range(n)]

# n = int(input())
# a, b = map(int, input().split())
# s = input()


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

D.sort()
T.sort()

i = 0
ans = "YES"
for e in T:
    while True:
        if i >= N:
            ans = "NO"
            break
        else:
            if D[i] != e:
                i += 1

    if ans == "NO":
        break
print(ans)

Submission status: Time Limit Exceeded

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

for i in t:
    if i in d:
        d.remove(i)

    else:
        print 'NO'
        sys.exit()

print 'YES'

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
listD = list(map(int,input().split()))
M = int(input())
listT = list(map(int,input().split()))

flag = "YES"
for _ in listT:
    if _ not in listD:
        flag = "NO"
        break
    else:
        listD.remove(_)
print(flag)

Submission status: Time Limit Exceeded

Solution code:
s=input()
s=input().split()
t=input()
t=input().split()
s.sort()
t.sort()
f=False
for c in t:
 if not c in s:
  print("NO")
  f=True
  break
 else:
  s.remove(c)
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()))

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

Submission status: Memory Limit Exceeded

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]*100000000

print('YES')

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

from collections import Counter

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

for k in t:
    if k not in d:
        print('NO')
        sys.exit(0)
    elif t[k] > d[k]:
        print('NO')
        sys.exit(0)
print('YES')

Submission status: Accepted

Solution code:
n = int(input())
D = tuple(map(int, input().split()))
m = int(input())
T = tuple(map(int, input().split()))

from collections import Counter
CD = Counter(D)
CT = Counter(T)
for t, ct in CT.items():
    cd = CD[t]
    if ct > cd:
        print('NO')
        break
else:
    print('YES')

Submission status: Accepted

Solution code:
import sys
n = int(input())
ls = list(map(int,input().split()))
m = int(input())
di = list(map(int,input().split()))
dic = {}
for i in range(n):
    if dic.get(ls[i],0) == 0:
        dic[ls[i]] = 1
    else:
        dic[ls[i]] += 1
for k in range(m):
    if dic.get(di[k],0) == 0:
        print("NO")
        sys.exit()
    else:
        dic[di[k]] -= 1
print("YES")

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
d = dict(Counter(list(map(int,input().split()))))
m = int(input())
t = list(map(int,input().split()))
check = True
for i in t:
  if i in d.keys():
    if d[i] > 0:
      d[i] -= 1
    else:
      check = False
      break
  else:
    check = False
    break
print("YES" if check else "NO")

Submission status: Accepted

Solution code:
import sys
import itertools
# import numpy as np
import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import permutations
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

cnt_d = Counter(D)
cnt_t = Counter(T)

for k, v in cnt_t.items():
    cnt_d[k] -= v
    if cnt_d[k] < 0:
        print("NO")
        exit()
print("YES")

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
M = int(input())
B = list(map(int, input().split()))
d = {}
for a in A:
  d[a] = d.get(a, 0) + 1
f = 0
for b in B:
  d[b] = d.get(b, 0) - 1
  if d[b] < 0:
    print("NO")
    f = 1
    break
if f == 0:
  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()))
p = {}
for j in d:
    if j not in p:
        p[j] = 1
    else:
        p[j] += 1
for i in t:
    if i not in p or p[i] == 0:
        print("NO")
        exit()
    p[i] -= 1
print("YES")

Submission status: Accepted

Solution code:
n = int(input())
D = list(map(int,input().split()))
m = int(input())
T = list(map(int,input().split()))

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

for t in T:
    if t not in p:
        print('NO')
        exit()
    if p[t] == 0:
        print('NO')
        exit()
    p[t] -= 1
    
print('YES')