input: from typing import List
  import bisect
  def count_subarrays_with_and_k(nums: List[int], k: int) -> int:
      """
      Given a list of integers nums and an integer k, determine the count of
      subarrays in nums where the bitwise AND of all elements equals k.
  
      Examples:
      >>> nums = [1,1,1], k = 1
      6
      >>> nums = [1,1,2], k = 1
      3
  
      Constraints:
      1 <= len(nums) <= 100,000
      0 <= nums[i], k <= 1,000,000,000
      """
output:     count = 0
      n = len(nums)
      
      for i in range(n):
          and_value = nums[i]
          for j in range(i, n):
              and_value &= nums[j]
              if and_value == k:
                  count += 1
              if and_value < k:
                  break
      
      return count