






"""simple docstring"""


lowercase_				     =     range(2, 20 + 1)
lowercase_				     =     [10**k for k in range(ks[-1] + 1)]
lowercase_				     =     {}



def 					lowerCAmelCase				(    __UpperCamelCase		,       __UpperCamelCase		,       __UpperCamelCase		,       __UpperCamelCase ):




  """simple docstring"""







  __A									= sum(a_i[j] for j in range(__UpperCamelCase		,       len(__UpperCamelCase ) ) )
  __A									= sum(a_i[j] * base[j] for j in range(min(len(__UpperCamelCase )		,       __UpperCamelCase ) ) )

  __A			,    __A									= 0, 0
  __A									= n - i

  __A									= memo.get(__UpperCamelCase )

  if sub_memo is not None:
    __A									= sub_memo.get(__UpperCamelCase )

    if jumps is not None and len(__UpperCamelCase ) > 0:
      # find and make the largest jump without going over
      __A									= -1
      for _k in range(len(__UpperCamelCase ) - 1		,       -1		,       -1 ):
        if jumps[_k][2] <= k and jumps[_k][1] <= max_dn:
          __A									= _k
          break

      if max_jump >= 0:
        __A			,    __A			,    __A									= jumps[max_jump]
        # since the difference between jumps is cached, add c
        __A									= diff + c
        for j in range(min(__UpperCamelCase		,       len(__UpperCamelCase ) ) ):
          __A			,    __A									= divmod(__UpperCamelCase		,       1_0 )
        if new_c > 0:
          add(__UpperCamelCase		,       __UpperCamelCase		,       __UpperCamelCase )

    else:
      __A									= []
  else:
    __A									= {c: []}
    __A									= sub_memo

  if dn >= max_dn or c + diff >= base[k]:
    return diff, dn

  if k > ks[0]:
    while True:
      # keep doing smaller jumps
      __A			,    __A									= next_term(__UpperCamelCase		,       k - 1		,       i + dn		,       __UpperCamelCase )
      diff += _diff
      dn += terms_jumped

      if dn >= max_dn or c + diff >= base[k]:
        break
  else:
    # would be too small a jump, just compute sequential terms instead
    __A			,    __A									= compute(__UpperCamelCase		,       __UpperCamelCase		,       i + dn		,       __UpperCamelCase )
    diff += _diff
    dn += terms_jumped

  __A									= sub_memo[c]

  # keep jumps sorted by # of terms skipped
  __A									= 0
  while j < len(__UpperCamelCase ):
    if jumps[j][1] > dn:
      break
    j += 1

  # cache the jump for this value digitsum(b) and c
  sub_memo[c].insert(__UpperCamelCase		,       (diff, dn, k) )
  return (diff, dn)



def 					lowerCAmelCase				(    __UpperCamelCase		,       __UpperCamelCase		,       __UpperCamelCase		,       __UpperCamelCase ):




  """simple docstring"""







  if i >= n:
    return 0, i
  if k > len(__UpperCamelCase ):
    a_i.extend([0 for _ in range(k - len(__UpperCamelCase ) )] )

  # note: a_i -> b * 10^k + c
  # ds_b -> digitsum(b)
  # ds_c -> digitsum(c)
  __A									= i
  __A			,    __A			,    __A									= 0, 0, 0
  for j in range(len(__UpperCamelCase ) ):
    if j >= k:
      ds_b += a_i[j]
    else:
      ds_c += a_i[j]

  while i < n:
    i += 1
    __A									= ds_c + ds_b
    diff += addend
    __A									= 0
    for j in range(__UpperCamelCase ):
      __A									= a_i[j] + addend
      __A			,    __A									= divmod(__UpperCamelCase		,       1_0 )

      ds_c += a_i[j]

    if addend > 0:
      break

  if addend > 0:
    add(__UpperCamelCase		,       __UpperCamelCase		,       __UpperCamelCase )
  return diff, i - start_i



def 					lowerCAmelCase				(    __UpperCamelCase		,       __UpperCamelCase		,       __UpperCamelCase ):




  """simple docstring"""







  for j in range(__UpperCamelCase		,       len(__UpperCamelCase ) ):
    __A									= digits[j] + addend
    if s >= 1_0:
      __A			,    __A									= divmod(__UpperCamelCase		,       1_0 )
      __A									= addend // 1_0 + quotient
    else:
      __A									= s
      __A									= addend // 1_0

    if addend == 0:
      break

  while addend > 0:
    __A			,    __A									= divmod(__UpperCamelCase		,       1_0 )
    digits.append(__UpperCamelCase )



def 					lowerCAmelCase				(    __UpperCamelCase = 1_0**1_5 ):




  """simple docstring"""







  __A									= [1]
  __A									= 1
  __A									= 0
  while True:
    __A			,    __A									= next_term(__UpperCamelCase		,       2_0		,       i + dn		,       __UpperCamelCase )
    dn += terms_jumped
    if dn == n - i:
      break

  __A									= 0
  for j in range(len(__UpperCamelCase ) ):
    a_n += digits[j] * 1_0**j
  return a_n


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












