public class Trees { record Tree(Tree l, Tree r, long v) {} static Tree make(int d, long v) { return d == 0 ? new Tree(null, null, v) : new Tree(make(d - 1, v), make(d - 1, v), 0); } static long check(Tree t) { return t.l() == null ? t.v() % 2 : 1 + check(t.l()) + check(t.r()); } public static void main(String[] a) { long acc = 0; for (int d = 4; d <= 16; d += 2) for (long i = 1; i <= (1L << (16 - d + 4)); i++) acc += check(make(d, i)); System.out.println(acc); } }