from bisect import bisect_left, bisect_right


def count_by_range(array, left_value, right_value):
    right_index = bisect_right(array, right_value)
    left_index = bisect_left(array, left_value)
    return right_index - left_index


array = [1, 2, 3, 3, 3, 3, 4, 4, 8, 9]
print(count_by_range(array, 4, 4))
print(count_by_range(array, -1, 3))

9a07d0c32b99dc885c4e61c814d7ddf981a0e57e
<mask token>


def count_by_range(array, left_value, right_value):
    right_index = bisect_right(array, right_value)
    left_index = bisect_left(array, left_value)
    return right_index - left_index


<mask token>

<mask token>


def count_by_range(array, left_value, right_value):
    right_index = bisect_right(array, right_value)
    left_index = bisect_left(array, left_value)
    return right_index - left_index


<mask token>
print(count_by_range(array, 4, 4))
print(count_by_range(array, -1, 3))

<mask token>


def count_by_range(array, left_value, right_value):
    right_index = bisect_right(array, right_value)
    left_index = bisect_left(array, left_value)
    return right_index - left_index


array = [1, 2, 3, 3, 3, 3, 4, 4, 8, 9]
print(count_by_range(array, 4, 4))
print(count_by_range(array, -1, 3))

from bisect import bisect_left, bisect_right


def count_by_range(array, left_value, right_value):
    right_index = bisect_right(array, right_value)
    left_index = bisect_left(array, left_value)
    return right_index - left_index


array = [1, 2, 3, 3, 3, 3, 4, 4, 8, 9]
print(count_by_range(array, 4, 4))
print(count_by_range(array, -1, 3))
