semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
	int n,m;
	cin>>n>>m;
	int a[20][20]={0};
	int x[8]={0,1,0,-1,1,1,-1,-1};
	int y[8]={1,0,-1,0,1,-1,1,-1};
	int taken[20][20]={0};
	a[5][5]=n;
	for ( int p=0;p<m;p++)
	{
		for ( int i=1;i<10;i++)
			for ( int j=1;j<10;j++)
			{
					for( int i_=0;i_<8;i_++)
					{
						taken[i+x[i_]][j+y[i_]]=a[i][j]+taken[i+x[i_]][j+y[i_]];
					}
					taken[i][j]=taken[i][j]+a[i][j]*2;
			}
       for ( int i=1;i<10;i++)
		   for ( int j=1;j<10;j++)
		   {
			  a[i][j]=taken[i][j];
			  taken[i][j]=0;
		   }
	}
	for ( int i=1;i<10;i++)
	{
		for ( int j=1;j<9;j++)
			cout<<a[i][j]<<' ';
		cout<<a[i][9]<<endl;
	}
	
	return 0;
}
int a[11][11]={0};
int b[11][11];
int sum(int x,int y)
{
    b[x][y]=a[x-1][y-1]+a[x-1][y]+a[x-1][y+1]+a[x][y-1]+a[x][y+1]+a[x+1][y-1]+a[x+1][y]+a[x+1][y+1]+2*a[x][y];
    return b[x][y];
}
main()
{
  int m,n,i,j;
  scanf("%d %d",&m,&n);
  a[5][5]=m;
  for(int k=1;k<=n;k++)
  { 
  for(i=5-k;i<=5+k;i++)
  {
    for(j=5-k;j<=5+k;j++)
    {
      b[i][j]=sum(i,j);
    }
  }
  for(int q=0;q<11;q++)
  {
    for(int p=0;p<11;p++)
    a[q][p]=b[q][p];
  }
  }
  for(i=1;i<10;i++)
  {
    for(j=1;j<9;j++)
    printf("%d ",b[i][j]);
    printf("%d\n",b[i][j]);
  }
 return 0;
}
//********************************
//*?????(11.8) ????????   **
//*?????? 1300012745 **
//*???2013.12.5  **
//*******************************

int germs[4][9][9];           //????????????????????

void reproduction (int i, int n)   //i????
{
	int j, k, x, y;         //??????
	if (i == n)             //????n????
		return;
	for (x = 0; x <= 8; x++)
	{
		for (y = 0; y <= 8; y++)
		{
			for (j = -1; j <= 1; j++)
			{
				for (k = -1; k <= 1; k++)
				{
					germs[i + 1][x + j][y + k]+=germs[i][x][y];   //???????????????
				}
			}
			germs[i + 1][x][y]+=germs[i][x][y];      //?????????????????
		}
	}
	reproduction (i + 1, n);                //??????
}

