import sequtils,algorithm,tables,strutils,times,sugar template `^`(n:int) : int = (1 shl n) template stopwatch(body) = (let t1 = cpuTime();body;echo "TIME:",(cpuTime() - t1) * 1000,"ms") template stopwatch(body) = body proc getchar_unlocked():char {. importc:"getchar_unlocked",header: "" .} proc scan(): int = while true: let k = getchar_unlocked() if k < '0': return result = 10 * result + k.ord - '0'.ord proc cmp(x,y:seq[int]):int = for i in 0.. 0: result &= i + 1 if n < ^(i+1) : return var I1 : array[^16,int] proc build(P:seq[int]) = proc impl(n,x:int) = # 1つずつ if n == P.len : return I1[x or ^n] = I1[x] + P[n] impl(n+1,x) impl(n+1,x or ^n) impl(0,0) let n = scan() let s = scan() let P = newSeqWith(n,scan()) if n == 1: quit "1",0 let n2 = n div 2 + 1 let P1 = P[0..x.v-y.v) stopwatch: var answers = newSeq[int]() for x in 0..<(^n2): let i1 = I1[x] let si = I2.binarySearch(s-i1,proc(K:tuple[k,v:int],V:int):int=K.v-V) if si == -1 : continue answers &= x or (I2[si].k shl n2) for i in (si+1)..