import random


def random_split(seq, ratio=0.5, surplus=0):
    """Randomly split sequncy into two.

    Parameter surplus defines the group where odd elements are put.
    """
    assert surplus == 0 or surplus == 1
    k = int(ratio * len(seq) + 0.5 * surplus)
    a = random.sample(seq, k)
    b = [x for x in seq if x not in a]
    return a, b