import collections


def unique2lists(list1, list2, add=False):
    """Unique list1 and list2 based on list1
    Args:
        list1(list):
        list2(list):
        add(Optional(bool)): add list2 elements with list1 duplicates
    Returns:
        list,list
    """
    if add:
        cntr = collections.Counter()

        def cntr_add(x, y):
            b = x not in cntr
            cntr[x] += y
            return b

        list1 = [x1 for x1, x2 in zip(list1, list2) if cntr_add(x1, x2)]
        list2 = [cntr[x1] for x1 in list1]
        return list1, list2
    else:
        seen = set()
        seen_add = seen.add
        list1, list2 = tuple(
            zip(
                *[
                    [x1, x2]
                    for x1, x2 in zip(list1, list2)
                    if not (x1 in seen or seen_add(x1))
                ]
            )
        )
        return list(list1), list(list2)