import strutils, sequtils, algorithm, future, math {.warning[SmallLshouldNotBeUsed]: off.} proc cnt(x, n: int, a: seq[int]): int = for i in 0..<(1 shl a.len): if i.toBin(a.len+1).count('1') != n: continue var l = 1 for j in 0..