



import contextlib
import os
import sqlitea

import pytest

from datasets import Dataset, Features, Value
from datasets.io.sql import SqlDatasetReader, SqlDatasetWriter

from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases, require_sqlalchemy







def  lowerCAmelCase_	(lowerCAmelCase__:		int		,						lowerCAmelCase__:		Any  ):





			"""simple docstring"""


			assert isinstance(lowerCAmelCase__		,						lowerCAmelCase__  )
			assert dataset.num_rows == 4
			assert dataset.num_columns == 3
			assert dataset.column_names == ["col_1", "col_2", "col_3"]
			for feature, expected_dtype in expected_features.items():
						assert dataset.features[feature].dtype == expected_dtype







@require_sqlalchemy
@pytest.mark.parametrize("""keep_in_memory"""		,						[False, True]  )
def  lowerCAmelCase_	(lowerCAmelCase__:		Optional[int]		,						lowerCAmelCase__:		Any		,						lowerCAmelCase__:		int		,						lowerCAmelCase__:		int  ):





			"""simple docstring"""


			UpperCAmelCase_:		Any							      =     tmp_path / """cache"""
			UpperCAmelCase_:		Dict							      =     {"""col_1""": """string""", """col_2""": """int64""", """col_3""": """float64"""}
			with assert_arrow_memory_increases() if keep_in_memory else assert_arrow_memory_doesnt_increase():
						UpperCAmelCase_:		Dict							      =     SqlDatasetReader(
						    """dataset"""		,						"""sqlite:///""" + sqlite_path		,						cache_dir=lowerCAmelCase__		,						keep_in_memory=lowerCAmelCase__  ).read()
			_check_sql_dataset(lowerCAmelCase__		,						lowerCAmelCase__  )







@require_sqlalchemy
@pytest.mark.parametrize(
    """features"""		,						[
        None,
        {"""col_1""": """string""", """col_2""": """int64""", """col_3""": """float64"""},
        {"""col_1""": """string""", """col_2""": """string""", """col_3""": """string"""},
        {"""col_1""": """int32""", """col_2""": """int32""", """col_3""": """int32"""},
        {"""col_1""": """float32""", """col_2""": """float32""", """col_3""": """float32"""},
    ]		,						)
def  lowerCAmelCase_	(lowerCAmelCase__:		Any		,						lowerCAmelCase__:		Tuple		,						lowerCAmelCase__:		Optional[int]		,						lowerCAmelCase__:		List[Any]  ):





			"""simple docstring"""


			UpperCAmelCase_:		Optional[int]							      =     tmp_path / """cache"""
			UpperCAmelCase_:		Optional[int]							      =     {"""col_1""": """string""", """col_2""": """int64""", """col_3""": """float64"""}
			UpperCAmelCase_:		Optional[Any]							      =     features.copy() if features else default_expected_features
			UpperCAmelCase_:		Any							      =     (
			    Features({feature: Value(lowerCAmelCase__  ) for feature, dtype in features.items()}  ) if features is not None else None
			)
			UpperCAmelCase_:		str							      =     SqlDatasetReader("""dataset"""		,						"""sqlite:///""" + sqlite_path		,						features=lowerCAmelCase__		,						cache_dir=lowerCAmelCase__  ).read()
			_check_sql_dataset(lowerCAmelCase__		,						lowerCAmelCase__  )







def  lowerCAmelCase_	(lowerCAmelCase__:		Any  ):





			"""simple docstring"""


			with contextlib.closing(sqlitea.connect(lowerCAmelCase__  )  ) as con:
						UpperCAmelCase_:		int							      =     con.cursor()
						cur.execute("""SELECT * FROM dataset"""  )
						for row in cur:
									yield row







