_put
def _put(i, e, v = None):
  if type(i) == type({}):
    i[e] = v
  elif type(i) == type([]):
    i.append(e)
  return i
--
_append
def _append(i, e):
  if isinstance(i, list):
    i.append(e)
  elif isinstance(i, dict):
    i[e[0]] = e[1]
  else:
    raise TypeError("append() only supports lists and maps")
  return i
--
list_swap_elements
def list_swap_elements(l, a, b):
  tmp = l[a]
  l[a] = l[b]
  l[b] = tmp
  return l
--
map_get_keys
def map_get_keys(m):
  return list(m.keys())
--
throw_error
def throw_error(msg):
  #raise Exception(msg)
  print(msg)
--
list_add_element
def list_add_element(l, e):
  l.append(e)
  return l
--
list_remove_element
def list_remove_element(l, e):
  l.pop(e)
  return l
--
random_number
def random_number(max, min):
  return random.randint(min, max)
--
list_set_at_index
def list_set_at_index(l, i, v):
  diff = i - len(l)
  if diff > 0:
    for i in range(0, diff + 1):
      l.append(None)
    l[len(l) - 1] = v
  l[i] = v
  return l
--
typeOf
def typeOf(e):
  if isinstance(e, dict):
    return "MAP"
  else:
    return type(e)
--
list_slice
def list_slice(l, offset, length=-1):
  if length == -1:
    return l[offset:]
  else:
    return l[offset:length]
--
map_contains
def map_contains(m, e):
  if m is None or e is None or type(m) != type({}):
    return False
  return e in m
--
string_get_length
def string_get_length(s):
  return len(str(s))
--
value
def value(o):
  if isinstance(o, int):
    return int(o)
  elif isinstance(o, float):
    return float(o)
  elif isinstance(o, str):
    if str(o).isnumeric():
      if str(o).find(".") > -1:
        return float(o)
      else:
        return int(o)
  else:
    return 0
--
string_get_substring
def string_get_substring(s, start, length):
  x = str(s)
  return x[start:length]
--
string_to_lowercase
def string_to_lowercase(s):
  return s.lower()
--
string_to_uppercase
def string_to_uppercase(s):
  return s.upper()
--
string_contains
def string_contains(s, c):
  return s.find(c) > -1
--
square_root
def square_root(n):
  return math.sqrt(n)
--
string_split
def string_split(s, d):
  return s.split(d)
--
millitime
import time
def millitime():
  return time.perf_counter_ns() / 1_000_000
--
auto_input
def auto_input():
  v = input()
  if v.isnumeric():
    return int(v)
  try:
    return float(v)
  except ValueError:
    return v
--
string_compare
def string_compare(a, b):
  return a == b
--
Math~random_number
def random_number(max, min):
  return random.randint(min, max)
--
map_create_ordered
def map_create_ordered(*args):
  result = {}

  for pair in args:
    result[pair[0]] = pair[1]

  return result
--
expand_if_list
def expand_if_list(array, i, j):
  if isinstance(array, list):
    while len(array) <= i:
      array.append([])
      while len(array[i]) <= j:
        array[i].append(0)
--
max_integer
def max_integer():
  return 2**31 - 1
