Buggy python submission (verdict: Time Limit Exceeded):
import sys

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

d.sort()

def solve(num,s,l):
	if s == l:
		if d[s] == num:
			return s
		else:
			return -1
	elif s+1 == l:
		if d[s] == num:
			return s
		elif d[l] == num:
			return l
		else:
			return -1

	c = s + (l-s)//2
	if d[c] == num:
		return c
	elif d[c] < num:
		return solve(num,c,l)
	else:
		return solve(num,s,c)

for i in range(m):
	A = solve(t[i],0,n-1)
	if A == -1:
		print("NO")
		sys.exit()
	else:
		d.pop(A)
		n -= 1

print("YES")

Fixed submission:
import sys
import collections as c
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 test in T.keys():
	if D[test] >= T[test]:
		continue
	else:
		print("NO")
		sys.exit()

print("YES")

Buggy python submission (verdict: Time Limit Exceeded):
import sys

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

d.sort()

def solve(num,s,l):
	if s == l:
		if d[s] == num:
			return s
		else:
			return -1
	elif s+1 == l:
		if d[s] == num:
			return s
		elif d[l] == num:
			return l
		else:
			return -1

	c = s + (l-s)//2
	if d[c] == num:
		return c
	elif d[c] < num:
		return solve(num,c,l)
	else:
		return solve(num,s,c)

for i in range(m):
	A = solve(t[i],0,n-1)
	if A == -1:
		print("NO")
		sys.exit()
	else:
		d.pop(A)
		n -= 1

print("YES")

Fixed submission:
import sys
import collections as c
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 test in T.keys():
	if D[test] >= T[test]:
		continue
	else:
		print("NO")
		sys.exit()

print("YES")

Buggy python submission (verdict: Time Limit Exceeded):
import sys

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

d.sort()
t.sort()
cond = 1
cnt = 0
for i in range(m):
	tmp_t = t[i]
	while d != []:
		tmp_d = d.pop(0)
		if tmp_d < tmp_t:
			continue
		elif tmp_d == tmp_t:
			cnt += 1
			break
		else:
			cond = 0
			break
	if cond == 0:
		print("NO")
		sys.exit()

if cnt == m:
	print("YES")
else:
	print("NO")

Fixed submission:
import sys
import collections as c
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 test in T.keys():
	if D[test] >= T[test]:
		continue
	else:
		print("NO")
		sys.exit()

print("YES")

Buggy python submission (verdict: Time Limit Exceeded):
import sys

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

d.sort()
t.sort()
cond = 1
cnt = 0
for i in range(m):
	tmp_t = t[i]
	while d != []:
		tmp_d = d.pop(0)
		if tmp_d < tmp_t:
			continue
		elif tmp_d == tmp_t:
			cnt += 1
			break
		else:
			cond = 0
			break
	if cond == 0:
		print("NO")
		sys.exit()

if cnt == m:
	print("YES")
else:
	print("NO")

Fixed submission:
import sys
import collections as c
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 test in T.keys():
	if D[test] >= T[test]:
		continue
	else:
		print("NO")
		sys.exit()

print("YES")