





import torch

from transformers import AutoModel



class  A__       (	torch.nn.Module      ):





      def __init__(			self	,							A_="sayef/fsner-bert-base-uncased"       ):
       '''simple docstring'''




       super(A_	,							self       ).__init__()

       UpperCamelCase     : Tuple	     =       AutoModel.from_pretrained(A_	,							return_dict=A_       )
       UpperCamelCase     : Optional[int]	     =       torch.nn.CosineSimilarity(3	,							1e-08       )
       UpperCamelCase     : List[str]	     =       torch.nn.Softmax(dim=1       )





      def 	__UpperCamelCase(			self	,							**A_       ):
       '''simple docstring'''




       return self.bert(**A_       ).last_hidden_state





      def 	__UpperCamelCase(			self	,							A_       ):
       '''simple docstring'''




       return token_embeddings.sum(2	,							keepdim=A_       )





      def 	__UpperCamelCase(			self	,							A_	,							A_	,							A_=1       ):
       '''simple docstring'''




       return self.softmax(T * self.cos(A_	,							A_       )       )





      def 	__UpperCamelCase(			self	,							A_	,							A_       ):
       '''simple docstring'''




       UpperCamelCase     : Dict	     =       W_supports["sizes"].tolist()
       UpperCamelCase     : List[Any]	     =       W_supports["start_token_id"].item()
       UpperCamelCase     : Optional[int]	     =       W_supports["end_token_id"].item()

       del W_supports["sizes"]
       del W_supports["start_token_id"]
       del W_supports["end_token_id"]

       UpperCamelCase     : List[str]	     =       self.BERT(**A_       )
       UpperCamelCase     : Optional[int]	     =       self.BERT(**A_       )

       UpperCamelCase     : str	     =       None
       UpperCamelCase     : Union[str, Any]	     =       None

       UpperCamelCase     : Optional[int]	     =       W_supports["input_ids"] == start_token_id
       UpperCamelCase     : List[str]	     =       W_supports["input_ids"] == end_token_id

       for i, size in enumerate(A_       ):
        if i == 0:
         UpperCamelCase     : Union[str, Any]	     =       0
        else:
         UpperCamelCase     : Dict	     =       support_sizes[i - 1]

        UpperCamelCase     : Dict	     =       S[s : s + size][start_token_masks[s : s + size]]
        UpperCamelCase     : List[str]	     =       S[s : s + size][end_token_masks[s : s + size]]

        UpperCamelCase     : int	     =       torch.matmul(q[i]	,							s_start.T       ).sum(1       ).softmax(0       )
        UpperCamelCase     : int	     =       torch.matmul(q[i]	,							s_end.T       ).sum(1       ).softmax(0       )

        if p_starts is not None:
         UpperCamelCase     : int	     =       torch.vstack((p_starts, p_start)       )
         UpperCamelCase     : int	     =       torch.vstack((p_ends, p_end)       )
        else:
         UpperCamelCase     : List[str]	     =       p_start
         UpperCamelCase     : Dict	     =       p_end

       return p_starts, p_ends







import math



def 		A_    (					_lowerCAmelCase					)						->			list:
 UpperCamelCase     : str	     =       [True] * n
 UpperCamelCase     : Optional[int]	     =       False
 UpperCamelCase     : str	     =       False
 UpperCamelCase     : List[Any]	     =       True

 for i in range(3							,       int(n**0.5 + 1					)							,       2					):
  UpperCamelCase     : int	     =       i * 2
  while index < n:
   UpperCamelCase     : Optional[Any]	     =       False
   UpperCamelCase     : Optional[Any]	     =       index + i

 UpperCamelCase     : Optional[Any]	     =       [2]

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

 return primes



def 		A_    (					_lowerCAmelCase = 9999_6666_3333					)						->			int:
 UpperCamelCase     : Tuple	     =       math.floor(math.sqrt(_lowerCAmelCase					)					) + 100
 UpperCamelCase     : Dict	     =       prime_sieve(_lowerCAmelCase					)

 UpperCamelCase     : Optional[Any]	     =       0
 UpperCamelCase     : Tuple	     =       0
 UpperCamelCase     : List[str]	     =       primes[prime_index]

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

  UpperCamelCase     : Any	     =       last_prime**2
  UpperCamelCase     : Union[str, Any]	     =       next_prime**2

  # Get numbers divisible by lps(current)
  UpperCamelCase     : Dict	     =       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)
  UpperCamelCase     : List[str]	     =       upper_bound - next_prime
  while current > lower_bound:
   matches_sum += current
   current -= next_prime

  # Remove the numbers divisible by both ups and lps
  UpperCamelCase     : Dict	     =       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
  UpperCamelCase     : str	     =       next_prime
  prime_index += 1

 return matches_sum


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