import random


def random_split(a:list, s:int):
    """Randomly split a list `a` into two parts with the first one having length `s`.
    """
    assert 0 <= s <= len(a)
    idx = list(range(len(a))); random.shuffle(idx)
#     a1 = [a[idx[i]] for i in range(0, min(s,len(a)))]
#     a2 = [a[idx[i]] for i in range(max(0,s),len(a))]
    a1 = [a[idx[i]] for i in range(0, s)]
    a2 = [a[idx[i]] for i in range(s,len(a))]
    return a1, a2
    # # equivalent to
    # aa = a.copy(); random.shuffle(aa)
    # return aa[:s]; aa[s:]