#include #include #include #include #include #include #include #include #include #include #include #include #include #include #define all(x) x.begin() , x.end() #define fi first #define se second #define pb push_back #define umax( x , y ) x = max( x , (y) ) #define umin( x , y ) x = min( x , (y) ) #define For( i , a ) for(int i=1;i<=a;i++) #define ort (b+s)/2 #define y2 asrwjaelkf #define y1 asseopirwjaelkf #define set multiset using namespace std; inline int read() { int res = 0 ;int neg ; while(true){char ch = getchar();if(ch>='0' && ch<='9' || ch=='-'){if(ch=='-') neg = -1;else neg = 1 , res = ch-'0';break;} } while(true){char ch = getchar();if(ch>='0' && ch<='9') res*=10 , res+=ch-'0';else break;} return res*neg; } typedef long long Lint; typedef double db; typedef pair ii; typedef pair dd; typedef pair di; typedef pair iii; typedef pair i4; const int maxn = 100020; const int maxm = 10000020; const int MOd = 1e9 + 7; int a, K; int rmq[maxn][18][4]; int us[maxn], ar[maxn]; vector w[maxn]; int nex[30]; inline int op( int a, int b, int tp ) { if( tp == 2 ) return max(a,b); else if( tp == 3 ) return min(a,b); else if( tp == 0 ) return a|b; return a&b; } int query( int l, int r, int tp ) { int k = us[r-l+1]; return op( rmq[l][k][tp], rmq[r-(1<>1,r=(r-1)>>1) { if( l&1 ) umax( ans[l], t ); if( ~r&1 ) umax( ans[r], t ); } } int main() { //freopen("asd.in","r",stdin); //freopen("out.txt","w",stdout); scanf("%d %d",&a,&K); for(int i=1;i<=a;i++) { scanf("%d",&ar[i]); for(int tp=0;tp<4;tp++) rmq[i][0][tp] = ar[i]; } for(int i=1,j=0;i<=a;i++) { us[i] = j; if( i == 1<<(j+1) ) j++; } n = 1; while( n < a ) n <<= 1; for(int i=1;i=1;i--) { vector v; for(int j=0;j<30;j++) { if( (ar[i]^ar[i+1])&(1<=0;j--) { int l = w[i][j]; int r = w[i][j+1]-1; int val = query( i, l, 0 ) - query( i, l, 1 ) - K; //printf("asd %d %d --> val=%d -- %d %d\n",i,l,val,query( i, l, 2 ), query( i, l, 3 )); if( query( i, l, 2 ) - query( i, l, 3 ) <= val ) { while( l < r ) { int m = (l+r+1)/2; if( query( i, m, 2 ) - query( i, m, 3 ) <= val ) l = m; else r = m-1; } up( i, l, l-i+1 ); break; } } } for(int i=1;i<=a;i++) { int val = -1; for(int k=i+n-1;k;k>>=1) umax( val, ans[k] ); printf("%d\n",val); } return 0; }