from typing import Counter


def percentile(data: list, p=0.5):
    """
    :param data: origin list
    :param p: frequency percentile
    :return: the element at frequency percentile p
    """
    assert 0 < p < 1
    boundary = len(data) * p
    counter = sorted(Counter(data).items(), key=lambda x: x[0])
    keys, counts = zip(*counter)
    accumulation = 0
    for i, c in enumerate(counts):
        accumulation += c
        if accumulation > boundary:
            return keys[i]
    return None