input: from bisect import bisect_left
  from typing import List
  
  def find_beautiful_indices(s: str, a: str, b: str, k: int) -> List[int]:
      """
      You are given a 0-indexed string s, a string a, a string b, and an integer k.
  
      An index i is beautiful if:
  
      0 <= i <= s.length - a.length
      s[i..(i + a.length - 1)] == a
      There exists an index j such that:
      0 <= j <= s.length - b.length
      s[j..(j + b.length - 1)] == b
      |j - i| <= k
      Return the array that contains beautiful indices in sorted order from smallest to largest.
  
      Examples:
      >>> s = "isawsquirrelnearmysquirrelhouseohmy", a = "my", b = "squirrel", k = 15
      [16,33]
      >>> s = "abcd", a = "a", b = "a", k = 4
      [0]
  
      Constraints:
      1 <= k <= s.length <= 10^5
      1 <= a.length, b.length <= 10
      s, a, and b contain only lowercase English letters.
      """
  
output: 
      beautiful_indices = []
      a_indices = []
      b_indices = []
      
      for i in range(len(s) - len(a) + 1):
          if s[i:i+len(a)] == a:
              a_indices.append(i)
      
      for j in range(len(s) - len(b) + 1):
          if s[j:j+len(b)] == b:
              b_indices.append(j)
      
      for i in a_indices:
          left = bisect_left(b_indices, i - k)
          right = bisect_left(b_indices, i + k + 1)
          for j in b_indices[left:right]:
              if abs(j - i) <= k:
                  beautiful_indices.append(i)
                  break
      
      return sorted(beautiful_indices)
  