#------------------------quiz3------------------------#


#####################[Code 1]##########################

def find(A):
    n = len(A)

    if n == 0: return set()
    if n == 1: return { A[0] }

    B = find(A[:n//2]) | find(A[n//2:])
    C = set()
    for x in B:
        count = 0
        for i in range(0, n):
            if A[i] == x: 
                count += 1
        if count > n/3.0:
            C.add(x)
    return C

print( find( [1, 2, 3, 1, 2, 3, 1] ) )
print( find( [1, 2, 3, 4, 5] ) )
print( find( [1, 1, 1, 2, 2, 2, 3] ) )



#####################[Code 2]##########################

#end



