from __future__ import annotations

from sys import maxsize
from typing import Generic, TypeVar

a_		       =   TypeVar("""T""")




def    __lowerCAmelCase   (    A_ :			int       )     ->	List[Any]:
  return (position - 1) // 2




def    __lowerCAmelCase   (    A_ :			int       )     ->	Optional[Any]:
  return (2 * position) + 1




def    __lowerCAmelCase   (    A_ :			int       )     ->	Union[str, Any]:
  return (2 * position) + 2


class       UpperCAmelCase__     (		Generic[T]       ):



  """simple docstring"""






  def __init__(					self:      Tuple )			->			int:




    '''simple docstring'''




    __UpperCAmelCase         =							[]
    __UpperCAmelCase         =							{}
    __UpperCAmelCase         =							0






  def __len__(					self:      Optional[int] )			->			int:




    '''simple docstring'''




    return self.elements






  def __repr__(					self:      Union[str, Any] )			->			Optional[Any]:




    '''simple docstring'''




    return str(self.heap )






  def 						_UpperCAmelCase					(					self:      Optional[int] )			->			Optional[Any]:




    '''simple docstring'''




    return self.elements == 0






  def 						_UpperCAmelCase					(					self:      Tuple					,					__lowerCAmelCase:      Optional[Any]					,					__lowerCAmelCase:      Optional[Any] )			->			Tuple:




    '''simple docstring'''




    self.heap.append((elem, weight) )
    __UpperCAmelCase         =							self.elements
    self.elements += 1
    self._bubble_up(__lowerCAmelCase )






  def 						_UpperCAmelCase					(					self:      Optional[Any] )			->			str:




    '''simple docstring'''




    if self.elements > 1:
      self._swap_nodes(0					,					self.elements - 1 )
    __UpperCAmelCase     ,		__UpperCAmelCase         =							self.heap.pop()
    del self.position_map[elem]
    self.elements -= 1
    if self.elements > 0:
      __UpperCAmelCase     ,		__UpperCAmelCase         =							self.heap[0]
      self._bubble_down(__lowerCAmelCase )
    return elem






  def 						_UpperCAmelCase					(					self:      Any					,					__lowerCAmelCase:      str					,					__lowerCAmelCase:      str )			->			Dict:




    '''simple docstring'''




    __UpperCAmelCase         =							self.position_map[elem]
    __UpperCAmelCase         =							(elem, weight)
    if position > 0:
      __UpperCAmelCase         =							get_parent_position(__lowerCAmelCase )
      __UpperCAmelCase     ,		__UpperCAmelCase         =							self.heap[parent_position]
      if parent_weight > weight:
        self._bubble_up(__lowerCAmelCase )
      else:
        self._bubble_down(__lowerCAmelCase )
    else:
      self._bubble_down(__lowerCAmelCase )






  def 						_UpperCAmelCase					(					self:      Any					,					__lowerCAmelCase:      List[str] )			->			Optional[int]:




    '''simple docstring'''




    __UpperCAmelCase         =							self.position_map[elem]
    if curr_pos == 0:
      return None
    __UpperCAmelCase         =							get_parent_position(__lowerCAmelCase )
    __UpperCAmelCase     ,		__UpperCAmelCase         =							self.heap[curr_pos]
    __UpperCAmelCase     ,		__UpperCAmelCase         =							self.heap[parent_position]
    if parent_weight > weight:
      self._swap_nodes(__lowerCAmelCase					,					__lowerCAmelCase )
      return self._bubble_up(__lowerCAmelCase )
    return None






  def 						_UpperCAmelCase					(					self:      Any					,					__lowerCAmelCase:      Optional[Any] )			->			str:




    '''simple docstring'''




    __UpperCAmelCase         =							self.position_map[elem]
    __UpperCAmelCase     ,		__UpperCAmelCase         =							self.heap[curr_pos]
    __UpperCAmelCase         =							get_child_left_position(__lowerCAmelCase )
    __UpperCAmelCase         =							get_child_right_position(__lowerCAmelCase )
    if child_left_position < self.elements and child_right_position < self.elements:
      __UpperCAmelCase     ,		__UpperCAmelCase         =							self.heap[child_left_position]
      __UpperCAmelCase     ,		__UpperCAmelCase         =							self.heap[child_right_position]
      if child_right_weight < child_left_weight and child_right_weight < weight:
        self._swap_nodes(__lowerCAmelCase					,					__lowerCAmelCase )
        return self._bubble_down(__lowerCAmelCase )
    if child_left_position < self.elements:
      __UpperCAmelCase     ,		__UpperCAmelCase         =							self.heap[child_left_position]
      if child_left_weight < weight:
        self._swap_nodes(__lowerCAmelCase					,					__lowerCAmelCase )
        return self._bubble_down(__lowerCAmelCase )
    else:
      return None
    if child_right_position < self.elements:
      __UpperCAmelCase     ,		__UpperCAmelCase         =							self.heap[child_right_position]
      if child_right_weight < weight:
        self._swap_nodes(__lowerCAmelCase					,					__lowerCAmelCase )
        return self._bubble_down(__lowerCAmelCase )
    return None






  def 						_UpperCAmelCase					(					self:      Tuple					,					__lowerCAmelCase:      Optional[int]					,					__lowerCAmelCase:      Optional[int] )			->			int:




    '''simple docstring'''




    __UpperCAmelCase         =							self.heap[nodea_pos][0]
    __UpperCAmelCase         =							self.heap[nodea_pos][0]
    __UpperCAmelCase     ,		__UpperCAmelCase         =							(
        self.heap[nodea_pos],
        self.heap[nodea_pos],
    )
    __UpperCAmelCase         =							nodea_pos
    __UpperCAmelCase         =							nodea_pos






