Buggy python submission (verdict: Runtime Error):
import heapq

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

heapq.heapify(d)
heapq.heapify(t)
cnt=0

if n>1 and m>1:
    for i in range(m):
        a=heapq.heappop(t)
        if len(b)>0:
            b=heapq.heappop(d)
        #print(a,b,cnt)
        while b<a and len(b)>0:
            b=heapq.heappop(d)
        if b==a:
            cnt+=1
    if cnt==m:
        print("YES")
    else:
        print("NO")

else:
    if n==1:
        if m==1 and t[0]==d[0]:
            print("YES")
        else:
            print("NO")
    else:
        if t[0] in d:
            print("YES")
        else:
            print("NO")
        

        
        

Fixed submission:
import heapq

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

heapq.heapify(d)
heapq.heapify(t)
cnt=0


if n>1 and m>1:
    for i in range(m):
        a=heapq.heappop(t)
        if len(d)>0:
            b=heapq.heappop(d)
        #print(a,b,cnt)
        while b<a and len(d)>0:
            b=heapq.heappop(d)
        if b==a:
            cnt+=1
    if cnt==m:
        print("YES")
    else:
        print("NO")

else:
    if n==1:
        if m==1 and t[0]==d[0]:
            print("YES")
        else:
            print("NO")
    else:
        if t[0] in d:
            print("YES")
        else:
            print("NO")

Buggy python submission (verdict: Runtime Error):
import heapq

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

heapq.heapify(d)
heapq.heapify(t)
cnt=0

if n>1 and m>1:
    for i in range(m):
        a=heapq.heappop(t)
        b=heapq.heappop(d)
        #print(a,b,cnt)
        while b<a:
            b=heapq.heappop(d)
        if b==a:
            cnt+=1
    if cnt==m:
        print("YES")
    else:
        print("NO")

else:
    if n==1:
        if m==1 and t[0]==d[0]:
            print("YES")
        else:
            print("NO")
    else:
        if t[0] in d:
            print("YES")
        else:
            print("NO")
        

        
        

Fixed submission:
import heapq

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

heapq.heapify(d)
heapq.heapify(t)
cnt=0


if n>1 and m>1:
    for i in range(m):
        a=heapq.heappop(t)
        if len(d)>0:
            b=heapq.heappop(d)
        #print(a,b,cnt)
        while b<a and len(d)>0:
            b=heapq.heappop(d)
        if b==a:
            cnt+=1
    if cnt==m:
        print("YES")
    else:
        print("NO")

else:
    if n==1:
        if m==1 and t[0]==d[0]:
            print("YES")
        else:
            print("NO")
    else:
        if t[0] in d:
            print("YES")
        else:
            print("NO")

Buggy python submission (verdict: Runtime Error):
import heapq

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

heapq.heapify(d)
heapq.heapify(t)
cnt=0

if n>1 and m>1:
    for i in range(m):
        a=heapq.heappop(t)
        b=heapq.heappop(d)
        #print(a,b,cnt)
        while b<a:
            b=heapq.heappop(d)
        if b==a:
            cnt+=1
    if cnt==m:
        print("YES")
    else:
        print("NO")

else:
    if n==1:
        print("NO")
    else:
        if t[0] in d:
            print("YES")
        else:
            print("NO")
        

        
        

Fixed submission:
import heapq

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

heapq.heapify(d)
heapq.heapify(t)
cnt=0


if n>1 and m>1:
    for i in range(m):
        a=heapq.heappop(t)
        if len(d)>0:
            b=heapq.heappop(d)
        #print(a,b,cnt)
        while b<a and len(d)>0:
            b=heapq.heappop(d)
        if b==a:
            cnt+=1
    if cnt==m:
        print("YES")
    else:
        print("NO")

else:
    if n==1:
        if m==1 and t[0]==d[0]:
            print("YES")
        else:
            print("NO")
    else:
        if t[0] in d:
            print("YES")
        else:
            print("NO")

Buggy python submission (verdict: Runtime Error):
import heapq

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

heapq.heapify(d)
heapq.heapify(t)
cnt=0

for i in range(m):
    a=heapq.heappop(t)
    b=heapq.heappop(d)
    #print(a,b,cnt)
    while b<a:
        b=heapq.heappop(d)
    if b==a:
        cnt+=1
        
    
if cnt==m:
    print("YES")
else:
    print("NO")
        

Fixed submission:
import heapq

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

heapq.heapify(d)
heapq.heapify(t)
cnt=0


if n>1 and m>1:
    for i in range(m):
        a=heapq.heappop(t)
        if len(d)>0:
            b=heapq.heappop(d)
        #print(a,b,cnt)
        while b<a and len(d)>0:
            b=heapq.heappop(d)
        if b==a:
            cnt+=1
    if cnt==m:
        print("YES")
    else:
        print("NO")

else:
    if n==1:
        if m==1 and t[0]==d[0]:
            print("YES")
        else:
            print("NO")
    else:
        if t[0] in d:
            print("YES")
        else:
            print("NO")