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:
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))
d.sort()
t.sort()
i,j=0,0
while i<m:
  if t[i]<d[j]:
    print("NO")
    exit()
  elif t[i]==d[j]:
    i+=1
    j+=1
  else:
    j+=1
  if j==n:
    print("NO")
    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()))

from collections import Counter
cd = Counter(d)
ct = Counter(t)

for tt in ct.items():
    if tt[1] > cd[tt[0]]:
        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()))
if D<=T:
  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 D<=T:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
d_ = [int(i) for i in input().split()]
m = int(input())
t_ = [int(i) for i in input().split()]
d = collections.Counter(d_)
t = collections.Counter(t_)
for ti in t:
    if d[ti] == 0:
        print("NO")
        exit()
    else:
        d[ti] -= 1
print("YES")

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
m=int(input())
pl=list(map(int,input().split()))
for i in list(pl):
  if not i in set(l):
    print('NO')
    break
  else:
    l.remove(i)
  if i==pl[-1]:
    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.sort()
T.sort()
if n>=m:
    if D==T:
        print('YES')
        exit()
    else:
        print('NO')
        exit()

r = 'YES'
for i in range(m):
    if T[i] in D:
        idx = D.index(T[i])
        D = D[idx+1:]
    else:
        r = 'NO'
        break
print(r)

Submission status: Wrong Answer

Solution code:
import collections

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

is_subset = D >= T
if is_subset:
  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()))

D.sort()
T.sort()
ans = 'YES'

if (len(D) >= len(T)):
  for i in range(len(T)):
    if (D[i] != T[i]):
      ans = 'NO'
      break
else:
  ans = 'NO'
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))
Flg = "YES"

c1 = Counter(D)
c2 = Counter(T)

for i, val in c2.items():
    if(c1[i] < val):
        Flg = "No"
        break
print(Flg)

Submission status: Wrong Answer

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

dic = {}
for d in D:
    if d in dic.keys():
        dic[d] += 1
    else:
        dic[d] = 1

for t in T:
    if t in dic.keys():
        if dic[t] == 0:
            print('No')
            exit()
        dic[t] -= 1
    else:
        print('No')
        exit()

print('Yes')

Submission status: Wrong Answer

Solution code:
from re import search

N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))
flag = True
for i in range(M):
    if not T[i] in D:
        flag = False
        break
if flag:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
import collections
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))
dd,tt=collections.Counter(d),collections.Counter(t)
for k,v in tt.items():
  if dd.get(k)==None:
    print("NO")
    exit()
  elif dd.get(k)>=v:
    print("NO")
    exit()
print("YES")

Submission status: Wrong Answer

Solution code:
from collections import Counter
import sys

N = int(input())
D = list(input().split())

M = int(input())
T = list(input().split())

D_count = Counter(D)
T_count = Counter(T)

for k in T_count:
    try:
        if D_count[k] < T_count[k]:
            print('NO')
            sys.exit()
    except:
        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()))

from collections import Counter

a=Counter(D)
b=Counter(T)

for keys in b:
  if keys not in a:
    print("No")
    break
  else:
    if b[keys]>a[keys]:
      print("No")
      break
else:
  print("Yes")

Submission status: Wrong Answer

Solution code:
import collections

n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))

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

c = collections.Counter(a)
d = collections.Counter(b)

for i, j in d.items():
    for x, y in c.items():
        flag = False
        if i == x and j > y:
            print('NO')
            exit()
        elif i == x:
            flag = True
    if flag is False:
        print('NO')
        exit()

print('YES')

Submission status: Wrong Answer

Solution code:
import collections

n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))

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

c = collections.Counter(a)
d = collections.Counter(b)

for i, j in c.items():
    for x, y in d.items():
        flag = False
        if i == x and j < y:
            print('NO')
            exit()
        elif i == x:
            flag = True
    if flag is False:
        print('NO')
        exit()

print('YES')

Submission status: Wrong Answer

Solution code:
import collections

n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))

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

c = collections.Counter(a)
d = collections.Counter(b)

for i, j in c.items():
    for x, y in d.items():
        if i == x:
            if j < y:
                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 = sorted(d)
t = sorted(t)

