Problem p03578 (python)

Fixed submission:
n = int(input())
list_d = list((map(int, input().split())))
m = int(input())
list_t = list((map(int, input().split())))

dict_d = {}
dict_t = {}
for number in set(list_d):
    dict_d[number] = 0
for number in set(list_t):
    dict_d[number] = 0
for number in list_d:
    dict_d[number] += 1

for number in set(list_t):
    dict_t[number] = 0
for number in list_t:
    dict_t[number] += 1

for number,value in dict_t.items():
    if dict_d[number] < value:
        print("NO")
        break
    else:
        pass
else:
    print("YES")

Buggy submission (verdict: Runtime Error):
def binarySearch(list_a, key):
    left = 0
    right = len(list_a)
    while left < right:
        mid = (left + right) // 2
        if list_a[mid] == key:
            return mid
            break
        elif key < list_a[mid]:
            right = mid
        else:
            left = mid+1
    else:
        return "NOT_FOUND"

def merge(list_a, left, mid, right):
    import math
    n1 = mid - left
    n2 = right - mid
    list_l = []
    list_r = []
    for i in range(0,n1):
        list_l.append(list_a[left + i])
    for i in range(0,n2):
        list_r.append(list_a[mid + i])
    list_l.append(math.inf)
    list_r.append(math.inf)
    i = 0
    j = 0
    for k in range(left,right):
        if list_l[i] <= list_r[j]:
            list_a[k] = list_l[i]
            i += 1
        else:
            list_a[k] = list_r[j]
            j += 1

def mergeSort(list_a, left, right):
    if left + 1 < right:
        mid = (left + right) //2
        mergeSort(list_a, left, mid)
        mergeSort(list_a, mid, right)
        merge(list_a, left, mid, right)


n = int(input())
list_d = list((map(int, input().split())))
m = int(input())
list_t = list((map(int, input().split())))

mergeSort(list_d, 0, n)
mergeSort(list_t, 0, m)
for number in list_t:
    ind = binarySearch(list_d, number)
    if ind != "NOT_FOUND":
        del list_d[ind]
    else:
        print("NO")
        break
else:
    print("YES")

Buggy submission (verdict: Runtime Error):
import math
def binarySearch(list_a, key):
    left = 0
    right = len(list_a)
    while left < right:
        mid = (left + right) // 2
        if list_a[mid] == key:
            return mid
            break
        elif key < list_a[mid]:
            right = mid
        else:
            left = mid+1
    else:
        return "NOT_FOUND"

def merge(list_a, left, mid, right):
    import math
    n1 = mid - left
    n2 = right - mid
    list_l = []
    list_r = []
    for i in range(0,n1):
        list_l.append(list_a[left + i])
    for i in range(0,n2):
        list_r.append(list_a[mid + i])
    list_l.append(math.inf)
    list_r.append(math.inf)
    i = 0
    j = 0
    for k in range(left,right):
        if list_l[i] <= list_r[j]:
            list_a[k] = list_l[i]
            i += 1
        else:
            list_a[k] = list_r[j]
            j += 1

def mergeSort(list_a, left, right):
    if left + 1 < right:
        mid = (left + right) //2
        mergeSort(list_a, left, mid)
        mergeSort(list_a, mid, right)
        merge(list_a, left, mid, right)


n = int(input())
list_d = list((map(int, input().split())))
m = int(input())
list_t = list((map(int, input().split())))

mergeSort(list_d, 0, n)

for number in list_t:
    ind = binarySearch(list_d, number)
    if ind != "NOT_FOUND":
        del list_d[ind]
    else:
        print("NO")
        break
else:
    print("YES")

Buggy submission (verdict: Runtime Error):
def binarySearch(list_a, key):
    left = 0
    right = len(list_a)
    while left < right:
        mid = (left + right) // 2
        if list_a[mid] == key:
            return mid
            break
        elif key < list_a[mid]:
            right = mid
        else:
            left = mid+1
    else:
        return "NOT_FOUND"

def merge(list_a, left, mid, right):
    import math
    n1 = mid - left
    n2 = right - mid
    list_l = []
    list_r = []
    for i in range(0,n1):
        list_l.append(list_a[left + i])
    for i in range(0,n2):
        list_r.append(list_a[mid + i])
    list_l.append(math.inf)
    list_r.append(math.inf)
    i = 0
    j = 0
    for k in range(left,right):
        if list_l[i] <= list_r[j]:
            list_a[k] = list_l[i]
            i += 1
        else:
            list_a[k] = list_r[j]
            j += 1

def mergeSort(list_a, left, right):
    if left + 1 < right:
        mid = (left + right) //2
        mergeSort(list_a, left, mid)
        mergeSort(list_a, mid, right)
        merge(list_a, left, mid, right)


n = int(input())
list_d = list((map(int, input().split())))
m = int(input())
list_t = list((map(int, input().split())))

mergeSort(list_d, 0, n)
for number in list_t:
    ind = binarySearch(list_d, number)
    if ind != "NOT_FOUND":
        del list_d[ind]
    else:
        print("NO")
        break
else:
    print("YES")

Buggy submission (verdict: Runtime Error):
def binarySearch(list_a, key):
    left = 0
    right = len(list_a)
    while left < right:
        mid = (left + right) // 2
        if list_a[mid] == key:
            return mid
            break
        elif key < list_a[mid]:
            right = mid
        else:
            left = mid+1
    else:
        return "NOT_FOUND"

def merge(list_a, left, mid, right):
    import math
    n1 = mid - left
    n2 = right - mid
    list_l = []
    list_r = []
    for i in range(0,n1):
        list_l.append(list_a[left + i])
    for i in range(0,n2):
        list_r.append(list_a[mid + i])
    list_l.append(math.inf)
    list_r.append(math.inf)
    i = 0
    j = 0
    for k in range(left,right):
        if list_l[i] <= list_r[j]:
            list_a[k] = list_l[i]
            i += 1
        else:
            list_a[k] = list_r[j]
            j += 1

def mergeSort(list_a, left, right):
    if left + 1 < right:
        mid = (left + right) //2
        mergeSort(list_a, left, mid)
        mergeSort(list_a, mid, right)
        merge(list_a, left, mid, right)


n = int(input())
list_d = list((map(int, input().split())))
m = int(input())
list_t = list((map(int, input().split())))

mergeSort(list_d, 0, n)
for number in list_t:
    ind = binarySearch(list_d, number)
    if ind != "NOT_FOUND":
        del list_d[ind]
    else:
        print("NO")
        break
else:
    print("YES")