int main()
{
	int n, m, i, j, k;
	cin >> m >> n;
	for (i = 0; i <= 4; i++)
	{
		for (j = 0; j <= 8; j++)
		{
			for (k = 0; k <= 8; k++)
			{
				germs[i][j][k] = 0;     //??
			}
		}
	}
	germs[0][4][4] = m;            //???
	reproduction (0, n);          //??????
	for (i = 0; i <= 8; i++)
	{
		for (j = 0; j <= 8; j++)
		{
			if (j == 8)
				cout << germs[n][i][j];        //???????
			else
				cout << germs[n][i][j] << " ";
		}
		cout << endl;
	}
	cin.get();cin.get();
	return 0;
}
int main(int argc, char* argv[])
{
	int m,n;
	int a[9][9],b[9][9];
	int i,j,k,x,y;

	scanf("%d%d",&m,&n);
	memset(a,0,sizeof(a));
	a[4][4]=m;

	for(k=0;k<n;k++)
	{
		memset(b,0,sizeof(b));
		for(i=1;i<8;i++)
		{
			for(j=1;j<8;j++)
			{
				b[i][j]+=a[i][j];
				for(x=-1;x<=1;x++)
				{
					for(y=-1;y<=1;y++)
					{
						b[i+x][j+y]+=a[i][j];
					}
				}
			}
		}
		memcpy(a,b,sizeof(a));
	}

	for(i=0;i<9;i++)
	{
		for(j=0;j<8;j++){printf("%d ",a[i][j]);}
		printf("%d\n",a[i][8]);
	}
	return 0;
}
//???1000010179
//????????
int x[9][9]={0};//???????
void peiyang()//????????
{
	int temp[9][9]={0},i,j;//temp??????????????????ij?????
	
	//???????temp[i][j]????x[i][j]????????x??
	temp[0][0]=x[0][0]*2+x[0][1]+x[1][0]+x[1][1];
	for (i=1;i<8;i++)
		temp[0][i]=x[0][i]*2+x[0][i-1]+x[0][i+1]+x[1][i-1]+x[1][i]+x[1][i+1];
	temp[0][8]=x[0][8]*2+x[0][7]+x[1][7]+x[1][8];

	for (i=1;i<8;i++)
	{
		temp[i][0]=x[i][0]*2+x[i-1][0]+x[i-1][1]+x[i][1]+x[i+1][0]+x[i+1][1];
		for (j=0;j<8;j++)
			temp[i][j]=x[i][j]*2+x[i-1][j-1]+x[i-1][j]+x[i-1][j+1]+x[i][j-1]+x[i][j+1]+x[i+1][j-1]+x[i+1][j]+x[i+1][j+1];
		temp[i][8]=x[i][8]*2+x[i-1][7]+x[i-1][8]+x[i][7]+x[i+1][7]+x[i+1][8];
	}

	temp[8][0]=x[8][0]*2+x[7][0]+x[7][1]+x[8][1];
	for (i=1;i<8;i++)
		temp[8][i]=x[8][i]*2+x[7][i-1]+x[7][i]+x[7][i+1]+x[8][i-1]+x[8][i+1];
	temp[8][8]=x[8][8]*2+x[7][7]+x[7][8]+x[8][7];

	for (i=0;i<9;i++)//?temp???x
		for (j=0;j<9;j++)
			x[i][j]=temp[i][j];
}
int main()
{
	int m,n;//mn???
	cin>>m>>n;
	x[4][4]=m;//???????m
	for (int k=0;k<n;k++)//??peiyang??n????n?????
		peiyang();
	for (int p=0;p<9;p++)//????
		for (int q=0;q<9;q++)
		{
			if (q==8) cout<<x[p][q]<<endl;
			else cout<<x[p][q]<<' ';
		}
	return 0;
}
int main()
{
    int m,n,i,j,k;
    scanf("%d%d",&m,&n);
    int a[5][11][11]={0};
    a[0][5][5]=m;
    for(i=0;i<n;i++)
    {
        for(j=1;j<10;j++)
        {
           for(k=1;k<10;k++)
           {
               a[i+1][j][k]=a[i][j][k]*2+a[i][j+1][k]
               +a[i][j-1][k]+a[i][j][k+1]
               +a[i][j][k-1]+a[i][j+1][k+1]
               +a[i][j+1][k-1]+a[i][j-1][k+1]
               +a[i][j-1][k-1];
           }
        }
    }
    for(i=1;i<10;i++)
    {
       for(j=1;j<10;j++)
       {
          if(j==1)
          {printf("%d",a[n][i][j]);}
          if(j>1)
          {printf(" %d",a[n][i][j]);}
       }
       if(i<9)
       {printf("\n");}
    }
}
int i,j,k,n;
int num[11][11]={0},num1[11][11]={0},t[11][11]={0};
void turn()
{
	int i,j;
	for(i=0;i<11;i++)
		for(j=0;j<11;j++)
		{
			t[i][j]=num[i][j];
			num[i][j]=num1[i][j];
			num1[i][j]=t[i][j];
		}
}
int main()
{
	cin>>i;
	num[5][5]=i;
	cin>>n;
	for(i=0;i<n;i++)
	{
		for(j=1;j<10;j++)
		{
			for(k=1;k<10;k++)
			{
				num1[j][k]=2*num[j][k]+(num[j][k+1]+num[j][k-1]+num[j+1][k]+num[j-1][k]+num[j+1][k+1]+num[j+1][k-1]+num[j-1][k+1]+num[j-1][k-1]);
			}
		}
		turn();
	}
	for(i=1;i<10;i++)
	{
		for(j=1;j<9;j++)
		{
			cout<<num[i][j]<<' ';
		}
		cout<<num[i][9]<<endl;
	}
	return 0;
}
main()
{
	long a[9][9]={0},b[9][9]={0},m,n;
	scanf("%d %d",&m,&n);
	a[4][4]=b[4][4]=m;
	for(int i=1;i<=n;i++)
	{
	for(int j=4-i;j<=4+i;j++)
	    for(int k=4-i;k<=4+i;k++)
	    {
		    for(int g=j-1;g<=j+1;g++)
	            for(int h=k-1;h<=k+1;h++)
	               if(0<=g&&g<=8&&0<=h&&h<=8)  a[j][k]=a[j][k]+b[g][h];
	        }
	for(int p=0;p<9;p++)
	    for(int q=0;q<9;q++)
	        b[p][q]=a[p][q];
    }
    for(int x=0;x<9;x++)
		for(int y=0;y<9;y++)
		{
		    if(y==0) printf("%d",a[x][y]);
		    else if(y==8) printf(" %d\n",a[x][y]);
			else printf(" %d",a[x][y]);
		} 
}
int num[9][9][5];
int day;
int zz(int d)
{
	int i,j;
	if(d==day+1)
		return 0;
	if(d!=day+1)
	{
	    for(i=0;i<9;i++)
		{
			for(j=0;j<9;j++)
			{
					num[i][j][d]+=2*num[i][j][d-1];
					num[i-1][j-1][d]+=num[i][j][d-1];
					num[i-1][j][d]+=num[i][j][d-1];
					num[i-1][j+1][d]+=num[i][j][d-1];
					num[i+1][j-1][d]+=num[i][j][d-1];
					num[i+1][j][d]+=num[i][j][d-1];
					num[i+1][j+1][d]+=num[i][j][d-1];
					num[i][j+1][d]+=num[i][j][d-1];
					num[i][j-1][d]+=num[i][j][d-1];
			}
		}
	}
	zz(d+1);
	return 0;
}
int main()
{
	int m;
	int i,j,k;
	cin>>m>>day;
	for(i=0;i<9;i++)
	{
		for(j=0;j<9;j++)
		{
			for(k=0;k<day;k++)
				num[i][j][k]=0;
		}
	}
	num[4][4][0]=m;
	zz(1);
	for(i=0;i<9;i++)
	{
		for(j=0;j<9;j++)
		{
			if(j!=8)
				cout<<num[i][j][day]<<" ";
			if(j==8)
				cout<<num[i][j][day]<<'\n';
		}
	}
	return 0;
}
int main()
{
long i,j,k,n,m,a[10][10],b[10][10];
    for (j=1;j<=9;j++)
       for (k=1;k<=9;k++)
          a[k][j]=b[k][j]=0;
scanf("%d%d",&a[5][5],&n);
m=a[5][5];b[5][5]=m;
for (i=1;i<=n;i++)
    {
    for (j=1;j<=9;j++)
       for (k=1;k<=9;k++)
          if (a[k][j]!=0) 
             {
               m=a[k][j];
               b[k][j]=b[k][j]+m;b[k+1][j]=b[k+1][j]+m;b[k-1][j]=b[k-1][j]+m;
               b[k][j+1]=b[k][j+1]+m;b[k][j-1]=b[k][j-1]+m;
               b[k+1][j+1]=b[k+1][j+1]+m;b[k+1][j-1]=b[k+1][j-1]+m;
               b[k-1][j-1]=b[k-1][j-1]+m;b[k-1][j+1]=b[k-1][j+1]+m;
              }
    for (j=1;j<=9;j++)
       for (k=1;k<=9;k++)
          a[k][j]=b[k][j];
    }
    for (j=1;j<=9;j++)
       {
        for (k=1;k<=8;k++)
            printf("%d ",a[k][j]);
        printf("%d\n",a[9][j]);
        }
}
int main()
{
	int row,col,i,a[N][N],b[N][N],n,d;
	for(row=0;row<N;row++)
		for(col=0;col<N;col++)
           a[row][col]=0;

	scanf("%d %d",&a[4][4],&d);
    
	
	for(i=0;i<d;i++)
	{
		for(row=0;row<N;row++)
		for(col=0;col<N;col++)
           b[row][col]=0;

	      for(row=0;row<N;row++)
		  {
		       for(col=0;col<N;col++)
			   {
                    if(a[row][col]!=0)
					{
                        b[row-1][col-1]+=a[row][col];
						b[row][col-1]+=a[row][col];
						b[row+1][col-1]+=a[row][col];
						b[row-1][col]+=a[row][col];
						b[row+1][col]+=a[row][col];
						b[row-1][col+1]+=a[row][col];
						b[row][col+1]+=a[row][col];
						b[row+1][col+1]+=a[row][col];
						a[row][col]*=2;

					}
			   }
		  }
          for(row=0;row<N;row++)
		  {
			  for(col=0;col<N;col++)
			  {
				  a[row][col]=a[row][col]+b[row][col];
			  }
		  }

	}

	
	for(row=0;row<N;row++)
	{
		for(col=0;col<N-1;col++)
		{
			printf("%d ",a[row][col]);
		}
		printf("%d\n",a[row][N-1]);
	}
	return 0;
}
int main()
{
    int i,j,k,n,m,a[12][12]={0},b[12][12]={0};   // b????????? 
    cin>>m>>n;                 //???? 
    for (j=1;j<=9;j++)
        {
            for (k=1;k<=9;k++)
            {
                b[j][k]=0;               //??b 
            }
        }  
    b[5][5]=m;                //???? 
    for (i=0;i<n;i++)
    {
        for (j=1;j<=9;j++)
        {
            for (k=1;k<=9;k++)
            {
                a[j][k]=b[j][k];             //a????b??? 
            }
        }      
        for (j=1;j<=9;j++)
        {
            for (k=1;k<=9;k++)                      //??????a???????????b? 
            {
                b[j-1][k-1] +=a[j][k];
                b[j-1][k] +=a[j][k];
                b[j-1][k+1] +=a[j][k];
                b[j][k-1] +=a[j][k];
                b[j][k] +=a[j][k];
                b[j][k+1] +=a[j][k];
                b[j+1][k-1] +=a[j][k];
                b[j+1][k] +=a[j][k];
                b[j+1][k+1] +=a[j][k];
            }
        }
    }
    for (j=1;j<=9;j++)               //??????????? 
    {
        for (k=1;k<=9;k++)
        {
            cout<<b[j][k];
            if (k!=9) cout<<" ";            
        }
        cout<<endl;
    }
    return 0;
}
int main()
{
	struct point
	{
		int a[11][11];
	}
	days[5];
	int a[11][11]={0},i,j,day,n,m;
	scanf("%d%d",&m,&n);
	for(day=0;day<=n;day++)	for(i=0;i<=10;i++)	for(j=0;j<=10;j++)	days[day].a[i][j]=0;
	days[0].a[5][5]=m;
	for(day=1;day<=n;day++)	for(i=1;i<=9;i++)	for(j=1;j<=9;j++)	
		days[day].a[i][j]
		=days[day-1].a[i-1][j-1]	
		+days[day-1].a[i-1][j]+days[day-1].a[i-1][j+1]
		+days[day-1].a[i][j-1]+days[day-1].a[i][j]+days[day-1].a[i][j]
		+days[day-1].a[i][j+1]+days[day-1].a[i+1][j-1]+days[day-1].a[i+1][j]
		+days[day-1].a[i+1][j+1];
	for(i=1;i<=9;i++)
	{
		for(j=1;j<9;j++)	printf("%d ",days[n].a[i][j]);
		printf("%d\n",days[n].a[i][9]);
	}
	return 0;

}
//***************************
//*???????????  **
//*?????? 1300012965 **
//*???20131204          **
//***************************
int a[10][10] = {0},biaoji[10][10] = {0};
void f(int n)
{
	int p, q, u, v;
	if(n == 0)
		return;
	for(p=1; p <= 9; p++)
		for(q=1; q <= 9; q++)
		{
			if(a[p][q] != 0)
			{
				biaoji[p][q] += 2*a[p][q];//???????
				biaoji[p-1][q+1] += a[p][q];
				biaoji[p-1][q] += a[p][q];
				biaoji[p-1][q-1] += a[p][q];
				biaoji[p][q-1] += a[p][q];
				biaoji[p][q+1] += a[p][q];
				biaoji[p+1][q-1] += a[p][q];
				biaoji[p+1][q] += a[p][q];
				biaoji[p+1][q+1] += a[p][q];
			}
		}
	for(u=1; u<=9; u++)
		for(v=1; v<=9; v++)
			a[u][v] = biaoji[u][v];//????????
	memset(biaoji,0,sizeof(biaoji));//????
	f(n-1);//??
}