left = 0
ans = 'YES'
for i in range(m):
    if t[i] < d[left]:
        ans='NO'
        break
    elif t[i] == d[left]:
        left+=1
        if i!= m-1 and left >=n:
            ans = 'NO'
            break
    else:
        while t[i] != d[left]:
            left+=1
            if left == n:
                break
        if left==n:
            ans = 'NO'
            break
print(ans)

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 = sorted(d)
t = sorted(t)

left = 0
ans = 'YES'
for i in range(m):
    if t[i] < d[left]:
        ans='NO'
        break
    elif t[i] == d[left]:
        left+=1
        if i!= m-1 and left >=n:
            ans = 'NO'
    else:
        left+=1
        if left>=n:
            ans = 'NO'
print(ans)

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 = sorted(d)
t = sorted(t)

left = 0
ans = 'Yes'
for i in range(m):
    if t[i] < d[left]:
        ans='No'
        break
    elif t[i] == d[left]:
        left+=1
        if i!= m-1 and left >=n:
            ans = 'No'
    else:
        left+=1
        if left>=n:
            ans = 'No'
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
D = sorted(list(map(int,input().split())))
M = int(input())
T = sorted(list(map(int,input().split())))
cur = 0
flag = 0
for i in range(N):
    if cur<M and D[i]==T[cur]:
        cur += 1
    elif cur<M and D[i]<T[cur]:
        continue
    else:
        flag = 1
        break
if flag==0:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

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

flag = 1
for elem in t:
    try:
        x = d.index(elem)
    except ValueError:
        flag = 0
        break
    d.remove(elem)

if flag == 0:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

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

j=0
for i in range(len(t)):
  if j==len(d):
    print("NO")
    break
  if t[i]==d[j]:
    j+=1
else:
  print("YES")

Submission status: Wrong Answer

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

grA = dict(collections.Counter(d))
grB = dict(collections.Counter(t))
#print(grA,grB)

for numB,cntB in grB.items():
  #print(numB,grA[numB])
  try:
    if grA[numB] < cntB:
      print("No")    
      exit()
  except KeyError:
    print("No")    
    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()))


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


for i in T:
    if List.get(i,None)==None:
        print("NO")
        exit()
    else:
        List[i]=-1
        

print("YES")

Submission status: Wrong Answer

Solution code:
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n = int(input().rstrip('\n'))
    d = sorted(list(map(int, input().rstrip('\n').split())))
    m = int(input().rstrip('\n'))
    t = sorted(list(map(int, input().rstrip('\n').split())))
    cur = 0
    for i in range(m):
        for j in range(cur, n):
            if t[i] == d[j]:
                if i + 1 >= m:
                    print("YES")
                    exit()
                else:
                    cur = j + 1
                    break
    print("NO")


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
from sys import stdin
N = int(stdin.readline().rstrip())
D = [int(x) for x in stdin.readline().rstrip().split()]
M = int(stdin.readline().rstrip())
T = [int(x) for x in stdin.readline().rstrip().split()]
S = set(D)&set(T)
if S == set(T):
    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()))

for i in range(m):
    if d.count(t[i])==t.count(t[i]):
        continue
    else:
        print("NO")
        exit()
print("YES")

Submission status: Wrong Answer

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

for i in range(m):
    if d.count(t[i])==t.count(t[i]):
        continue
    else:
        print("NO")
        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()))

for i in range(m):
    if t[i] in d:
        d.remove(t[i])
    else:
        print("No")
        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()))

dicD = {}
dicT = {}

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

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

for t in dicT:
    if t not in dicD:
        print("NO")
    elif dicT[t] > dicD[t]:
        print("NO")
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()))

dicD = {}
dicT = {}

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

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

for t in dicT:
    if (t not in dicD) or (dicT[t] > dicD[t]):
        print("NO") 
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()]
x = [0]*n
import sys
for i in t:
    if not i in d:
        print('NO')
        sys.exit()
    x[d.index(i)] += 1
print('YES') if max(x) == 1 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()))

for i in t:
  if i not in d:
    print("NO")
    exit()

print("YES")

Submission status: Wrong Answer

Solution code:
from collections import Counter
n=int(input())
ln=list(map(int,input().split()))
m=int(input())
lm=list(map(int,input().split()))
d=dict(Counter(ln))
for i in lm:
    try:
        if d[i]>=1:d[i]-=1
        else:print("NO");exit()
    except:print("NO");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()))

