Buggy python submission (verdict: Time Limit Exceeded):
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()]

d = Counter(D)
t = Counter(T)
d_key = d.keys()
t_key = t.keys()

for i in t_key:
    if i not in d_key or t[i] > d[i]:
        print('NO')
        exit()

print('YES')


Fixed submission:
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()]

d = Counter(D)
t = Counter(T)
d_key = list(d.keys())
t_key = list(t.keys())

p = len(d_key)
d_key += t_key
q = set(d_key)

if p != len(q):
    print('NO')
    exit()

for i in t_key:
    if t[i] > d[i]:
        print('NO')
        exit()

print('YES')

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

N = int(input())
D = [int(i) for i in input().split()]
d = set(D)
M = int(input())
T = [int(i) for i in input().split()]

dict_d = {}
for i in d:
    dict_d[i] = D.count(i)

for i in T:
    if i not in d:
        print('NO')
        exit()
    else:
        if dict_d[i] > 0:
            dict_d[i] -= 1
        else:
            print('NO')
            exit()

print('YES')


Fixed submission:
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()]

d = Counter(D)
t = Counter(T)
d_key = list(d.keys())
t_key = list(t.keys())

p = len(d_key)
d_key += t_key
q = set(d_key)

if p != len(q):
    print('NO')
    exit()

for i in t_key:
    if t[i] > d[i]:
        print('NO')
        exit()

print('YES')

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
D = [int(i) for i in input().split()]
d = set(D)
M = int(input())
T = [int(i) for i in input().split()]

dict_d = {}
for i in d:
    dict_d[i] = D.count(i)

for i in T:
    if i not in d:
        print('NO')
        exit()
    else:
        if dict_d[i] > 0:
            dict_d[i] -= 1
        else:
            print('NO')
            exit()

print('YES')


Fixed submission:
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()]

d = Counter(D)
t = Counter(T)
d_key = list(d.keys())
t_key = list(t.keys())

p = len(d_key)
d_key += t_key
q = set(d_key)

if p != len(q):
    print('NO')
    exit()

for i in t_key:
    if t[i] > d[i]:
        print('NO')
        exit()

print('YES')

Buggy python submission (verdict: Time Limit Exceeded):
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 not in D:
        print('NO')
        exit()
    else:
        D.remove(i)

print('YES')


Fixed submission:
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()]

d = Counter(D)
t = Counter(T)
d_key = list(d.keys())
t_key = list(t.keys())

p = len(d_key)
d_key += t_key
q = set(d_key)

if p != len(q):
    print('NO')
    exit()

for i in t_key:
    if t[i] > d[i]:
        print('NO')
        exit()

print('YES')