#include using namespace std; int getMaxCost(vector& A, int l, int r){ int OR = A[l], AND = A[l], MAX = A[l], MIN = A[l]; for(int i = l + 1; i <= r; i++){ OR |= A[i]; AND &= A[i]; MAX = max(MAX, A[i]); MIN = min(MIN, A[i]); } return ((OR - AND) - (MAX - MIN)); } vector costlyIntervals(int n, int k, vector & A) { vectorres(n, -1); for(int i = 0; i < n; i++){ int cost = -1; int l = i; for(int j = i; j < n; j++){ int tmp = getMaxCost(A, i, j); if(tmp >= k){ cost = tmp; l = j; } } if(cost >= k){ for(int j = i; j <= l; j++) res[j] = max(res[j], l - i + 1); } } return res; } int main() { int n; int k; cin >> n >> k; vector A(n); for(int A_i = 0; A_i < n; A_i++){ cin >> A[A_i]; } vector result = costlyIntervals(n, k, A); for (ssize_t i = 0; i < result.size(); i++) { cout << result[i] << (i != result.size() - 1 ? "\n" : ""); } cout << endl; return 0; }