@require_sqlalchemy
def  lowerCAmelCase_	(lowerCAmelCase__:		Any		,						lowerCAmelCase__:		Optional[int]		,						lowerCAmelCase__:		Optional[Any]  ):





			"""simple docstring"""


			UpperCAmelCase_:		int							      =     tmp_path / """cache"""
			UpperCAmelCase_:		Optional[Any]							      =     os.path.join(lowerCAmelCase__		,						"""tmp.sql"""  )
			UpperCAmelCase_:		Optional[int]							      =     SqlDatasetReader("""dataset"""		,						"""sqlite:///""" + sqlite_path		,						cache_dir=lowerCAmelCase__  ).read()
			SqlDatasetWriter(lowerCAmelCase__		,						"""dataset"""		,						"""sqlite:///""" + output_sqlite_path		,						num_proc=1  ).write()

			UpperCAmelCase_:		List[str]							      =     iter_sql_file(lowerCAmelCase__  )
			UpperCAmelCase_:		List[str]							      =     iter_sql_file(lowerCAmelCase__  )

			for rowa, rowa in zip(lowerCAmelCase__		,						lowerCAmelCase__  ):
						assert rowa == rowa







@require_sqlalchemy
def  lowerCAmelCase_	(lowerCAmelCase__:		Optional[int]		,						lowerCAmelCase__:		List[Any]		,						lowerCAmelCase__:		Tuple  ):





			"""simple docstring"""


			UpperCAmelCase_:		Optional[int]							      =     tmp_path / """cache"""
			UpperCAmelCase_:		List[Any]							      =     os.path.join(lowerCAmelCase__		,						"""tmp.sql"""  )
			UpperCAmelCase_:		Any							      =     SqlDatasetReader("""dataset"""		,						"""sqlite:///""" + sqlite_path		,						cache_dir=lowerCAmelCase__  ).read()
			SqlDatasetWriter(lowerCAmelCase__		,						"""dataset"""		,						"""sqlite:///""" + output_sqlite_path		,						num_proc=2  ).write()

			UpperCAmelCase_:		Optional[Any]							      =     iter_sql_file(lowerCAmelCase__  )
			UpperCAmelCase_:		Optional[int]							      =     iter_sql_file(lowerCAmelCase__  )

			for rowa, rowa in zip(lowerCAmelCase__		,						lowerCAmelCase__  ):
						assert rowa == rowa







@require_sqlalchemy
def  lowerCAmelCase_	(lowerCAmelCase__:		Optional[int]		,						lowerCAmelCase__:		Optional[Any]		,						lowerCAmelCase__:		Any  ):





			"""simple docstring"""


			UpperCAmelCase_:		Any							      =     tmp_path / """cache"""
			UpperCAmelCase_:		Optional[Any]							      =     os.path.join(lowerCAmelCase__		,						"""tmp.sql"""  )
			UpperCAmelCase_:		Union[str, Any]							      =     SqlDatasetReader("""dataset"""		,						"""sqlite:///""" + sqlite_path		,						cache_dir=lowerCAmelCase__  ).read()
			with pytest.raises(lowerCAmelCase__  ):
						SqlDatasetWriter(lowerCAmelCase__		,						"""dataset"""		,						"""sqlite:///""" + output_sqlite_path		,						num_proc=0  ).write()











def  lowerCAmelCase_	(lowerCAmelCase__:		int  ):





			"""simple docstring"""


			if n == 1 or not isinstance(lowerCAmelCase__		,						lowerCAmelCase__  ):
						return 0
			elif n == 2:
						return 1
			else:
						UpperCAmelCase_:		Optional[int]							      =     [0, 1]
						for i in range(2		,						n + 1  ):
									sequence.append(sequence[i - 1] + sequence[i - 2]  )

						return sequence[n]







def  lowerCAmelCase_	(lowerCAmelCase__:		int  ):





			"""simple docstring"""


			UpperCAmelCase_:		str							      =     0
			UpperCAmelCase_:		str							      =     2

			while digits < n:
						index += 1
						UpperCAmelCase_:		Union[str, Any]							      =     len(str(fibonacci(lowerCAmelCase__  )  )  )

			return index







def  lowerCAmelCase_	(lowerCAmelCase__:		int = 1_0_0_0  ):





			"""simple docstring"""


			return fibonacci_digits_index(lowerCAmelCase__  )


if __name__ == "__main__":
	print(solution(int(str(input()).strip())))






