using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static int[] costlyIntervals(int n, int k, int[] a) { // Return a list of length n consisting of the answers int[] res = new int[n]; for (int i = 0; i < n; i++) res[i] = -1; for (int i = 0; i < n; i++){ int or = a[i]; int and = a[i]; int max = a[i]; int min = a[i]; for (int j = i + 1; j < n; j++){ or = or | a[j]; and = and & a[j]; max = Math.Max(a[j], max); min = Math.Min(a[j], min); int cost = (or - and) - (max - min); if (cost >= k){ int len = j - i + 1; for (int m = i; m <= j; m++){ res[m] = Math.Max(res[m], len); } } } } return res; } static void Main(String[] args) { string[] tokens_n = Console.ReadLine().Split(' '); int n = Convert.ToInt32(tokens_n[0]); int k = Convert.ToInt32(tokens_n[1]); string[] A_temp = Console.ReadLine().Split(' '); int[] A = Array.ConvertAll(A_temp,Int32.Parse); int[] result = costlyIntervals(n, k, A); Console.WriteLine(String.Join("\n", result)); } }