#include using namespace std; vector costlyIntervals(int n, int k, vector A) { vector r (n,-1); for (int i = 0; i < n; i++) { int mx = 0, mn = A[i], o = 0, a = A[i]; int l = -10; for (int j = i; j < n; j++) { mx = max(A[j],mx), mn = min(A[j],mn); a &= A[j], o |= A[j]; if (o-mx+mn-a >= k) l = j; } mx = l-i+1; for (; l >= i; l--) r[l] = max(r[l],mx); } return r; } 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; }