ans = "Yes"
for i in range(m):
    try:
        d.remove(t[i])    
    except ValueError:
        ans = "No"
        break
print(ans)

Submission status: Wrong Answer

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

  print(ans)

main()

Submission status: Wrong Answer

Solution code:
def quick_sort(arr):
  left = []
  right = []
  if len(arr) <= 1:
    return arr

  # データの状態に左右されないためにrandom.choice()を用いることもある。
  # ref = random.choice(arr)
  ref = arr[0]
  ref_count = 0

  for ele in arr:
    if ele < ref:
      left.append(ele)
    elif ele > ref:
      right.append(ele)
    else:
      ref_count += 1
  left = quick_sort(left)
  right = quick_sort(right)
  return left + [ref] * ref_count + right

n = int(input())
ds = quick_sort(list(map(int,input().split())))
m = int(input())
ts = quick_sort(list(map(int,input().split())))
i = 0
for t in ts:
  for j in range(len(ds)):
    if ds[j+i]==t:
      ds.pop(j+i)
      i = j+i-1
      break
    elif ds[j+i] < t:
      continue
    else:
      print('NO')
      exit(0)
print('YES')

Submission status: Wrong Answer

Solution code:
def quick_sort(arr):
  left = []
  right = []
  if len(arr) <= 1:
    return arr

  # データの状態に左右されないためにrandom.choice()を用いることもある。
  # ref = random.choice(arr)
  ref = arr[0]
  ref_count = 0

  for ele in arr:
    if ele < ref:
      left.append(ele)
    elif ele > ref:
      right.append(ele)
    else:
      ref_count += 1
  left = quick_sort(left)
  right = quick_sort(right)
  return left + [ref] * ref_count + right

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

for t in ts:
  for d in ds:
    if d==t:
      ds.remove(t)
    elif d < t:
      continue
    else:
      print('NO')
      exit(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()))
D.sort()
def find(a, i):
    l = 0
    r = len(a)-1
    mid = (l+r)//2
    while l <= r:
        if i == a[mid]:
            return mid
        elif i < a[mid]:
            r = mid - 1
        else:
            l = mid + 1
        mid = (l+r)//2
    return -1

for i in range(M):
    j = find(D, T[i])
    if j == -1:
        print("NO")
        exit(0)
    
print("YES")

Submission status: Wrong Answer

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
print("YES" if T.count(0)==M else "NO")

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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

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

Submission status: Wrong Answer

Solution code:
import bisect

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

d.sort()
t.sort()

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

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

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

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

Submission status: Wrong Answer

Solution code:
import bisect

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

d.sort()
t.sort()

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

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

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

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

Submission status: 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()

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

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

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))
if T in 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()))
for i in T:
	if i in D:
		D.remove(i)
	else:
		print("No")
		exit()
print("Yes")

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
Ds = list(map(int,input().split()))
M = int(input())
Ts = list(map(int,input().split()))

sDs = [-1]+sorted(Ds)
sTs = sorted(Ts)

print(sDs)
print(sTs)
# flg = True
ind = 0
for t in sTs:
    flg = False
    for j in range(ind+1,len(sDs)):
        if sDs[j] == t:
            ind = j
            flg = True
            break
    if not flg:
        print("NO")
        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()))
d.sort()
t.sort()
di=0
f=0
for ti in range(m):
    if di<n:
        while d[di]!=t[ti]:
            if d[di]>t[ti]:
                f=1
                break
            di+=1
    if f==1:
        break
if f==1:
    print('NO')
else:
    print('YES')

Submission status: Wrong Answer

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

Solution code:
n=int(input())
d=dict()
for a in map(int,input().split()):
  if a not in d:
    d[a]=1
  else:
    d[a]+=1
m=int(input())
t=dict()
for a in map(int,input().split()):
  if a not in t:
    t[a]=1
  else:
    t[a]+=1
  if a not in d:
    d[a]=0
ans="YES"
for i in t.keys():
  if not t[i]==d[i]:
    ans="NO"
print(ans)

Submission status: Wrong Answer

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
        break

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

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

