#include using namespace std; #include #include using namespace __gnu_pbds; template using ordered_set = tree, rb_tree_tag, tree_order_statistics_node_update>; typedef long long ll; typedef long double ld; typedef pair pl; typedef vector vl; #define sl(x) scanf("%d",&x) #define pl(x) printf("%d\n",x) #define sz(x) ((int)x.size()) #define s(x) sort(x.begin(),x.end()) #define all(v) v.begin(),v.end() #define debug(x) cerr << #x << " " << x << "\n"; #define debug2(x, n) cerr << #x << "\n"; f(i, n) cerr << i << " " << x[i] << "\n"; #define r(v) {reverse(all(v));} #define pb push_back #define F first #define S second #define f(i,n) for(int i=0;i T power2(T a, ll b) { if(b == 0) return 1; if(b == 1) return a; T x = power2(a, b / 2); x = x * x; if(b % 2) x = x * a; return x;} ll gcd(ll a, ll b) {if(a < b) swap(a, b); while(b) {ll t = b; b = a % b; a = t;} return a;} ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;} ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;} ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;} ll n, a[N], k, st[4 * N], lazy[4 * N]; void push(ll id, ll s, ll e) { if(!lazy[id]) return; st[id] = max(st[id], lazy[id]); if(s != e) { lazy[id + id] = max(lazy[id + id], lazy[id]); lazy[id + id + 1] = max(lazy[id + id + 1], lazy[id]); } lazy[id] = 0; } ll query(ll id, ll s, ll e, ll l, ll r) { push(id, s, e); if(s > e || s > r || l > e) return 0; if(l <= s && e <= r) return st[id]; ll m = (s + e) >> 1; return max(query(id + id, s, m, l, r), query(id + id + 1, m + 1, e, l, r)); } void update(ll id, ll s, ll e, ll l, ll r, ll v) { push(id, s, e); if(s > e || s > r || l > e) return; if(l <= s && e <= r) { lazy[id] = max(lazy[id], v); push(id, s, e); return; } ll m = (s + e) >> 1; update(id + id, s, m, l, r, v); update(id + id + 1, m + 1, e, l, r, v); st[id] = max(st[id + id], st[id + id + 1]); } void st1() { cin >> n >> k; f(i, n) cin >> a[i]; f(i, n) { ll O = a[i]; ll A = a[i]; ll MA = a[i]; ll MI = a[i]; ll curr; for(ll j = i; j < min(n, i + 1000ll); j++) { MA = max(MA, a[j]); MI = min(MI, a[j]); A = A & a[j]; O = O | a[j]; curr = O - A - MA + MI; if(curr >= k) update(1, 0, n - 1, i, j, j - i + 1); } } f(i, n) { ll lol = query(1, 0, n - 1, i, i); if(!lol) lol = -1; cout << lol << "\n"; } } int main() { ios_base::sync_with_stdio(0); ll t = 1; while(t--) st1(); return 0; }