"""simple docstring"""


import numpy as np
import torch
from torch.utils.data import DataLoader

from accelerate.utils.dataclasses import DistributedType


class 					snake_case		:


   '''simple docstring'''

   def __init__(	self :     Optional[int],       _lowerCamelCase :     Optional[int]=2,       _lowerCamelCase :     Optional[int]=3,       _lowerCamelCase :     int=64,       _lowerCamelCase :     List[str]=None  ):

     '''simple docstring'''
     __A									= np.random.default_rng(_lowerCamelCase  )
     __A									= length
     __A									= rng.normal(size=(length,)  ).astype(np.floataa  )
     __A									= a * self.x + b + rng.normal(scale=0.1,       size=(length,)  ).astype(np.floataa  )


   def __len__(	self :     str  ):

     '''simple docstring'''
     return self.length






   def __getitem__(	self :     Dict,       _lowerCamelCase :     Optional[int]  ):

     '''simple docstring'''
     return {"x": self.x[i], "y": self.y[i]}





class 					snake_case		(							torch.nn.Module						):


   '''simple docstring'''

   def __init__(	self :     Optional[Any],       _lowerCamelCase :     Tuple=0,       _lowerCamelCase :     Any=0,       _lowerCamelCase :     Optional[Any]=False  ):

     '''simple docstring'''
     super().__init__()
     __A									= torch.nn.Parameter(torch.tensor([2, 3]  ).float()  )
     __A									= torch.nn.Parameter(torch.tensor([2, 3]  ).float()  )
     __A									= True






   def 				_SCREAMING_SNAKE_CASE				(	self :     List[str],       _lowerCamelCase :     Optional[Any]=None  ):

     '''simple docstring'''
     if self.first_batch:
       print(f'Model dtype: {self.a.dtype}, {self.b.dtype}. Input dtype: {x.dtype}'  )
       __A									= False
     return x * self.a[0] + self.b[0]





class 					snake_case		(							torch.nn.Module						):


   '''simple docstring'''

   def __init__(	self :     str,       _lowerCamelCase :     Optional[Any]=0,       _lowerCamelCase :     Any=0,       _lowerCamelCase :     List[Any]=False  ):

     '''simple docstring'''
     super().__init__()
     __A									= torch.nn.Parameter(torch.tensor(_lowerCamelCase  ).float()  )
     __A									= torch.nn.Parameter(torch.tensor(_lowerCamelCase  ).float()  )
     __A									= True






   def 				_SCREAMING_SNAKE_CASE				(	self :     Optional[Any],       _lowerCamelCase :     List[str]=None  ):

     '''simple docstring'''
     if self.first_batch:
       print(f'Model dtype: {self.a.dtype}, {self.b.dtype}. Input dtype: {x.dtype}'  )
       __A									= False
     return x * self.a + self.b





def 					lowerCAmelCase				(    __UpperCamelCase		,       __UpperCamelCase = 1_6 ):




  """simple docstring"""







  from datasets import load_dataset
  from transformers import AutoTokenizer

  __A									= AutoTokenizer.from_pretrained('''bert-base-cased''' )
  __A									= {'''train''': '''tests/test_samples/MRPC/train.csv''', '''validation''': '''tests/test_samples/MRPC/dev.csv'''}
  __A									= load_dataset('''csv'''		,       data_files=__UpperCamelCase )
  __A									= datasets['''train'''].unique('''label''' )

  __A									= {v: i for i, v in enumerate(__UpperCamelCase )}

  def tokenize_function(__UpperCamelCase ):
    # max_length=None => use the model max length (it's actually the default)
    __A									= tokenizer(
        examples['''sentence1''']		,       examples['''sentence2''']		,       truncation=__UpperCamelCase		,       max_length=__UpperCamelCase		,       padding='''max_length''' )
    if "label" in examples:
      __A									= [label_to_id[l] for l in examples['''label''']]
    return outputs

  # Apply the method we just defined to all the examples in all the splits of the dataset
  __A									= datasets.map(
      __UpperCamelCase		,       batched=__UpperCamelCase		,       remove_columns=['''sentence1''', '''sentence2''', '''label''']		,       )

  def collate_fn(__UpperCamelCase ):
    # On TPU it's best to pad everything to the same length or training will be very slow.
    if accelerator.distributed_type == DistributedType.TPU:
      return tokenizer.pad(__UpperCamelCase		,       padding='''max_length'''		,       max_length=1_2_8		,       return_tensors='''pt''' )
    return tokenizer.pad(__UpperCamelCase		,       padding='''longest'''		,       return_tensors='''pt''' )

  # Instantiate dataloaders.
  __A									= DataLoader(tokenized_datasets['''train''']		,       shuffle=__UpperCamelCase		,       collate_fn=__UpperCamelCase		,       batch_size=2 )
  __A									= DataLoader(tokenized_datasets['''validation''']		,       shuffle=__UpperCamelCase		,       collate_fn=__UpperCamelCase		,       batch_size=1 )

  return train_dataloader, eval_dataloader




