Problem:
Score : 1200 points

Problem Statement

There are N non-negative integers written on the blackboard: A_1, ..., A_N.

Snuke can perform the following two operations at most K times in total in any order:

Operation A: Replace each integer X on the blackboard with X divided by 2, rounded down to the nearest integer.

Operation B: Replace each integer X on the blackboard with X minus 1. This operation cannot be performed if one or more 0s are written on the blackboard.

Find the number of the different possible combinations of integers written on the blackboard after Snuke performs the operations, modulo 1,000,000,007.

Constraints

1 \leq N \leq 200

1 \leq A_i \leq 10^{18}

1 \leq K \leq 10^{18}

A_i and K are integers.

Input

Input is given from Standard Input in the following format:

N K
A_1 A_2 ... A_N

Output

Print the number of the different possible combinations of integers written on the blackboard after Snuke performs the operations, modulo 1,000,000,007.

Sample Input 1

2 2
5 7

Sample Output 1

6

There are six possible combinations of integers on the blackboard: (1, 1), (1, 2), (2, 3), (3, 5), (4, 6) and (5, 7).
For example, (1, 2) can be obtained by performing Operation A and Operation B in this order.

Sample Input 2

3 4
10 13 22

Sample Output 2

20

Sample Input 3

1 100
10

Sample Output 3

11

Sample Input 4

10 123456789012345678
228344079825412349 478465001534875275 398048921164061989 329102208281783917 779698519704384319 617456682030809556 561259383338846380 254083246422083141 458181156833851984 502254767369499613

Sample Output 4

164286011

Solution in Java8 (OpenJDK 1.8.0) (judge verdict: Wrong Answer)

// package arc.arc086;

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    private static final long MOD = 1000000007;

    static class Pattern {
        long leftOperation;
        long head;
        long[] diff;
        Pattern(long[] a, long left) {
            int n = a.length;
            Arrays.sort(a);
            diff = new long[n-1];
            for (int i = 0; i < n-1 ; i++) {
                diff[i] = a[i+1] - a[i];
            }
            head = a[0];
            leftOperation = Math.min(left, head);
        }

        public int hashCode() {
            return Arrays.hashCode(diff);
        }

        public boolean equals(Object o) {
            Pattern p = (Pattern) o;
            return Arrays.equals(diff, p.diff);
        }
    }

    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n = in.nextInt();
        long K = in.nextLong();
        long[] a = new long[n];
        for (int i = 0; i < n ; i++) {
            a[i] = in.nextLong();
        }

        List<Pattern> arr = new ArrayList<>();
        for (int b = 0 ; b <= 60 ; b++) {
            long pw = 1L<<b;
            long[] mod = new long[n+2];
            for (int i = 0; i < n ; i++) {
                mod[i] = a[i] & (pw-1);
            }
            mod[n] = -1;
            mod[n+1] = pw;
            Arrays.sort(mod);

            long last = -1;
            for (int i = 0; i+1 < mod.length ; i++) {
                if (mod[i] == mod[i+1]) {
                    continue;
                }
                Pattern ptn = computePattern(a, b, last+1, mod[i+1], K);
                if (ptn.leftOperation >= 0) {
                    arr.add(ptn);
                }
                last = mod[i+1];
            }
        }

        Map<Pattern, List<long[]>> pset = new HashMap<>();
        for (Pattern ptn : arr) {
            if (!pset.containsKey(ptn)) {
                pset.put(ptn, new ArrayList<>());
            }
            pset.get(ptn).add(new long[]{ptn.head, ptn.head - ptn.leftOperation});
        }

        long ans = 0;
        for (List<long[]> ranges : pset.values()) {
            ans += solve(ranges);
            ans %= MOD;
        }
        out.println(ans);
        out.flush();
    }

    private static long solve(List<long[]> ranges) {
        Collections.sort(ranges, Comparator.comparingLong(u -> u[1]));

        long count = 0;
        long last = -1;
        long coverMax = -2;

        for (long[] l : ranges) {
            if (coverMax < l[1]) {
                count += coverMax - last + 1;
                last = l[1];
                coverMax = l[0];
            } else {
                coverMax = Math.max(coverMax, l[0]);
            }
        }
        count += coverMax - last + 1;

//        debug("=");
//        for (long[] l : ranges) {
//            debug(l);
//        }
//        debug(count);

        return count;
    }

    private static Pattern computePattern(long[] a, int B, long from, long to, long K) {
        long div = 1L<<B;
        long[] ta = new long[a.length];
        for (int i = 0; i < a.length ; i++) {
            ta[i] = (a[i] - from) / div;
        }
        long cnt = K - B - minPopcount(from, to);
        return new Pattern(ta, cnt);
    }

    private static int minPopcount(long from, long to) {
        int cnt = 0;
        for (int b = 60 ; b >= 0 ; b--) {
            long mask = 1L<<b;
            if ((from & mask) == (to & mask)) {
                cnt += ((from & mask) == 0) ? 0 : 1;
            } else {
                if (from % mask >= 1) {
                    cnt++;
                    break;
                }
            }
        }
        return cnt;
    }

    public static void debug(Object... o) {
        System.err.println(Arrays.deepToString(o));
    }

    public static class InputReader {
        private static final int BUFFER_LENGTH = 1 << 12;
        private InputStream stream;
        private byte[] buf = new byte[BUFFER_LENGTH];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        private int next() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public char nextChar() {
            return (char) skipWhileSpace();
        }

        public String nextToken() {
            int c = skipWhileSpace();
            StringBuilder res = new StringBuilder();
            do {
                res.append((char) c);
                c = next();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public int nextInt() {
            return (int) nextLong();
        }

        public long nextLong() {
            int c = skipWhileSpace();
            long sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = next();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = next();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public double nextDouble() {
            return Double.valueOf(nextToken());
        }

        int skipWhileSpace() {
            int c = next();
            while (isSpaceChar(c)) {
                c = next();
            }
            return c;
        }

        boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
    }
}