Working implementation of arbitrary-size clique counting function