int main()
{
	int m, n, i, j;
	cin >> m >> n;
	a[5][5] = m;//??????
	f(n);
	for(i=1; i<=9; i++)
	{
		cout << a[i][1];
		for(j = 2; j <= 9; j++)
			cout << " " << a[i][j];
		cout << endl;
	}
	return 0;
}
int main(){
	int m,n,i,j,r,k,h;
	scanf("%d%d",&m,&n);
	int a[11][11]={0};
	a[5][5]=m;
	for(h=0;h<n;h++){
		int b[11][11]={0};
	for(i=1;i<10;i++){
		for(j=1;j<10;j++){
			if(a[i][j]!=0){
				for(r=i-1;r<=i+1;r++){
					for(k=j-1;k<=j+1;k++){
						b[r][k]+=a[i][j];
					}
				}
			}
		}
	}
	for(i=1;i<10;i++){
		for(j=1;j<10;j++){
			a[i][j]+=b[i][j];
		}
	}
	}
	for(i=1;i<10;i++){
		for(j=1;j<10;j++){
			if(j!=9)
				printf("%d ",a[i][j]);
			else
				printf("%d\n",a[i][j]);
		}
	}
}
//********************
//**????????**
//**?? 1100012915***
//********11.28*******
//********************

int m, n, i, j ;

