input: from typing import List
  import bisect
  def subarray_and_equals_k(nums: List[int], k: int) -> int:
      """
      Given an array of integers nums and an integer k, determine the count of
      subarrays in nums where the bitwise AND of all elements in the subarray is equal to k.
  
      Examples:
      >>> nums = [1,1,1], k = 1
      6
      >>> nums = [1,1,2], k = 1
      3
  
      Constraints:
      1 <= len(nums) <= 10^5
      0 <= nums[i], k <= 10^9
      """
output:     
      n = len(nums)
      count = 0
      for i in range(n):
          current_and = nums[i]
          for j in range(i, n):
              current_and &= nums[j]
              if current_and == k:
                  count += 1
              if current_and < k:
                  break
      return count
  