#include #include const int MAXN = 5005; int A[MAXN]{ }; int cost[MAXN][MAXN]{ }; int good[MAXN]{ }; std::set cnt; int K, N; int main() { scanf(" %d%d", &N, &K); for(int i = 1; i <= N; ++i) scanf("%d", &A[i]); for(int i = 1; i <= N; ++i) { int AN, OR; cnt.clear(); AN = OR = A[i]; for(int j = i; j <= N; ++j) { AN &= A[j]; OR |= A[j]; cnt.insert(A[j]); cost[i][j] = (OR+*cnt.begin())-(AN+*cnt.rbegin()); if(cost[i][j] >= K) good[i] = j; } } for(int i = 1; i <= N; ++i) { int ret = -1; for(int j = 1; j <= i; ++j) if(good[j] >= i) ret = std::max(good[j]-j+1, ret); printf("%d\n", ret); } return 0; }