int bac( int day, int i, int j )
{
	if ( ( day == 0 ) && ( i == 5 ) && ( j == 5 ) )		//?0? ?????????m?
		return m ;
	else if ( ( i >= 5 - day ) && ( i <= 5 + day ) && 
		( j >= 5 - day ) && ( j <= 5 + day ) )			//?day? ??????? ??????????????????????
		return ( bac(day - 1, i - 1, j - 1) + bac(day - 1, i - 1, j) 
					+ bac(day - 1, i - 1, j + 1) + bac(day - 1, i, j - 1)
					+ bac(day - 1, i, j + 1) + bac(day - 1, i + 1, j - 1)
					+ bac(day - 1, i + 1, j) + bac(day - 1, i + 1, j + 1) 
					+ 2 * bac(day - 1, i, j) ) ;
	else 
		return 0 ;
}

int main()
{
	cin >> m >> n ;
	for ( i = 1; i <= 9; i ++ )
	{
		for ( j = 1; j <= 8; j ++ )
			cout << bac( n, i, j ) << " " ;
		cout << bac( n, i, 9 ) << endl ;
	}
	return 0 ;
}
main()
{
	int a[11][11];
	int b[11][11];
	int m,n;
	for(int i=0;i<11;i++)
	{
	    for(int j=0;j<11;j++)
	    {
			a[i][j]=0;
			b[i][j]=0;
		}
	}
	scanf("%d %d",&m,&n);
	a[5][5]=m;
	for(int z=0;z<n;z++)
	{
		for(int x=1;x<10;x++)
	    {
			for(int y=1;y<10;y++)
	        {
				b[x][y]=a[x+1][y]+a[x-1][y]+a[x][y+1]+a[x][y-1]+a[x+1][y+1]+a[x+1][y-1]+a[x-1][y+1]+a[x-1][y-1];
			}
		}
		for(int x=1;x<10;x++)
	    {
			for(int y=1;y<10;y++)
	        {
				a[x][y]=2*a[x][y]+b[x][y];
			}
		}
	}	
	for(int x=1;x<10;x++)
	    {
			printf("%d",a[x][1]);
			for(int y=2;y<10;y++)
	        {
				printf(" %d",a[x][y]);
			}
			printf("\n");
		}
}
int a[10][10];
int b[10][10];
int n;
void inf(int m)
{
  int i,j;
  for(i = 1;i <= 9;i++)     
     for(j = 1;j <= 9;j++)
     {
        b[i][j] = 2*a[i][j]+a[i][j+1]+a[i+1][j]+a[i][j-1]+a[i-1][j]+a[i+1][j+1]+a[i-1][j-1]+a[i+1][j-1]+a[i-1][j+1];
     }
  for(i = 1;i <= 9;i++)     
     for(j = 1;j <= 9;j++)
        a[i][j] = b[i][j];
   if(m < n) inf(m+1);
}
int main()
{
  int i,j;
  scanf("%d%d",&a[5][5],&n);
  inf(1); 
  for(i = 1;i <= 9;i++)
  {     
     for(j = 1;j <= 8;j++)
        printf("%d ",a[i][j]);
     printf("%d\n",a[i][9]);
  }
  return 0;    
}
int main()
{
    int a[10][10],t[10][10];
    int time=0,i=0,j=0,k=0;
    for(i=1;i<10;i++)
       for(j=1;j<10;j++)
       a[i][j]=0;
    cin>>a[5][5]>>time;
    for(i=0;i<time;i++)
      {
          for(j=5-i;j<=5+i;j++)
            for(k=5-i;k<=5+i;k++)
            t[j][k]=a[j][k];
          for(j=5-i;j<=5+i;j++)
            for(k=5-i;k<=5+i;k++)
            {
               a[j-1][k-1]=a[j-1][k-1]+t[j][k];
               a[j-1][k]=a[j-1][k]+t[j][k];
               a[j-1][k+1]=a[j-1][k+1]+t[j][k];
               a[j][k-1]=a[j][k-1]+t[j][k];
               a[j][k]=a[j][k]+t[j][k];
               a[j][k+1]=a[j][k+1]+t[j][k]; 
               a[j+1][k-1]=a[j+1][k-1]+t[j][k]; 
               a[j+1][k]=a[j+1][k]+t[j][k]; 
               a[j+1][k+1]=a[j+1][k+1]+t[j][k]; 
                      
            }
      }
    for(i=1;i<10;i++)
       {
             for(j=1;j<=8;j++)
                cout<<a[i][j]<<" ";
             cout<<a[i][9]<<endl;
       }
       return 0;
}
int main()
{
    int k,n;
    scanf("%d%d",&k,&n);
    int a[12][12][5];
    int i,j,l,x;
    for(i=1;i<=11;i++)
    {
                     for(j=1;j<=11;j++)
                     {
                                       for(l=0;l<=4;l++)
                                       {
                                                         a[i][j][l]=0;
                                       }
                     }
    }
    a[6][6][0]=k;
    for(l=1;l<=n;l++)
    {
                     for(i=2;i<=10;i++)
                     {
                                       for(j=2;j<=10;j++)
                                       {
                                                         a[i][j][l]=
                                                         a[i-1][j-1][l-1]
                                                         +a[i-1][j][l-1]
                                                         +a[i-1][j+1][l-1]
                                                         +a[i][j-1][l-1]
                                                         +a[i][j+1][l-1]
                                                         +a[i+1][j-1][l-1]
                                                         +a[i+1][j][l-1]
                                                         +a[i+1][j+1][l-1]
                                                         +2*a[i][j][l-1];
                                       }
                     }
    }
    for(i=2;i<=9;i++)
    {
                     for(j=2;j<=9;j++)
                     {
                                      printf("%d ",a[i][j][n]);
                     }
                     printf("%d\n",a[i][10][n]);
    }                                     
     for(j=2;j<=9;j++)
     {
                      printf("%d ",a[10][j][n]);
     }
     printf("%d",a[10][10][n]);
     //scanf("%d",&l);
     return 0;
}
int main()
{
    int zhen[11][11],zhen2[11][11],m,n,i,j,k,hang1,hang2;
    for(i=0;i<=10;i++)
    {
                     for(j=0;j<=10;j++)zhen[i][j]=0;
    }
    cin>>m>>n;
    zhen[5][5]=m;//??????? 
    hang1=5;
    hang2=5;
    for(k=1;k<=n;k++)
    {
                    
                    for(i=0;i<=10;i++)
                     {
                       for(j=0;j<=10;j++)zhen2[i][j]=zhen[i][j];//?????????????????????????? 
                     } 
                     for(i=hang1-1;i<=hang2+1;i++)
                     {
                                      for(j=hang1-1;j<=hang2+1;j++)zhen[i][j]=zhen2[i-1][j-1]+zhen2[i-1][j]+zhen2[i-1][j+1]+zhen2[i][j-1]+2*zhen[i][j]+zhen2[i][j+1]+zhen2[i+1][j-1]+zhen2[i+1][j]+zhen2[i+1][j+1];
                     }//?????????? 
                     hang1=hang1-1;
                     hang2=hang2+1;//???????            
    }
    for(i=1;i<=9;i++)
    {
                     for(j=1;j<=9;j++)
                     {cout<<zhen[i][j];
                     if(j<9)cout<<" ";
                     }
                     cout<<endl;//?? 
    }
    cin.get();cin.get();cin.get();cin.get();cin.get();
return 0;
}
int a[9][9], b[9][9];

