import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static class MyElement { public int max; public int min; public int or; public int and; public MyElement(int max, int min, int or, int and) { this.max = max; this.min = min; this.or = or; this.and = and; } public int getCost() { return or - and - (max - min); } } static int[] costlyIntervals(int n, int k, int[] A) { // Return a list of length n consisting of the answers int[] maxSizes = new int[n]; for (int i = 0; i < n; i++) { maxSizes[i] = -1; } int[] indices = new int[n]; for (int i = 0; i < n; i++) { indices[i] = -1; } MyElement[] elements = new MyElement[n]; for (int i = 0; i < n; i++) { elements[i] = new MyElement(A[i], A[i], A[i], A[i]); } if (k == 0) { for (int i = 0; i < n; i++) { maxSizes[i] = 1; indices[i] = i; } } int size = 2; for (int i = n - 1; i >= 0; i--) { for (int j = 0; j < i; j++) { if (elements[j + 1].max > elements[j].max) { elements[j].max = elements[j + 1].max; } if (elements[j + 1].min < elements[j].min) { elements[j].min = elements[j + 1].min; } elements[j].or |= elements[j + 1].or; elements[j].and &= elements[j + 1].and; if (elements[j].getCost() >= k && size > maxSizes[j]) { maxSizes[j] = size; indices[j] = j + size - 1; } } size++; } int i = 0; int count = 0; int m = -1; while (i < n) { if (count > 0) { if (m > maxSizes[i]) { maxSizes[i] = m; indices[i] = indices[i - 1]; } else { count = 0; } } if (maxSizes[i] > 1 && i + maxSizes[i] - 1 == indices[i]) { count = maxSizes[i]; m = maxSizes[i]; } i++; count--; } return maxSizes; } public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt(); int[] A = new int[n]; for(int A_i = 0; A_i < n; A_i++){ A[A_i] = in.nextInt(); } int[] result = costlyIntervals(n, k, A); for (int i = 0; i < result.length; i++) { System.out.print(result[i] + (i != result.length - 1 ? "\n" : "")); } System.out.println(""); in.close(); } }