


from __future__ import annotations

from sys import maxsize
from typing import Generic, TypeVar

SCREAMING_SNAKE_CASE :   Tuple							      =				TypeVar("T")



def        UpperCamelCase_(   lowerCamelCase_				)					->		int:
    return (position - 1) // 2



def        UpperCamelCase_(   lowerCamelCase_				)					->		int:
    return (2 * position) + 1



def        UpperCamelCase_(   lowerCamelCase_				)					->		int:
    return (2 * position) + 2






class _lowerCamelCase(		Generic[T]     ):
       def __init__(      self) ->     None:




           """simple docstring"""

           _lowercase :							list[tuple[T, int]]   	=	[]
           _lowercase :							dict[T, int]   	=	{}
           _lowercase :							int   	=	0
       def __len__(      self) ->     int:




           """simple docstring"""

           return self.elements
       def __repr__(      self) ->     str:




           """simple docstring"""

           return str(self.heap)
       def     UpperCamelCase  (      self) ->     bool:




           """simple docstring"""

           return self.elements == 0
       def     UpperCamelCase  (      self,   lowerCamelCase,   lowerCamelCase) ->     None:




           """simple docstring"""

           self.heap.append((elem, weight))
           _lowercase :							str   	=	self.elements
           self.elements += 1
           self._bubble_up(lowerCamelCase)
       def     UpperCamelCase  (      self) ->     T:




           """simple docstring"""

           if self.elements > 1:
               self._swap_nodes(0,   self.elements - 1)
           _lowercase :							Any   	=	self.heap.pop()
           del self.position_map[elem]
           self.elements -= 1
           if self.elements > 0:
               _lowercase :							int   	=	self.heap[0]
               self._bubble_down(lowerCamelCase)
           return elem
       def     UpperCamelCase  (      self,   lowerCamelCase,   lowerCamelCase) ->     None:




           """simple docstring"""

           _lowercase :							List[Any]   	=	self.position_map[elem]
           _lowercase :							Tuple   	=	(elem, weight)
           if position > 0:
               _lowercase :							Union[str, Any]   	=	get_parent_position(lowerCamelCase)
               _lowercase :							int   	=	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,   lowerCamelCase) ->     None:




           """simple docstring"""

           _lowercase :							Union[str, Any]   	=	self.position_map[elem]
           if curr_pos == 0:
               return None
           _lowercase :							str   	=	get_parent_position(lowerCamelCase)
           _lowercase :							Dict   	=	self.heap[curr_pos]
           _lowercase :							List[Any]   	=	self.heap[parent_position]
           if parent_weight > weight:
               self._swap_nodes(lowerCamelCase,   lowerCamelCase)
               return self._bubble_up(lowerCamelCase)
           return None
       def     UpperCamelCase  (      self,   lowerCamelCase) ->     None:




           """simple docstring"""

           _lowercase :							Tuple   	=	self.position_map[elem]
           _lowercase :							Union[str, Any]   	=	self.heap[curr_pos]
           _lowercase :							Dict   	=	get_child_left_position(lowerCamelCase)
           _lowercase :							Tuple   	=	get_child_right_position(lowerCamelCase)
           if child_left_position < self.elements and child_right_position < self.elements:
               _lowercase :							Any   	=	self.heap[child_left_position]
               _lowercase :							List[str]   	=	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:
               _lowercase :							List[str]   	=	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:
               _lowercase :							Tuple   	=	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,   lowerCamelCase,   lowerCamelCase) ->     None:




           """simple docstring"""

           _lowercase :							int   	=	self.heap[nodea_pos][0]
           _lowercase :							Any   	=	self.heap[nodea_pos][0]
           _lowercase :							str   	=	(
               self.heap[nodea_pos],
               self.heap[nodea_pos],
           )
           _lowercase :							Optional[Any]   	=	nodea_pos
           _lowercase :							Optional[Any]   	=	nodea_pos






class _lowerCamelCase(		Generic[T]     ):
       def __init__(      self) ->     None:




           """simple docstring"""

           _lowercase :							dict[T, dict[T, int]]   	=	{}
           _lowercase :							int   	=	0
       def __repr__(      self) ->     str:




           """simple docstring"""

           return str(self.connections)
       def __len__(      self) ->     int:




           """simple docstring"""

           return self.nodes
       def     UpperCamelCase  (      self,   lowerCamelCase) ->     None:




           """simple docstring"""

           if node not in self.connections:
               _lowercase :							List[str]   	=	{}
               self.nodes += 1




       def     UpperCamelCase  (      self,   lowerCamelCase,   lowerCamelCase,   lowerCamelCase) ->     None:




           """simple docstring"""

           self.add_node(lowerCamelCase)
           self.add_node(lowerCamelCase)
           _lowercase :							Any   	=	weight
           _lowercase :							str   	=	weight



def        UpperCamelCase_(   lowerCamelCase_							,				)					->		tuple[dict[T, int], dict[T, T | None]]:
    _lowercase :							dict[T, int]   	=	{node: maxsize for node in graph.connections}
    _lowercase :							dict[T, T | None]   	=	{node: None for node in graph.connections}

    _lowercase :							MinPriorityQueue[T]   	=	MinPriorityQueue()
    for node, weight in dist.items():
        priority_queue.push(lowerCamelCase_							,				lowerCamelCase_				)

    if priority_queue.is_empty():
        return dist, parent

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

    # running prim's algorithm
    while not priority_queue.is_empty():
        _lowercase :							Tuple   	=	priority_queue.extract_min()
        for neighbour in graph.connections[node]:
            if dist[neighbour] > dist[node] + graph.connections[node][neighbour]:
                _lowercase :							str   	=	dist[node] + graph.connections[node][neighbour]
                priority_queue.update_key(lowerCamelCase_							,				dist[neighbour]				)
                _lowercase :							List[Any]   	=	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


SCREAMING_SNAKE_CASE :   List[Any]							      =				subprocess.check_output("git merge-base main HEAD".split()).decode("utf-8")
SCREAMING_SNAKE_CASE :   Optional[int]							      =				(
    subprocess.check_output(F"git diff --diff-filter=d --name-only {fork_point_sha}".split()).decode("utf-8").split()
)

SCREAMING_SNAKE_CASE :   Any							      =				"|".join(sys.argv[1:])
SCREAMING_SNAKE_CASE :   Union[str, Any]							      =				re.compile(rF"^({joined_dirs}).*?\.py$")

SCREAMING_SNAKE_CASE :   List[Any]							      =				[x for x in modified_files if regex.match(x)]
print(" ".join(relevant_modified_files), end="")


