





import csv

import tweepy

# Twitter API credentials
UpperCamelCase__   : int					  = """"""
UpperCamelCase__   : Optional[Any]					  = """"""
UpperCamelCase__   : Dict					  = """"""
UpperCamelCase__   : Tuple					  = """"""




def    A_(			A   ):
	# authorize twitter, initialize tweepy
	UpperCAmelCase_								=     tweepy.OAuthHandler(A				,      A   )
	auth.set_access_token(A				,      A   )
	UpperCAmelCase_								=     tweepy.API(A   )

	# initialize a list to hold all the tweepy Tweets
	UpperCAmelCase_								=     []

	# make initial request for most recent tweets (200 is the maximum allowed count)
	UpperCAmelCase_								=     api.user_timeline(screen_name=A				,      count=200   )

	# save most recent tweets
	alltweets.extend(A   )

	# save the id of the oldest tweet less one
	UpperCAmelCase_								=     alltweets[-1].id - 1

	# keep grabbing tweets until there are no tweets left to grab
	while len(A   ) > 0:
		print(f"""getting tweets before {oldest}"""   )

		# all subsequent requests use the max_id param to prevent duplicates
		UpperCAmelCase_								=     api.user_timeline(
		    screen_name=A				,      count=200				,      max_id=A   )

		# save most recent tweets
		alltweets.extend(A   )

		# update the id of the oldest tweet less one
		UpperCAmelCase_								=     alltweets[-1].id - 1

		print(f"""...{len(A   )} tweets downloaded so far"""   )

	# transform the tweepy tweets into a 2D array that will populate the csv
	UpperCAmelCase_								=     [[tweet.id_str, tweet.created_at, tweet.text] for tweet in alltweets]

	# write the csv
	with open(f"""new_{screen_name}_tweets.csv"""				,      """w"""   ) as f:
		UpperCAmelCase_								=     csv.writer(A   )
		writer.writerow(["""id""", """created_at""", """text"""]   )
		writer.writerows(A   )


if __name__ == "__main__":
				# pass in the username of the account you want to download
				get_all_tweets("""FirePing32""")









from math import factorial

UpperCamelCase__   : dict[str, int]					  = {str(digit): factorial(digit) for digit in range(10)}




def    A_(			A   ):
	if not isinstance(A				,      A   ):
		raise TypeError("""Parameter number must be int"""   )

	if number < 0:
		raise ValueError("""Parameter number must be greater than or equal to 0"""   )

	# Converts number in string to iterate on its digits and adds its factorial.
	return sum(DIGIT_FACTORIAL[digit] for digit in str(A   )   )




def    A_(			A = 60				,      A = 1000000   ):

	if not isinstance(A				,      A   ) or not isinstance(A				,      A   ):
		raise TypeError("""Parameters chain_length and number_limit must be int"""   )

	if chain_length <= 0 or number_limit <= 0:
		raise ValueError(
		    """Parameters chain_length and number_limit must be greater than 0"""   )

	# the counter for the chains with the exact desired length
	UpperCAmelCase_								=     0
	# the cached sizes of the previous chains
	UpperCAmelCase_								=     {}

	for start_chain_element in range(1				,      A   ):
		# The temporary set will contain the elements of the chain
		UpperCAmelCase_								=     set()
		UpperCAmelCase_								=     0

		# Stop computing the chain when you find a cached size, a repeating item or the
		# length is greater then the desired one.
		UpperCAmelCase_								=     start_chain_element
		while (
		    chain_element not in chain_sets_lengths
		    and chain_element not in chain_set
		    and chain_set_length <= chain_length
		):
			chain_set.add(A   )
			chain_set_length += 1
			UpperCAmelCase_								=     digit_factorial_sum(A   )

		if chain_element in chain_sets_lengths:
			chain_set_length += chain_sets_lengths[chain_element]

		UpperCAmelCase_								=     chain_set_length

		# If chain contains the exact amount of elements increase the counter
		if chain_set_length == chain_length:
			chains_counter += 1

	return chains_counter


if __name__ == "__main__":
				import doctest

				doctest.testmod()
				print(f"{solution()}")


