package main import ( "fmt" "bufio" "os" "strings" "strconv" ) type Cell struct { n int a []int } func newCell(n int, a []int) *Cell { cp := new(Cell) cp.n = n if len(a) == 0 { cp.a = a } else { cp.a = make([]int, len(a)) copy(cp.a, a) } return cp } func toString(a []int) string { var str_build strings.Builder for i := 0; i < len(a); i++ { str_build.WriteString(strconv.Itoa(a[i]) + ",") } return str_build.String() } func main() { r := bufio.NewReader(os.Stdin) w := bufio.NewWriter(os.Stdout) defer w.Flush() var N, W int fmt.Fscan(r, &N, &W) a := make([]int, N) for i := 0; i < N; i++ { fmt.Fscan(r, &a[i]) } w0 := make([]*Cell, 1) w0[0] = newCell(0, make([]int, 0)) for i := 0; i < N; i++ { w1 := make([]*Cell, 0) for _, wv := range w0 { w, v := wv.n, wv.a w1 = append(w1, newCell(w, v)) if w + a[i] / 2 <= W { w1 = append(w1, newCell(w + a[i] / 2, append(v, i))) } if w + a[i] <= W { w1 = append(w1, newCell(w + a[i], append(v, i))) } } w0 = w1 } if W == 0 { w0 = w0[1:] } m := make(map[string]bool) for _, xy := range w0 { if xy.n == W { m[toString(xy.a)] = true } } fmt.Fprintln(w, len(m)) }