Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
import bisect
import sys
input=sys.stdin.readline
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))
ans='NO'
d.sort()
for i in range(m):
    if i>0:
        if t[i]==t[i-1]:
            cnt-=1
            if d[cnt]==t[i]:
                d.pop(cnt)
                if i==m-1:
                    ans='YES'
            else:
                break
        else:
            cnt=bisect.bisect_right(d,t[i])-1
            if d[cnt]==t[i]:
                d.pop(cnt)
                if i==m-1:
                    ans='YES'
            else:
                break
    else:
        cnt=bisect.bisect_right(d,t[i])-1
        if d[cnt]==t[i]:
            d.pop(cnt)
            if i==m-1:
                ans='YES'
        else:
            break
print(ans)


Fixed submission:
from collections import Counter
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))

d_c=Counter(d)
t_c=Counter(t)
for i in t_c.keys():
    if t_c[i]>d_c[i]:
        print('NO')
        exit()
print('YES')

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
import bisect
import sys
input=sys.stdin.readline
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))
ans='NO'
d.sort()
for i in range(m):
    cnt=bisect.bisect_right(d,t[i])-1
    if d[cnt]==t[i]:
        d.pop(cnt)
        if i==m-1:
            ans='YES'
    else:
        break
print(ans)


Fixed submission:
from collections import Counter
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))

d_c=Counter(d)
t_c=Counter(t)
for i in t_c.keys():
    if t_c[i]>d_c[i]:
        print('NO')
        exit()
print('YES')

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
import bisect
import sys
input=sys.stdin.readline
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))
ans='NO'
d.sort()
for i in range(m):
    cnt=bisect.bisect_right(d,t[i])-1
    if d[cnt]==t[i]:
        d.pop(cnt)
        if i==m-1:
            ans='YES'
    else:
        break
print(ans)


Fixed submission:
from collections import Counter
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))

d_c=Counter(d)
t_c=Counter(t)
for i in t_c.keys():
    if t_c[i]>d_c[i]:
        print('NO')
        exit()
print('YES')

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
import bisect
import sys
input=sys.stdin.readline
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))
ans='NO'
d.sort()
for i in range(m):
    if d[bisect.bisect_right(d,t[i])-1]==t[i]:
        d.pop(bisect.bisect_right(d,t[i])-1)
        if i==m-1:
            ans='YES'
    else:
        break
print(ans)


Fixed submission:
from collections import Counter
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))

d_c=Counter(d)
t_c=Counter(t)
for i in t_c.keys():
    if t_c[i]>d_c[i]:
        print('NO')
        exit()
print('YES')

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
import bisect
import sys
input=sys.stdin.readline
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))
ans='NO'
d.sort()
for i in range(m):
    if d[bisect.bisect_right(d,t[i])-1]==t[i]:
        d.remove(t[i])
        if i==m-1:
            ans='YES'
    else:
        break
print(ans)


Fixed submission:
from collections import Counter
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))

d_c=Counter(d)
t_c=Counter(t)
for i in t_c.keys():
    if t_c[i]>d_c[i]:
        print('NO')
        exit()
print('YES')

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
import bisect
import sys
input=sys.stdin.readline
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))
ans='NO'
d.sort()
for i in range(m):
    if d[bisect.bisect_right(d,t[i])-1]==t[i]:
        d.remove(d[bisect.bisect_right(d,t[i])-1])
        if i==m-1:
            ans='YES'
    else:
        break
print(ans)


Fixed submission:
from collections import Counter
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))

d_c=Counter(d)
t_c=Counter(t)
for i in t_c.keys():
    if t_c[i]>d_c[i]:
        print('NO')
        exit()
print('YES')

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
import bisect
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))
ans='NO'
d.sort()
for i in range(m):
    if d[bisect.bisect_right(d,t[i])-1]==t[i]:
        d.remove(d[bisect.bisect_right(d,t[i])-1])
        if i==m-1:
            ans='YES'
    else:
        break
print(ans)


Fixed submission:
from collections import Counter
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))

d_c=Counter(d)
t_c=Counter(t)
for i in t_c.keys():
    if t_c[i]>d_c[i]:
        print('NO')
        exit()
print('YES')