


'''simple docstring'''
UpperCAmelCase_ :     Tuple								=      range(2, 2_0 + 1)
UpperCAmelCase_ :     Union[str, Any]								=      [1_0**k for k in range(ks[-1] + 1)]
UpperCAmelCase_ :     dict[int, dict[int, list[list[int]]]]								=      {}


def 			_lowercase       (				UpperCamelCase__       :					List[str],				UpperCamelCase__       :					Dict,				UpperCamelCase__       :					List[Any],				UpperCamelCase__       :					str			):
 __A  :		Optional[int]       =			sum(a_i[j] for j in range(UpperCamelCase__,				len(UpperCamelCase__			)			)			)
 __A  :		List[str]       =			sum(a_i[j] * base[j] for j in range(min(len(UpperCamelCase__			),				UpperCamelCase__			)			)			)

 __A  :		Dict       =			0, 0
 __A  :		Tuple       =			n - i

 __A  :		Optional[Any]       =			memo.get(UpperCamelCase__			)

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

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

   if max_jump >= 0:
    __A  :		Dict       =			jumps[max_jump]
    # since the difference between jumps is cached, add c
    __A  :		Optional[int]       =			diff + c
    for j in range(min(UpperCamelCase__,				len(UpperCamelCase__			)			)			):
     __A  :		List[str]       =			divmod(UpperCamelCase__,				10			)
    if new_c > 0:
     add(UpperCamelCase__,				UpperCamelCase__,				UpperCamelCase__			)

  else:
   __A  :		int       =			[]
 else:
  __A  :		Union[str, Any]       =			{c: []}
  __A  :		Dict       =			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  :		Dict       =			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  :		Dict       =			compute(UpperCamelCase__,				UpperCamelCase__,				i + dn,				UpperCamelCase__			)
  diff += _diff
  dn += terms_jumped

 __A  :		List[Any]       =			sub_memo[c]

 # keep jumps sorted by # of terms skipped
 __A  :		List[Any]       =			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 			_lowercase       (				UpperCamelCase__       :					Any,				UpperCamelCase__       :					int,				UpperCamelCase__       :					Union[str, Any],				UpperCamelCase__       :					Optional[Any]			):
 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  :		Dict       =			i
 __A  :		str       =			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  :		Union[str, Any]       =			ds_c + ds_b
  diff += addend
  __A  :		int       =			0
  for j in range(UpperCamelCase__			):
   __A  :		Any       =			a_i[j] + addend
   __A  :		Optional[int]       =			divmod(UpperCamelCase__,				10			)

   ds_c += a_i[j]

  if addend > 0:
   break

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


def 			_lowercase       (				UpperCamelCase__       :					Dict,				UpperCamelCase__       :					Any,				UpperCamelCase__       :					List[Any]			):
 for j in range(UpperCamelCase__,				len(UpperCamelCase__			)			):
  __A  :		Dict       =			digits[j] + addend
  if s >= 10:
   __A  :		List[Any]       =			divmod(UpperCamelCase__,				10			)
   __A  :		Any       =			addend // 10 + quotient
  else:
   __A  :		Optional[int]       =			s
   __A  :		Any       =			addend // 10

  if addend == 0:
   break

 while addend > 0:
  __A  :		Union[str, Any]       =			divmod(UpperCamelCase__,				10			)
  digits.append(UpperCamelCase__			)


def 			_lowercase       (				UpperCamelCase__       :					int = 10**15			):
 __A  :		Union[str, Any]       =			[1]
 __A  :		Optional[int]       =			1
 __A  :		Dict       =			0
 while True:
  __A  :		Dict       =			next_term(UpperCamelCase__,				20,				i + dn,				UpperCamelCase__			)
  dn += terms_jumped
  if dn == n - i:
   break

 __A  :		str       =			0
 for j in range(len(UpperCamelCase__			)			):
  a_n += digits[j] * 10**j
 return a_n


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










'''simple docstring'''
import glob
import os
import random
from string import ascii_lowercase, digits

import cva
UpperCAmelCase_ :     int								=      ''
UpperCAmelCase_ :     Union[str, Any]								=      ''
UpperCAmelCase_ :     Any								=      ''
UpperCAmelCase_ :     int								=      1  # (0 is vertical, 1 is horizontal)