dic_D = {} 
for d in D:
    dic_D[d] = dic_D.get(d,0) + 1
dic_T = {}
for t in T:
    dic_T[t] = dic_T.get(t,0) + 1
    
for k in dic_T:
    if dic_T[k]>dic_D.get(k,0):
        print("YES")
        break
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.sort()
def binary_search(x, first, end):
    global D
    if x<D[first] or D[end]<x:
        return -1
    middle = (first+end)//2
    if middle == first:
        if x == D[middle]:
            return middle
        elif x == D[end]:
            return end
        else:
            return -1
    if x>=D[middle]:
        return binary_search(x, middle, end)
    else:
        return binary_search(x, first, middle)

for m in range(M):
    index = binary_search(T[m],0,N-1)
    if index==-1:
        print('No')
        exit()
    del D[index]
    N -= 1
    

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 t:
  if i in d:
    d.remove(i)
  else:
    print("NO")
print("YES")

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input().split()
m=int(input())
for t in input().split():
    if t in s:
        s.remove(t)
        continue
    else:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input().split()
m=int(input())
for t in input().split():
    if t in s:
        continue
    else:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
def intersect_list(lst1, lst2):
    arr = []
    lst = lst1.copy()
    for element in lst2:
        try:
            lst.remove(element)
        except ValueError:
            pass
        else:
            arr.append(element)
    return arr


n = int(input())
d = list(int(i) for i in input().split())
m = int(input())
t = list(int(i) for i in input().split())
array = intersect_list(t,d)
t.sort()
if array == t:print('YES')
else: print(array)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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()
    print('Yes')

Submission status: Wrong Answer

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

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])
            break
 
if len(Z) < len(T):
    print("NO")
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()))

Z = []
for i in range(N):
    for j in range(M):
        if D[i] == T[j]:
            Z.append(T[j])
            break

if len(Z) < len(T):
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter
candnum=int(input())
candiff=list(map(int,input().split()))
pronum=int(input())
candiff=Counter(candiff)
prodiff=list(map(int,input().split()))
prodiff=Counter(candiff)

for k,v in prodiff.items():
    if k in candiff:
        if candiff[k]<v:
            print("NO")
            sys.exit()
    else:
        print("NO")
        sys.exit()
print("YES")

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter
candnum=int(input())
candiff=list(map(int,input().split()))
pronum=int(input())
candiff=Counter(candiff)
prodiff=list(map(int,input().split()))
prodiff=Counter(candiff)
if pronum>candnum:
    print("NO")
    sys.exit()
for k,v in prodiff.items():
    if k in candiff:
        if candiff[k]<v:
            print("NO")
            sys.exit()
    else:
        print("NO")
        sys.exit()
print("YES")

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter
candnum=int(input())
candiff=list(map(int,input().split()))
pronum=int(input())
candiff=Counter(candiff)
prodiff=list(map(int,input().split()))
prodiff=Counter(candiff)
if pronum>candnum:
    print("NO")
    sys.exit()
#print(candnum)
print(candiff)
#print(pronum)
print(prodiff)
'''
while candnum>=1 and pronum>=1:
    if candiff[candnum-1]<prodiff[pronum-1]:
        print("NO")
        sys.exit()
    candnum-=1
    pronum-=1

print("YES")
sys.exit()
'''
#print(candiff)
#print(prodiff)
for k,v in prodiff.items():
    if k in candiff:
        if candiff[k]<v:
            print("NO")
            sys.exit()
    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.sort()
T.sort()
i = 0
j = 0
while True:
    if i >= len(T) or j >= len(D):
        break
    ans = 0
    while True:
        if j >= len(D):
            break
        if T[i] == D[j]:
            ans = 1
            j += 1
            break
        j += 1
    if ans == 0:
        break
    i += 1
            
if ans == 1:
    print("Yes")
elif ans == 0:
    print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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()]
dc,tc,flag = Counter(d),Counter(t),True
for i in tc.most_common():
	if i[0] not in d:
		flag = False
		break
	elif i[1]>dc[i[0]]:
		flag = False
		break
if flag: 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()))
for i in T:
    if i in D:
        D.pop(D.index(i))
    else:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

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
        i = len(t)-1
            
print('YES' if sum(t) == 0 else 'NO')