class       UpperCAmelCase__     (		Generic[T]       ):



  """simple docstring"""






  def __init__(					self:      Tuple )			->			int:




    '''simple docstring'''




    __UpperCAmelCase         =							{}
    __UpperCAmelCase         =							0






  def __repr__(					self:      str )			->			int:




    '''simple docstring'''




    return str(self.connections )






  def __len__(					self:      Optional[Any] )			->			Any:




    '''simple docstring'''




    return self.nodes






  def 						_UpperCAmelCase					(					self:      Any					,					__lowerCAmelCase:      int )			->			Optional[Any]:




    '''simple docstring'''




    if node not in self.connections:
      __UpperCAmelCase         =							{}
      self.nodes += 1






  def 						_UpperCAmelCase					(					self:      Optional[Any]					,					__lowerCAmelCase:      Tuple					,					__lowerCAmelCase:      List[str]					,					__lowerCAmelCase:      int )			->			List[str]:




    '''simple docstring'''




    self.add_node(__lowerCAmelCase )
    self.add_node(__lowerCAmelCase )
    __UpperCAmelCase         =							weight
    __UpperCAmelCase         =							weight






def    __lowerCAmelCase   (    A_ :			GraphUndirectedWeighted[T]    ,						)     ->	str:
  __UpperCAmelCase         =							{node: maxsize for node in graph.connections}
  __UpperCAmelCase         =							{node: None for node in graph.connections}

  __UpperCAmelCase         =							MinPriorityQueue()
  for node, weight in dist.items():
    priority_queue.push(a__    ,						a__       )

  if priority_queue.is_empty():
    return dist, parent

  # initialization
  __UpperCAmelCase         =							priority_queue.extract_min()
  __UpperCAmelCase         =							0
  for neighbour in graph.connections[node]:
    if dist[neighbour] > dist[node] + graph.connections[node][neighbour]:
      __UpperCAmelCase         =							dist[node] + graph.connections[node][neighbour]
      priority_queue.update_key(a__    ,						dist[neighbour]       )
      __UpperCAmelCase         =							node

    # running prim's algorithm
  while not priority_queue.is_empty():
    __UpperCAmelCase         =							priority_queue.extract_min()
    for neighbour in graph.connections[node]:
      if dist[neighbour] > dist[node] + graph.connections[node][neighbour]:
        __UpperCAmelCase         =							dist[node] + graph.connections[node][neighbour]
        priority_queue.update_key(a__    ,						dist[neighbour]       )
        __UpperCAmelCase         =							node
  return dist, parent










# this script reports modified .py files under the desired list of top-level sub-dirs passed as a list of arguments, e.g.:
#   python ./utils/get_modified_files.py utils src tests examples
#
# it uses git to find the forking point and which files were modified - i.e. files not under git won't be considered
# since the output of this script is fed into Makefile commands it doesn't print a newline after the results

import re
import subprocess
import sys


UpperCamelCase__           =			subprocess.check_output("git merge-base main HEAD".split()).decode("utf-8")
UpperCamelCase__           =			subprocess.check_output(f"""git diff --name-only {fork_point_sha}""".split()).decode("utf-8").split()

UpperCamelCase__           =			"|".join(sys.argv[1:])
UpperCamelCase__           =			re.compile(rf"""^({joined_dirs}).*?\.py$""")

UpperCamelCase__           =			[x for x in modified_files if regex.match(x)]
print(" ".join(relevant_modified_files), end="")




