
"""simple docstring"""







from collections import defaultdict




class  A__       :

		def __init__(      self       ,		_SCREAMING_SNAKE_CASE       ,		_SCREAMING_SNAKE_CASE ):
			__lowerCAmelCase			:						Any									=      total  # total no of tasks (N)

			# DP table will have a dimension of (2^M)*N
			# initially all values are set to -1
			__lowerCAmelCase			:						Optional[int]									=      [
			    [-1 for i in range(total + 1 )] for j in range(2 ** len(_SCREAMING_SNAKE_CASE ) )
			]

			__lowerCAmelCase			:						int									=      defaultdict(_SCREAMING_SNAKE_CASE )  # stores the list of persons for each task

			# final_mask is used to check if all persons are included by setting all bits
			# to 1
			__lowerCAmelCase			:						Dict									=      (1 << len(_SCREAMING_SNAKE_CASE )) - 1

		def 							__lowerCamelCase							(      self       ,		_SCREAMING_SNAKE_CASE       ,		_SCREAMING_SNAKE_CASE ):
			# if mask == self.finalmask all persons are distributed tasks, return 1
			if mask == self.final_mask:
				return 1

			# if not everyone gets the task and no more tasks are available, return 0
			if task_no > self.total_tasks:
				return 0

			# if case already considered
			if self.dp[mask][task_no] != -1:
				return self.dp[mask][task_no]

			# Number of ways when we don't this task in the arrangement
			__lowerCAmelCase			:						int									=      self.count_ways_until(_SCREAMING_SNAKE_CASE       ,		task_no + 1 )

			# now assign the tasks one by one to all possible persons and recursively
			# assign for the remaining tasks.
			if task_no in self.task:
				for p in self.task[task_no]:
					# if p is already given a task
					if mask & (1 << p):
						continue

					# assign this task to p and change the mask value. And recursively
					# assign tasks with the new mask value.
					total_ways_util += self.count_ways_until(mask | (1 << p)       ,		task_no + 1 )

        # save the value.
			__lowerCAmelCase			:						Dict									=      total_ways_util

			return self.dp[mask][task_no]







		def 							__lowerCamelCase							(      self       ,		_SCREAMING_SNAKE_CASE ):
			# Store the list of persons for each task
			for i in range(len(_SCREAMING_SNAKE_CASE ) ):
				for j in task_performed[i]:
					self.task[j].append(_SCREAMING_SNAKE_CASE )

        # call the function to fill the DP table, final answer is stored in dp[0][1]
			return self.count_ways_until(0       ,		1 )


if __name__ == "__main__":
							lowerCamelCase__   					=		5  # total no of tasks (the value of N)

							# the list of tasks that can be done by M persons.
							lowerCamelCase__   					=		[[1, 3, 4], [1, 2, 5], [3, 4]]
							print(
							    AssignmentUsingBitmask(task_performed, total_tasks).count_no_of_ways(
							        task_performed
							    )
							)






import argparse
from collections import defaultdict

import yaml


A    :					str =      '''docs/source/en/_toctree.yml'''







def    __lowerCamelCase					(							__a   :str    )		->				List[Any]:






		"""simple docstring"""

		A__        =   defaultdict(__a    )
		A__        =   []
		A__        =   []
		for doc in doc_list:
				if "local" in doc:
						counts[doc["local"]] += 1

				if doc["title"].lower() == "overview":
						overview_doc.append({"""local""": doc["""local"""], """title""": doc["""title"""]}    )
				else:
						new_doc_list.append(__a    )

		A__        =   new_doc_list
		A__        =   [key for key, value in counts.items() if value > 1]

		A__        =   []
		for duplicate_key in duplicates:
				A__        =   list({doc["""title"""] for doc in doc_list if doc["""local"""] == duplicate_key}    )
				if len(__a    ) > 1:
						raise ValueError(
						    F'{duplicate_key} is present several times in the documentation table of content at '
						    """`docs/source/en/_toctree.yml` with different *Title* values. Choose one of those and remove the """
						    """others."""    )
				# Only add this once
				new_doc.append({"""local""": duplicate_key, """title""": titles[0]}    )

		# Add none duplicate-keys
		new_doc.extend([doc for doc in doc_list if """local""" not in counts or counts[doc["""local"""]] == 1]    )
		A__        =   sorted(__a    ,     key=lambda __a    : s["title"].lower()    )

		# "overview" gets special treatment and is always first
		if len(__a    ) > 1:
				raise ValueError("""{doc_list} has two 'overview' docs which is not allowed."""    )

		overview_doc.extend(__a    )

		# Sort
		return overview_doc