def 			_lowercase       (				):
 __A     ,__A  :		Optional[int]       =			get_dataset(UpperCamelCase__,				UpperCamelCase__			)
 print('Processing...'			)
 __A     ,__A     ,__A  :		Any       =			update_image_and_anno(UpperCamelCase__,				UpperCamelCase__,				UpperCamelCase__			)

 for index, image in enumerate(UpperCamelCase__			):
  # Get random string code: '7b7ad245cdff75241935e4dd860f3bad'
  __A  :		Dict       =			random_chars(32			)
  __A  :		List[Any]       =			paths[index].split(os.sep			)[-1].rsplit('.',				1			)[0]
  __A  :		Dict       =			f"""{OUTPUT_DIR}/{file_name}_FLIP_{letter_code}"""
  cva.imwrite(f"""/{file_root}.jpg""",				UpperCamelCase__,				[cva.IMWRITE_JPEG_QUALITY, 85]			)
  print(f"""Success {index+1}/{len(UpperCamelCase__			)} with {file_name}"""			)
  __A  :		Tuple       =			[]
  for anno in new_annos[index]:
   __A  :		Any       =			f"""{anno[0]} {anno[1]} {anno[2]} {anno[3]} {anno[4]}"""
   annos_list.append(UpperCamelCase__			)
  with open(f"""/{file_root}.txt""",				'w'			) as outfile:
   outfile.write('\n'.join(line for line in annos_list			)			)


def 			_lowercase       (				UpperCamelCase__       :					str,				UpperCamelCase__       :					str			):
 __A  :		Tuple       =			[]
 __A  :		int       =			[]
 for label_file in glob.glob(os.path.join(UpperCamelCase__,				'*.txt'			)			):
  __A  :		Optional[int]       =			label_file.split(os.sep			)[-1].rsplit('.',				1			)[0]
  with open(UpperCamelCase__			) as in_file:
   __A  :		Optional[Any]       =			in_file.readlines()
  __A  :		int       =			os.path.join(UpperCamelCase__,				f"""{label_name}.jpg"""			)

  __A  :		Optional[int]       =			[]
  for obj_list in obj_lists:
   __A  :		str       =			obj_list.rstrip('\n'			).split(' '			)
   boxes.append(
       [
           int(obj[0]			),
           float(obj[1]			),
           float(obj[2]			),
           float(obj[3]			),
           float(obj[4]			),
       ]			)
  if not boxes:
   continue
  img_paths.append(UpperCamelCase__			)
  labels.append(UpperCamelCase__			)
 return img_paths, labels


def 			_lowercase       (				UpperCamelCase__       :					list,				UpperCamelCase__       :					list,				UpperCamelCase__       :					int = 1			):
 __A  :		int       =			[]
 __A  :		Optional[Any]       =			[]
 __A  :		str       =			[]
 for idx in range(len(UpperCamelCase__			)			):
  __A  :		List[Any]       =			[]
  __A  :		List[str]       =			img_list[idx]
  path_list.append(UpperCamelCase__			)
  __A  :		Optional[Any]       =			anno_list[idx]
  __A  :		Union[str, Any]       =			cva.imread(UpperCamelCase__			)
  if flip_type == 1:
   __A  :		int       =			cva.flip(UpperCamelCase__,				UpperCamelCase__			)
   for bbox in img_annos:
    __A  :		Union[str, Any]       =			1 - bbox[1]
    new_annos.append([bbox[0], x_center_new, bbox[2], bbox[3], bbox[4]]			)
  elif flip_type == 0:
   __A  :		Tuple       =			cva.flip(UpperCamelCase__,				UpperCamelCase__			)
   for bbox in img_annos:
    __A  :		Dict       =			1 - bbox[2]
    new_annos.append([bbox[0], bbox[1], y_center_new, bbox[3], bbox[4]]			)
  new_annos_lists.append(UpperCamelCase__			)
  new_imgs_list.append(UpperCamelCase__			)
 return new_imgs_list, new_annos_lists, path_list


def 			_lowercase       (				UpperCamelCase__       :					int = 32			):
 assert number_char > 1, "The number of character should greater than 1"
 __A  :		int       =			ascii_lowercase + digits
 return "".join(random.choice(UpperCamelCase__			) for _ in range(UpperCamelCase__			)			)


if __name__ == "__main__":
 main()
 print('DONE ✅')






