/*二分查找(范围统计)*/
#include <iostream>
#include<algorithm>
#include<queue>
#include<stack>
#include<cmath>
#include<string.h>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
#define maxn 1000
int A[maxn];
int lower_bound1(int *A,int x,int y,int v)//二分查找求下界
{
int m;
while(x<y)
{
m=x+(y-x)/2;
if(A[m]>=v)//看区别
y=m;
else
x=m+1;
}
return x;
}
int upper_bound1(int *A,int x,int y,int v)//二分查找求上界
{
int m;
while(x<y)
{
m=x+(y-x)/2;
if(A[m]<=v)//看区别
x=m+1;
else
y=m;
}
return x;
}
int main()
{
int n,v;
while(~scanf("%d%d",&n,&v))
{
for(int i=0; i<n; i++)
{
A[i]=2*i;
printf("%d ",A[i]);
}
printf("\n%d\n",upper_bound(A,A+n,v+8)-lower_bound(A,A+n,v));//STL自带的
/*范围统计*/
printf("\n%d\n",lower_bound1(A,0,n,v));
printf("\n%d\n",upper_bound1(A,0,n,v));
}
return 0;
}