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 proc build(P:seq[int]) : seq[int] = var answer = newSeq[int](^P.len) proc impl(n,x:int) = # 1つずつ if n == P.len : return answer[x or ^n] = answer[x] + P[n] impl(n+1,x) impl(n+1,x or ^n) impl(0,0) return answer let n = scan() let s = scan() let P = newSeqWith(n,scan()) if n == 1: quit "1",0 let n2 = n div 2 let P1 = P[0..