May-28-2018, 06:01 PM
from numpy import array, bitwise_or from itertools import combinations, chain n,k=map(int,input().split()) arr=list(map(int,input().split())) tup=map(list,chain.from_iterable(map(lambda x:combinations(arr,x),range(1,k+1)))) ans=map(lambda x:bitwise_or.reduce(array(x,dtype='int')),tup) print(len(set(ans)))n is the number of elements in set
the code makes subsets of size <= k and performs bitwise or on each subset and prints the number of unique elements formed