


import argparse
from collections import defaultdict

import yaml


snake_case							:       Dict     			=      '''docs/source/en/_toctree.yml'''






def 							__lowercase   ( __lowerCAmelCase							:				List[Any]   ):
							a__             =     defaultdict(__lowerCAmelCase   )
							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(__lowerCAmelCase   )

							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(__lowerCAmelCase   ) > 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(__lowerCAmelCase					,    key=lambda __lowerCAmelCase   : s["title"].lower()   )

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

							overview_doc.extend(__lowerCAmelCase   )

							# Sort
							return overview_doc






def 							__lowercase   ( __lowerCAmelCase							:				str=False   ):
							with open(__lowerCAmelCase					,    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(__lowerCAmelCase   )

							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(__lowerCAmelCase					,    'w'					,    encoding='utf-8'   ) as f:
																												f.write(yaml.dump(__lowerCAmelCase					,    allow_unicode=__lowerCAmelCase   )   )
														else:
																					raise ValueError(
																					    'The model doc part of the table of content is not properly sorted, run `make style` to fix this.'   )






def 							__lowercase   ( __lowerCAmelCase							:				Any=False   ):
							with open(__lowerCAmelCase					,    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(__lowerCAmelCase   )
																					if overwrite:
																												a__             =     new_sub_pipeline_doc
														new_pipeline_docs.append(__lowerCAmelCase   )

							# sort overall pipeline doc
							a__             =     clean_doc_toc(__lowerCAmelCase   )

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

							if diff:
														if overwrite:
																					a__             =     api_doc
																					with open(__lowerCAmelCase					,    'w'					,    encoding='utf-8'   ) as f:
																												f.write(yaml.dump(__lowerCAmelCase					,    allow_unicode=__lowerCAmelCase   )   )
														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__":
						snake_case							:       Any     			=      argparse.ArgumentParser()
						parser.add_argument('''--fix_and_overwrite''', action='''store_true''', help='''Whether to fix inconsistencies.''')
						snake_case							:       str     			=      parser.parse_args()

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








import math






def 							__lowercase   ( __lowerCAmelCase							:				int   ):
							a__             =     [True] * n
							a__             =     False
							a__             =     False
							a__             =     True

							for i in range(3					,    int(n**0.5 + 1   )					,    2   ):
														a__             =     i * 2
														while index < n:
																					a__             =     False
																					a__             =     index + i

							a__             =     [2]

							for i in range(3					,    __lowerCAmelCase					,    2   ):
														if is_prime[i]:
																					primes.append(__lowerCAmelCase   )

							return primes






def 							__lowercase   ( __lowerCAmelCase							:				int = 9_9_9_9_6_6_6_6_3_3_3_3   ):
							a__             =     math.floor(math.sqrt(__lowerCAmelCase   )   ) + 1_0_0
							a__             =     prime_sieve(__lowerCAmelCase   )

							a__             =     0
							a__             =     0
							a__             =     primes[prime_index]

							while (last_prime**2) <= limit:
														a__             =     primes[prime_index + 1]

														a__             =     last_prime**2
														a__             =     next_prime**2

														# Get numbers divisible by lps(current)
														a__             =     lower_bound + last_prime
														while upper_bound > current <= limit:
																					matches_sum += current
																					current += last_prime

														# Reset the upper_bound
														while (upper_bound - next_prime) > limit:
																					upper_bound -= next_prime

														# Add the numbers divisible by ups(current)
														a__             =     upper_bound - next_prime
														while current > lower_bound:
																					matches_sum += current
																					current -= next_prime

														# Remove the numbers divisible by both ups and lps
														a__             =     0
														while upper_bound > current <= limit:
																					if current <= lower_bound:
																												# Increment the current number
																												current += last_prime * next_prime
																												continue

																					if current > limit:
																												break

																					# Remove twice since it was added by both ups and lps
																					matches_sum -= current * 2

																					# Increment the current number
																					current += last_prime * next_prime

														# Setup for next pair
														a__             =     next_prime
														prime_index += 1

							return matches_sum


if __name__ == "__main__":
						print(solution())