int main()
{
	int m, day;
	cin >> m >> day;
	memset(a, 0, sizeof(a));
	memset(b, 0, sizeof(b));
	b[4][4] = m;
	for (int i = 0; i < day; i++)
	{
		memset(a, 0, sizeof(a));
		for (int p = 0; p < 9; p++)
		{
			for (int q = 0; q < 9; q++)
			{
				if (b[p][q] != 0)
				{
					a[p][q] = a[p][q] + 2 * b[p][q];
					if (p - 1 >= 0)  a[p - 1][q] += b[p][q];
					if (p + 1 < 9)  a[p + 1][q] += b[p][q];
				    if (q - 1 >= 0)  a[p][q - 1] += b[p][q];
					if (q + 1 < 9)  a[p][q + 1] += b[p][q];
					if (p - 1 >= 0 && q - 1 >= 0) a[p - 1][q - 1] += b[p][q];
					if (p + 1 < 9 && q + 1 < 9) a[p + 1][q + 1] += b[p][q];
                    if (p - 1 >= 0 && q + 1 < 9) a[p - 1][q + 1] += b[p][q];
					if (p + 1 < 9 && q - 1 >= 0) a[p + 1][q - 1] += b[p][q];
				}
			}
		}
		for (int g = 0; g < 9; g++)
		{
			for (int h = 0; h < 9; h++)
			{
				b[g][h] = a[g][h];
			}
		}
	}
	for (int s = 0; s < 9; s++)
	{
		cout << a[s][0];
		for (int t = 1; t < 9; t++)
		{
			cout << ' ' << a[s][t]; 
		}
		cout << endl;
	}
    return 0;
}
int germ[10][10]={0};           //???????????
int m=0,n=0;
void work();
int main()
{
    cin>>m>>n;
    work();
    for(int i=1;i<10;i++)       //??
    {
        for(int j=1;j<9;j++)
            cout<<germ[i][j]<<' ';
        cout<<germ[i][9]<<endl;
    }
    return 0;
}
void work()
{
    germ[5][5]=m;
    int ngerm[10][10]={0};      //????????????
    for(int i=0;i<n;i++)
    {
        int j,k,p,q;
        for(j=1;j<=9;j++)
            for(k=1;k<=9;k++)  // ?????????
                {              // ????????
                    if(germ[j][k]!=0)
                    {
                        for(p=j-1;p<=j+1;p++)
                            for(q=k-1;q<=k+1;q++)
                                ngerm[p][q]+=germ[j][k];
                        ngerm[j][k]+=germ[j][k];
                    }
                }
        for(j=1;j<=9;j++)    //????????????
            for(k=1;k<=9;k++)//??????
            {
                germ[j][k]=ngerm[j][k];
                ngerm[j][k]=0;
            }
    }
}
const int dx[8] = {-1, -1, 0 , 1, 1, 1, 0, -1},
          dy[8] = {0 , -1, -1, -1, 0, 1, 1, 1};