def    __lowerCamelCase					(							__a   :Any=False    )		->				List[str]:






		"""simple docstring"""

		with open(__a    ,     encoding="""utf-8"""    ) as f:
				A__        =   yaml.safe_load(f.read()    )

		# Get to the API doc
		A__        =   0
		while content[api_idx]["title"] != "API":
				api_idx += 1
		A__        =   content[api_idx]["""sections"""]

		# Then to the model doc
		A__        =   0
		while api_doc[scheduler_idx]["title"] != "Schedulers":
				scheduler_idx += 1

		A__        =   api_doc[scheduler_idx]["""sections"""]
		A__        =   clean_doc_toc(__a    )

		A__        =   False
		if new_scheduler_doc != scheduler_doc:
				A__        =   True
				if overwrite:
						A__        =   new_scheduler_doc

		if diff:
				if overwrite:
						A__        =   api_doc
						with open(__a    ,     """w"""    ,     encoding="""utf-8"""    ) as f:
								f.write(yaml.dump(__a    ,     allow_unicode=__a    )    )
				else:
						raise ValueError(
						    """The model doc part of the table of content is not properly sorted, run `make style` to fix this."""    )







def    __lowerCamelCase					(							__a   :Optional[int]=False    )		->				Dict:






		"""simple docstring"""

		with open(__a    ,     encoding="""utf-8"""    ) as f:
				A__        =   yaml.safe_load(f.read()    )

		# Get to the API doc
		A__        =   0
		while content[api_idx]["title"] != "API":
				api_idx += 1
		A__        =   content[api_idx]["""sections"""]

		# Then to the model doc
		A__        =   0
		while api_doc[pipeline_idx]["title"] != "Pipelines":
				pipeline_idx += 1

		A__        =   False
		A__        =   api_doc[pipeline_idx]["""sections"""]
		A__        =   []

		# sort sub pipeline docs
		for pipeline_doc in pipeline_docs:
				if "section" in pipeline_doc:
						A__        =   pipeline_doc["""section"""]
						A__        =   clean_doc_toc(__a    )
						if overwrite:
								A__        =   new_sub_pipeline_doc
				new_pipeline_docs.append(__a    )

		# sort overall pipeline doc
		A__        =   clean_doc_toc(__a    )

		if new_pipeline_docs != pipeline_docs:
				A__        =   True
				if overwrite:
						A__        =   new_pipeline_docs

		if diff:
				if overwrite:
						A__        =   api_doc
						with open(__a    ,     """w"""    ,     encoding="""utf-8"""    ) as f:
								f.write(yaml.dump(__a    ,     allow_unicode=__a    )    )
				else:
						raise ValueError(
						    """The model doc part of the table of content is not properly sorted, run `make style` to fix this."""    )


if __name__ == "__main__":
					A    :					Tuple =      argparse.ArgumentParser()
					parser.add_argument('''--fix_and_overwrite''', action='''store_true''', help='''Whether to fix inconsistencies.''')
					A    :					Optional[Any] =      parser.parse_args()

					check_scheduler_doc(args.fix_and_overwrite)
					check_pipeline_doc(args.fix_and_overwrite)



