


'''simple docstring'''
import os
from collections import deque

import torch
from torch.utils.data import Dataset

class 						__magic_name__					(    snake_case_				):




 '''simple docstring'''


 def __init__(      self      ,      __lowercase=""      ,      __lowercase="train"						):

  """simple docstring"""







  assert os.path.isdir(__lowercase						)

  __A  :		Optional[int]       =			[]
  __A  :		Optional[Any]       =			os.listdir(__lowercase						)
  for story_filename in story_filenames_list:
   if "summary" in story_filename:
    continue
   __A  :		Union[str, Any]       =			os.path.join(__lowercase      ,      __lowercase						)
   if not os.path.isfile(__lowercase						):
    continue
   self.documents.append(__lowercase						)


 def __len__(      self						):

  """simple docstring"""







  return len(self.documents						)







 def __getitem__(      self      ,      __lowercase						):

  """simple docstring"""







  __A  :		Dict       =			self.documents[idx]
  __A  :		List[str]       =			document_path.split('/'						)[-1]
  with open(__lowercase      ,      encoding='utf-8'						) as source:
   __A  :		Optional[int]       =			source.read()
   __A  :		Optional[int]       =			process_story(__lowercase						)
  return document_name, story_lines, summary_lines


def 			_lowercase       (				UpperCamelCase__       :					Union[str, Any]			):
 __A  :		int       =			list(filter(lambda UpperCamelCase__			: len(UpperCamelCase__			) != 0,				[line.strip() for line in raw_story.split('\n'			)]			)			)

 # for some unknown reason some lines miss a period, add it
 __A  :		List[str]       =			[_add_missing_period(UpperCamelCase__			) for line in nonempty_lines]

 # gather article lines
 __A  :		Any       =			[]
 __A  :		int       =			deque(UpperCamelCase__			)
 while True:
  try:
   __A  :		Any       =			lines.popleft()
   if element.startswith('@highlight'			):
    break
   story_lines.append(UpperCamelCase__			)
  except IndexError:
   # if "@highlight" is absent from the file we pop
   # all elements until there is None, raising an exception.
   return story_lines, []

    # gather summary lines
 __A  :		Optional[int]       =			list(filter(lambda UpperCamelCase__			: not t.startswith('@highlight'			),				UpperCamelCase__			)			)

 return story_lines, summary_lines


def 			_lowercase       (				UpperCamelCase__       :					Union[str, Any]			):
 __A  :		Union[str, Any]       =			['.', '!', '?', '...', '\'', '`', '"', '\u2019', '\u2019', ')']
 if line.startswith('@highlight'			):
  return line
 if line[-1] in END_TOKENS:
  return line
 return line + "."


def 			_lowercase       (				UpperCamelCase__       :					Optional[int],				UpperCamelCase__       :					Optional[int],				UpperCamelCase__       :					Any			):
 if len(UpperCamelCase__			) > block_size:
  return sequence[:block_size]
 else:
  sequence.extend([pad_token_id] * (block_size - len(UpperCamelCase__			))			)
  return sequence


def 			_lowercase       (				UpperCamelCase__       :					int,				UpperCamelCase__       :					List[str]			):
 __A  :		str       =			torch.ones_like(UpperCamelCase__			)
 __A  :		Any       =			sequence == pad_token_id
 __A  :		Optional[int]       =			0
 return mask


def 			_lowercase       (				UpperCamelCase__       :					int,				UpperCamelCase__       :					int,				UpperCamelCase__       :					Union[str, Any]			):
 __A  :		Optional[Any]       =			[tokenizer.encode(UpperCamelCase__			) for line in story_lines]
 __A  :		Any       =			[token for sentence in story_lines_token_ids for token in sentence]
 __A  :		Any       =			[tokenizer.encode(UpperCamelCase__			) for line in summary_lines]
 __A  :		str       =			[token for sentence in summary_lines_token_ids for token in sentence]

 return story_token_ids, summary_token_ids


def 			_lowercase       (				UpperCamelCase__       :					List[Any],				UpperCamelCase__       :					int			):
 __A  :		List[str]       =			[]
 for sequence in batch:
  __A  :		int       =			-1
  __A  :		Union[str, Any]       =			[]
  for s in sequence:
   if s == separator_token_id:
    sentence_num += 1
   embeddings.append(sentence_num % 2			)
  batch_embeddings.append(UpperCamelCase__			)
 return torch.tensor(UpperCamelCase__			)










'''simple docstring'''
from collections import defaultdict
from math import ceil, sqrt


def 			_lowercase       (				UpperCamelCase__       :					int = 1000000,				UpperCamelCase__       :					int = 10			):
 __A  :		defaultdict       =			defaultdict(UpperCamelCase__			)

 for outer_width in range(3,				(t_limit // 4) + 2			):
  if outer_width * outer_width > t_limit:
   __A  :		Optional[int]       =			max(
       ceil(sqrt(outer_width * outer_width - t_limit			)			),				1			)
  else:
   __A  :		Optional[Any]       =			1

  hole_width_lower_bound += (outer_width - hole_width_lower_bound) % 2

  for hole_width in range(UpperCamelCase__,				outer_width - 1,				2			):
   count[outer_width * outer_width - hole_width * hole_width] += 1

 return sum(1 for n in count.values() if 1 <= n <= 10			)


if __name__ == "__main__":
 print(f'''{solution() = }''')