int a[9][9];

int number (int x, int y, int day)
{
    if (day == 0) return a[x][y];
    
    int v = 0;
    
    for (int i = 0; i < 8; ++i)
      if (x + dx[i] >=0 && x + dx[i] < 9 && y + dy[i] >= 0 && y + dy[i] < 9)
          v += number(x + dx[i], y + dy[i], day - 1);
    
    v +=  2 * number(x, y, day - 1);
    
    return v;
}

int main()
{
    int m, n;
    
    cin >> m >> n;
    
    for (int j = 0; j < 9; ++j)
      for (int k = 0; k < 9; ++k)
        a[j][k] = 0;
    
    a[4][4] = m;

    for (int j = 0; j < 9; ++j)
    {
        for (int k = 0; k < 9; ++k)
        {
            if (k != 0) cout << " ";
            cout << number(j, k, n);
        }
        cout << endl;
    }
    return 0;
}
int main()
{
	int i,j,k,m,n;
	int xijun[11][11],next[11][11];
	cin>>m>>n;
	for(i=0;i<=10;i++)
	{
		for(j=0;j<=10;j++)
		{
			xijun[i][j]=0;
			next[i][j]=0;
		}
	}
	xijun[5][5]=next[5][5]=m;
	for(i=1;i<=n;i++)
	{
		
		for(j=1;j<=9;j++)
		{
			for(k=1;k<=9;k++)
			{
					next[j][k]+=xijun[j][k];
				    next[j-1][k]+=xijun[j][k];
					next[j-1][k-1]+=xijun[j][k];
					next[j-1][k+1]+=xijun[j][k];
					next[j][k-1]+=xijun[j][k];
					next[j][k+1]+=xijun[j][k];
					next[j+1][k-1]+=xijun[j][k];
					next[j+1][k]+=xijun[j][k];
					next[j+1][k+1]+=xijun[j][k];;
			}
		}
		for(j=1;j<=9;j++)
		{
			for(k=1;k<=9;k++)
			{
				xijun[j][k]=next[j][k];
			}
		}
	}
	for(i=1;i<=9;i++)
	{
		for(j=1;j<=8;j++)
		{
			cout<<xijun[i][j]<<" ";
		}
		cout<<xijun[i][9]<<endl;
	}
	return 0;
}
int main(){
	static int n,a[10][100][100];
	cin>>a[0][5][5];
	cin>>n;
	for(int i=1;i<=n;i++){
		for(int x=1;x<=9;x++)
			for(int y=1;y<=9;y++)
				a[i][x][y]=a[i-1][x][y]*2+a[i-1][x-1][y]+a[i-1][x+1][y]+a[i-1][x][y-1]+a[i-1][x][y+1]+a[i-1][x-1][y-1]+a[i-1][x-1][y+1]+a[i-1][x+1][y-1]+a[i-1][x+1][y+1];
	}
	for(int i=1;i<=9;i++)
		for(int j=1;j<=9;j++){
			if(j-1)cout<<' ';
			cout<<a[n][i][j];
			if(j==9)cout<<endl;
		}
	//cin>>n;
	return 0;
}
int main()
{
	int m,n,i,j,a,b,sz[11][11],de[11][11];
	scanf("%d%d",&m,&n);
	for(i=0;i<11;i++){
		for(j=0;j<11;j++){
			sz[i][j]=0;
			de[i][j]=0;
		}
	}
	de[5][5]=m;
	for(a=0;a<n;a++){
		for(i=1;i<10;i++){
			for(j=0;j<10;j++){
				sz[i][j]=de[i][j];
			}
		}
		for(i=1;i<10;i++){
			for(j=1;j<10;j++){
				if(sz[i][j]!=0){
					b=sz[i][j];
					de[i][j+1]=de[i][j+1]+b;
					de[i][j-1]=de[i][j-1]+b;
					de[i-1][j]=de[i-1][j]+b;
					de[i+1][j]=de[i+1][j]+b;
					de[i-1][j-1]=de[i-1][j-1]+b;
					de[i-1][j+1]=de[i-1][j+1]+b;
					de[i+1][j-1]=de[i+1][j-1]+b;
					de[i+1][j+1]=de[i+1][j+1]+b;
					de[i][j]=de[i][j]+b;
					}								
			}
		}			
	}
	for(i=1;i<10;i++){
		for(j=1;j<10;j++){
			if(j<9)
				printf("%d ",de[i][j]);
			else
				printf("%d\n",de[i][j]);
		}
	}
	return 0;
}
int cell[20][20];//total simulation array
struct cell_q
{
	int px,py,num;
} queue[10000];

void Grow(int px,int py,int num)
{
	cell[px][py]+=num;
	cell[px-1][py]+=num;
	cell[px+1][py]+=num;
	cell[px][py-1]+=num;
	cell[px][py+1]+=num;
	cell[px-1][py-1]+=num;
	cell[px-1][py+1]+=num;
	cell[px+1][py-1]+=num;
	cell[px+1][py+1]+=num;
	return;
}

int main()
{
	int n,m,x,y,d;
	cin>>m>>n;
	cell[5][5]=m;
	int head=0,tail=0;
	for(d=1;d<=n;d++)
	{
		for(x=1;x<=9;x++)
		{
			for(y=1;y<=9;y++)
			{
				if(cell[x][y]!=0)
				{
					queue[tail].px=x;
					queue[tail].py=y;
					queue[tail].num=cell[x][y];
					tail++;//Stand by for growth
				}
			}
		}
		while(head<tail)
		{
			Grow(queue[head].px,queue[head].py,queue[head].num);
			head++;
		}
	}
	for(x=1;x<=9;x++)
	{
		for(y=1;y<=8;y++)
		{
			cout<<cell[x][y]<<' ';
		}
		cout<<cell[x][9]<<endl;
	}
	return 0;
}
int a[11][11] = {0};
int b[11][11] = {0};

void f()
{
	int u, v;
	for (u = 1; u <= 9; u++)
	{
		for (v = 1; v <= 9; v++)
		{
			b[u][v] = 2 * a[u][v] + a[u - 1][v] + a[u + 1][v] + a[u][v - 1] + a[u][v + 1] + a[u - 1][v - 1] + a[u - 1][v + 1] + a[u + 1][v - 1] + a[u + 1][v + 1];
		}
	}
	for (u = 1; u <= 9; u++)
	{
		for (v = 1; v <= 9; v++)
		{
			a[u][v] = b[u][v];
		}
	}
}

void print()
{
	int i, j;
	for(i = 1; i <= 9; i++)
	{
		for (j = 1; j <= 8; j++)
		{
			cout << a[i][j] << " ";
		}
		cout << a[i][9] << endl;
	}
	return;
}


int main()
{
	int n, m;
	cin >> n >> m;
	a[5][5] = n;
	b[5][5] = n;
	while (m > 0)
	{
		f();
		m--;
	}
	print();
	return 0;
}