semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
main()
{
    int m,n;
    scanf("%d",&m);
    scanf("%d",&n);
    int a[11][11];
    int b[9][9];
    for(int i=0;i<11;i++)
    {
        for(int j=0;j<11;j++)
        {
            a[i][j]=0;
        }
    }
    a[5][5]=1;
    for(int i=0;i<9;i++)
    {
        for(int j=0;j<9;j++)
        {
            b[i][j]=0;
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<9;j++)
        {
            for(int k=0;k<9;k++)
            {
                b[j][k]=2*a[j+1][k+1]+a[j][k]+a[j][k+1]+a[j][k+2]+a[j+1][k]+a[j+1][k+2]+a[j+2][k]+a[j+2][k+1]+a[j+2][k+2];
            }
        }
        for(int j=0;j<9;j++)
        {
            for(int k=0;k<9;k++)
            {
                a[j+1][k+1]=b[j][k];
            }
        }
    }
        for(int i=0;i<9;i++)
        {
            for(int j=0;j<8;j++)
            {
                printf("%d ",b[i][j]*m);
            }
            printf("%d\n",b[i][8]*m);
        }
}
//**************************
//*???2013?12?4?     *
//*??????            *
//*???????????  *
//**************************

int board[11][11] = {0}, next[11][11] = {0};
int m, i, j, cnt = 0, days;
void spread(int days);
int main ()
{
	cin >> m >> days;
	board[5][5] = m;
	spread(days);
	for(i = 1; i <= 9; i++)
	{
		for(j = 1; j <= 9; j++)
		{
			if(j < 9)
				cout << board[i][j] << " ";
			else
				cout << board[i][j];
		}
		cout << endl;
	}
	return 0;
}

void spread(int days)
{
	if(cnt == days)
		return;
	cnt++;
	for(i = 1; i <= 9; i++)
	{
		for(j = 1; j <= 9; j++)
		{
			next[i][j] = board[i-1][j] + board[i+1][j] + board[i][j-1] + board[i][j+1] + 
				board[i+1][j+1] + board[i-1][j-1] + board[i+1][j-1] + board[i-1][j+1] + board[i][j] * 2;
		}
	}
	for(i = 1; i <= 9; i++)
	{
		for(j = 1; j <= 9; j++)
		{
			board[i][j] = next[i][j];
			next[i][j] = 0;
		}
	}
	spread(days);
}
int main()
{
	int a[5][11][11]={0};
	int day,i,j,k;
	scanf("%d%d",&a[0][5][5],&day);
	for(i=1;i<=day;i++)
	{
		for(j=1;j<=9;j++)
		{
			for(k=1;k<=9;k++)
			{
				a[i][j][k]=a[i-1][j][k]*2+a[i-1][j-1][k-1]+a[i-1][j-1][k]+a[i-1][j-1][k+1]+a[i-1][j][k-1]+a[i-1][j][k+1]+a[i-1][j+1][k-1]+a[i-1][j+1][k]+a[i-1][j+1][k+1];
			}   
			

		}
	}
		for(j=1;j<=9;j++)
		{
			for(k=1;k<9;k++)
			{
				printf("%d ",a[i-1][j][k]);
			}
			printf("%d\n",a[i-1][j][9]);
		}
	return 0;
}
int main ()
{  int m,n;
   scanf ("%d %d",&m,&n);
   int a[121][4];
  for (int i=0;i<121;i++)
   {  a[i][0]=0;
      a[i][1]=0;
      a[i][2]=0;
      a[i][3]=0;
     
      }
   a[60][0]=m;
   int k,i;
   for (k=1;k<n+1;k++)
   {
       for ( i=1;i<10;i++)
   {
       for (int j=1;j<10;j++)
    {  a[i*11+j][k]=a[(i-1)*11+j][k-1]+a[(i-1)*11+j-1][k-1]+a[(i-1)*11+j+1][k-1]+a[i*11+j-1][k-1]+a[i*11+j+1][k-1]+a[(i+1)*11+j+1][k-1]+a[(i+1)*11+j][k-1]+a[(i+1)*11+j-1][k-1]+2*a[i*11+j][k-1];
        }
        }
   }
   for (int i=1;i<10;i++)
   {printf ("%d %d %d %d %d %d %d %d %d\n",a[i*11+1][n],a[i*11+2][n],a[i*11+3][n],a[i*11+4][n],a[i*11+5][n],a[i*11+6][n],a[i*11+7][n],a[i*11+8][n],a[i*11+9][n]);
   }
 }
int n,m;

void num(int a[11][11],int b[11][11],int c)
{
	int w;
	for(w=0;w<11;w++)
	{
		a[0][w] = 0;
		a[w][0] = 0;
		b[0][w] = 0;
		b[w][0] = 0;
		a[10][w] = 0;
		a[w][10] = 0;
		b[10][w] = 0;
		b[w][10] = 0;
	}
	int i,j,p,q;
	if(c==n+1)
	{
		for(p = 1;p<=9;p++)
		{
		   for(q=1;q<=8;q++)
		   {
	     		cout << m*a[p][q]<<" " ;
		   }
			cout << m*a[p][9]<< endl;
		}
		return;
	}
	else
	{
		for(i=1;i<=9;i++)
			for(j=1;j<=9;j++)
				b[i][j] = 2*a[i][j]+a[i-1][j-1]+a[i-1][j]+a[i-1][j+1]+a[i][j-1]+a[i][j+1]+a[i+1][j-1]+a[i+1][j]+a[i+1][j+1];
		num(b,a,c+1);
	}
}
int main()
{   
	int i,j;
	int bac1[11][11]={0},bac2[11][11] = {0};
    bac1[5][5] = 1;
	cin >> m >> n;
	num(bac1,bac2,1);
	return 0;
}
void main(){
int m,n,i,j,k,c;
int a[9][9]={0};
scanf("%d",&m);
scanf("%d",&n);
a[4][4]=m;
for(i=1;i<=n;i++){
	int b[9][9]={0};
	for(j=1;j<8;j++){
		for(k=1;k<8;k++){
			c=a[j][k];
			b[j][k]+=2*c;
			b[j-1][k-1]+=c;
			b[j-1][k]+=c;
			b[j-1][k+1]+=c;
			b[j][k-1]+=c;
			b[j][k+1]+=c;
			b[j+1][k-1]+=c;
			b[j+1][k]+=c;
			b[j+1][k+1]+=c;}}
	for(j=0;j<9;j++){
		for(k=0;k<9;k++)
			a[j][k]=b[j][k];}}
for(j=0;j<9;j++){
		for(k=0;k<8;k++)
printf("%d ",a[j][k]);
printf("%d\n",a[j][8]);}
}
int a[9][9]={0},b[9][9]={0};
void copy(int a[9][9],int b[9][9])
{
	for (int i = 0;i<9;i++)
		for(int j=0;j<9;j++)
			a[i][j] = b[i][j];
}
int main()
{
	int m,n,j,k;
	cin >>m>>n;
	a[4][4] = m;
	b[4][4] = m;
	for(int i =0;i<n;i++)
	{
		for( j=4-i;j<=4+i;j++)
			for( k=4-i;k<=4+i;k++)
				for(int l = j -1;l<=j+1;l++)
					for(int m = k-1;m<=k+1;m++)
						b[l][m] += a[j][k];
		copy(a,b);
	}
	for(k = 0;k<9;k++)
		for(j=0;j<9;j++)
		{
			cout <<a[k][j];
			if(j<8)
				cout<<' ';
			else cout<<endl;
		}
		return 0;
}
main()
{
	  int i,j,k,t,m,n,r,day,x;
	  int a[100][100],b[100][100];
	  scanf("%d%d",&r,&day);
	   m=9;n=9;
	  for(i=0;i<m;i++)
	  {
			for(j=0;j<n;j++)
			 {a[i][j]=0;b[i][j]=0;}
	  }
	  a[4][4]=r;
	  b[4][4]=r;
	  for(x=0;x<day;x++)
	  {
	  	a[0][0]=b[0][1]+b[0][0]*2+b[1][0]+b[1][1];
	  	 
	  	for(i=1;i<n-1;i++)
		{
			a[0][i]=b[1][i]+b[0][i]*2+b[0][i+1]+b[0][i-1]+b[1][i+1]+b[1][i-1];
			 
		}
		a[0][n-1]=b[0][n-2]+b[0][n-1]*2+b[1][n-1]+b[1][n-2];
	 	for(i=1;i<m-1;i++)
		{
		for(j=0;j<n;j++)
		{
			if(j==0)
			{
				a[i][j]=b[i+1][j]+b[i][j]*2+b[i-1][j]+b[i][j+1]+b[i-1][j+1]+b[i+1][j+1];
			}
			if(j!=0&&j!=n-1)
			a[i][j]=b[i][j+1]+b[i][j]*2+b[i][j-1]+b[i+1][j]+b[i-1][j]+b[i-1][j-1]+b[i-1][j+1]+b[i+1][j-1]+b[i+1][j+1];
			 
			if(j==n-1)
			{
				a[i][j]=b[i+1][j]+b[i][j]*2+b[i-1][j]+b[i][j-1]+b[i+1][n-2]+b[i-1][n-2];
				 
			}
		}
	}
	a[m-1][0]=b[m-2][0]+b[m-1][0]*2+b[m-1][1]+b[m-2][1];
	 
	for(i=1;i<n-1;i++)
	{
		a[m-1][i]=b[m-1][i+1]+b[m-1][i]*2+b[m-1][i-1] +b[m-2][i]+b[m-2][i+1]+b[m-2][i-1];
		 
	}
	a[m-1][n-1]=b[m-2][n-1]+b[m-1][n-1]*2+b[m-1][n-2]+b[m-2][n-2];
	for(i=0;i<m;i++)
	  {
			for(j=0;j<n;j++)
			 b[i][j]=a[i][j];
	  }	
	}
	for(i=0;i<m;i++)
	  {
			for(j=0;j<n;j++)
			{
				if(j==0)
			printf("%d",a[i][j]);else printf(" %d",a[i][j]); }
			printf("\n");
	  }	
}
int main()
{
	int a[9][9]={0},b[9][9]={0};
	int i,j,k,m,n;
	scanf("%d%d",&m,&n);
	a[4][4]=m;
	b[4][4]=m;
	for(k=0;k<n;k++)
	{
		for(i=0;i<9;i++)
			for(j=0;j<9;j++)
			{
				if(i!=0&&i!=8&&j!=0&&j!=8)
					a[i][j]=2*b[i][j]+b[i][j-1]+b[i][j+1]+b[i-1][j]+b[i+1][j]+b[i-1][j-1]+b[i-1][j+1]+b[i+1][j-1]+b[i+1][j+1];
				if(i==0&&j==0)
					a[i][j]=2*b[i][j]+b[i][j+1]+b[i+1][j]+b[i+1][j+1];
				if(i==8&&j==0)
					a[i][j]=2*b[i][j]+b[i-1][j]+b[i][j+1]+b[i-1][j+1];
				if(i==0&&j==8)
					a[i][j]=2*b[i][j]+b[i-1][j]+b[i+1][j]+b[i+1][j-1];
				if(i==8&&j==8)
					a[i][j]=2*b[i][j]+b[i-1][j]+b[i][j-1]+b[i-1][j-1];
				if(i==0&&j!=0&&j!=8)
					a[i][j]=2*b[i][j]+b[i][j-1]+b[i][j+1]+b[i+1][j]+b[i+1][j-1]+b[i+1][j+1];
				if(i==8&&j!=0&&j!=8)
					a[i][j]=2*b[i][j]+b[i][j-1]+b[i][j+1]+b[i-1][j]+b[i-1][j-1]+b[i-1][j+1];
				if(j==0&&i!=0&&i!=8)
					a[i][j]=2*b[i][j]+b[i-1][j]+b[i+1][j]+b[i][j+1]+b[i-1][j+1]+b[i+1][j+1];
				if(j==8&&i!=0&&i!=8)
					a[i][j]=2*b[i][j]+b[i-1][j]+b[i+1][j]+b[i][j-1]+b[i-1][j-1]+b[i+1][j-1];
			}
		for(i=0;i<9;i++)
			for(j=0;j<9;j++)
				b[i][j]=a[i][j];
	}
	for(i=0;i<9;i++)
	{
		for(j=0;j<9;j++)
		{
			if(j==0)
				printf("%d",a[i][j]);
			else if(j==8)
				printf(" %d\n",a[i][j]);
			else
				printf(" %d",a[i][j]);
		}
	}
	return 0;
}
int main()
{
int m,n;
int a[9][9],b[9][9];
scanf("%d %d",&m,&n);
for(int i=0;i<9;i++){
                for(int j=0;j<9;j++){
                a[i][j]=0;
                b[i][j]=0;
                                  }
                 }
  a[4][4]=m;
for(int k=0;k<n;k++){ for(int i=0;i<9;i++){
                for(int j=0;j<9;j++){
               if(a[i][j]!=0){
               b[i-1][j]+=a[i][j];
               b[i+1][j]+=a[i][j];
               b[i][j-1]+=a[i][j];
               b[i][j+1]+=a[i][j];
               b[i-1][j-1]+=a[i][j];
               b[i+1][j+1]+=a[i][j];
               b[i-1][j+1]+=a[i][j];
               b[i+1][j-1]+=a[i][j];
                b[i][j]+=2*a[i][j];
                }
                 }
                 }
                 for(int i=0;i<9;i++){
                for(int j=0;j<9;j++){
                        a[i][j]=b[i][j];
                        b[i][j]=0;
                        }
                        }
                 }
  for(int i=0;i<9;i++){
for(int j=0;j<9;j++){
    if(j!=8) {
                printf("%d ",a[i][j]);
                }
    else{
          printf("%d\n",a[i][j]);
         }
        }
        }
int hou;
scanf("%d",&hou);
return 0;
}
//*************************************
//**Title:????????????? **
//**Author:???        **
//**Date?2013.12.7        **
//**File?2.cpp        **
//****************************


int chess[15][15][5];   //chess[i][j][k]???k?????(i,j)????
int d;                 //????

int f(int i,int j,int k)    //?????????k?????(i,j)????
{
	if(i < 1 || i > 9 || j < 1 || j > 9)   //??????????
		return 0;                          //??0(??????????????)

	if(chess[i][j][k]!=-1)        //???????????????????
		return chess[i][j][k];    //??????

	//????????????????????????*2+??8??????
	//???????????????????
	chess[i][j][k] = f(i, j, k - 1) * 2 + 
					 f(i, j - 1, k - 1) + 
					 f(i, j + 1, k - 1) +
					 f(i + 1, j, k - 1)+
					 f(i - 1, j, k - 1)+
					 f(i - 1, j - 1, k - 1)+
					 f(i - 1, j + 1, k - 1)+
					 f(i + 1, j - 1, k - 1)+
					 f(i + 1, j + 1, k - 1);
	return chess[i][j][k];            //??????
}

int main()
{
	int i, j, t;

	//?chess????????????
	for(i = 1; i <= 9; i++)
	{
		for(j = 1; j <= 9; j++)
		{
			chess[i][j][0] = 0;         //?0?????????????????0
			for(t = 1; t <= 4; t++)
				chess[i][j][t] = -1;     //-1??????????????????
		}
	}

	//??
	cin >> chess[5][5][0] >> d;    

	//????????????d??(i,j)?????
	for(i = 1; i <= 9; i++)
	{
		cout << f(i, 1, d);
		for(j = 2; j <= 9; j++)
		{
			cout << " " << f(i, j, d);
		}
		cout << endl;
	}
	return 0;
}
int m,n;
int a[11][11];int b[11][11];
main ()
{
     int i,j,h;
     memset(a,0,sizeof(int));
     memset(b,0,sizeof(int));
     scanf("%d %d",&m,&n);
     a[5][5]=m;
     for (h=1;h<=n;)
     {
       for (i=0;i<=10;i++)
       {
          for (j=0;j<=10;j++)
          {b[i][j]=a[i][j];}
        }
        for (i=5-h;i<=5+h;i++)
          {
             for (j=5-h;j<=5+h;j++)
             {
                  a[i][j]=b[i-1][j-1]+b[i-1][j]+b[i-1][j+1]+b[i][j-1]+2*b[i][j]+b[i][j+1]+b[i+1][j-1]+b[i+1][j]+b[i+1][j+1];
             }
      }
      h++;
     }
     for (i=1;i<=9;i++)
     {
         for (j=1;j<=8;j++)
         {printf ("%d ",a[i][j]);}
          for (j=9;j<=9;j++)
         {printf ("%d\n",a[i][j]);}
     }
}
int main()
{
	int m,n,s[A][A]={0},t[A][A]={0},i,a,b;
	scanf ("%d%d",&m,&n);
	s[4][4]=m;
	t[4][4]=m;
 for (i=0;i<n;i++)
	{
		for (a=0;a<9;a++)
		{
			for (b=0;b<9;b++)
			{
			    if (s[a][b]!=0)
				{
                    
			        t[a-1][b]+=s[a][b];
                    t[a][b-1]+=s[a][b];
                    t[a+1][b]+=s[a][b];
                    t[a][b+1]+=s[a][b];
                    t[a+1][b-1]+=s[a][b];	
		            t[a+1][b+1]+=s[a][b];
		            t[a-1][b+1]+=s[a][b];
		            t[a-1][b-1]+=s[a][b];
					t[a][b]+=s[a][b];
				}
			}
		}
		for (a=0;a<9;a++)
		{
			for (b=0;b<9;b++)
			{
				s[a][b]=t[a][b];
			}
		}
	}
	for (a=0;a<9;a++)
	{
		for (b=0;b<8;b++)
		{
			printf ("%d ",s[a][b]);
	     	
		}
		printf("%d\n",s[a][8]);
	}

	return 0;
}
int main()
{
	int m=0,n=0; int i=0,j=0,k=0; //??????m,n???????????????????????i,j,k??????0?
	int total[11][11]={{0}},born[11][11]={{0}}; //????total,born??????????????????
	cin>>m>>n; //?????
	total[5][5]=m;
	for(k=0;k<n;k++) //??????
	{
		for(i=1;i<10;i++) //??????????????
		{
			for(j=1;j<10;j++)
				born[i][j]=2*total[i][j]+total[i-1][j]+total[i-1][j-1]+total[i-1][j+1]+total[i][j-1]+total[i][j+1]+total[i+1][j-1]+total[i+1][j]+total[i+1][j+1];
		}
		for(i=1;i<10;i++) //???????
		{
			for(j=1;j<10;j++)
			{
				total[i][j]=born[i][j];
			}
		}
		for(i=1;i<10;i++) //born?????
		{
			for(j=1;j<10;j++)
				born[i][j]=0;
		}
	}
		for(i=1;i<10;i++) //?????
		{
			for(j=1;j<10;j++)
			{
				cout<<total[i][j];
				if(j==9)
					cout<<endl;
				else cout<<" ";
			}
		}
	return 0;
}
int a[31][11][11]={0};
int m;
void f(int k)
{int i,j;

 if(k<m+1){
   for(i=1;i<=9;i++)
   {for(j=1;j<=9;j++)
     {a[k][i][j]=2*a[k-1][i][j]+a[k-1][i+1][j]+a[k-1][i-1][j]+a[k-1][i][j+1]+a[k-1][i][j-1]+a[k-1][i+1][j+1]+a[k-1][i-1][j+1]+a[k-1][i+1][j-1]+a[k-1][i-1][j-1];}}
    f(k+1);}
else
{for(i=1;i<=9;i++)
  {for(j=1;j<9;j++)
    cout<<a[m][i][j]<<" ";
   cout<<a[m][i][9];
cout<<endl;}}
}
int main()
{
  int n;
  cin>>n>>m;
  a[0][5][5]=n;
  f(1);
return 0;
}
//********************************
//*?????? 1300012733 **
//*???2013?11?29?
//********************************
int arr[11][11]={0};
int brr[11][11]={0};
void proliferate( int day )
{
	if( day == 0 )
		return;
	//?arr???brr?????????
	memcpy( brr , arr , sizeof(arr) );
	for( int i = 1; i <= 9; i++ )
		for( int j = 1; j <= 9; j++ )
		{
			//???
			arr[i][j] = 2 * brr[i][j] + brr[i-1][j] + brr[i+1][j] + brr[i][j-1] + brr[i][j+1]
			 + brr[i-1][j-1] + brr[i+1][j+1] + brr[i+1][j-1] + brr[i-1][j+1];
		}
	day--;
	proliferate( day );
}

int main()
{
	cin >> arr[5][5];
	int day;
	cin >> day;
	proliferate( day );
	//????
	for( int i = 1; i <= 9; i++ )
	{
		cout << arr[i][1];
		for( int j = 2; j <= 9; j++ )
			cout << ' ' << arr[i][j];
		cout << endl;
	}
	return 0;
}
main()
{
      int m,n,i,j,k,l;
      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<=9;j++)
            {
                  for(k=1;k<=9;k++)
                  {
                        a[i+1][j-1][k-1]+=a[i][j][k];
                        a[i+1][j-1][k]+=a[i][j][k]; 
                        a[i+1][j-1][k+1]+=a[i][j][k]; 
                        a[i+1][j][k-1]+=a[i][j][k]; 
                        a[i+1][j][k+1]+=a[i][j][k];
                        a[i+1][j+1][k-1]+=a[i][j][k];
                        a[i+1][j+1][k]+=a[i][j][k];
                        a[i+1][j+1][k+1]+=a[i][j][k];
                        a[i+1][j][k]+=(2*a[i][j][k]);
                  }
            }
      }
      for(l=1;l<=9;l++)
      {
            printf("%d %d %d %d %d %d %d %d %d\n",a[i][l][1],a[i][l][2],a[i][l][3],a[i][l][4],a[i][l][5],a[i][l][6],a[i][l][7],a[i][l][8],a[i][l][9]);
      }
}
int main()
{
	int a[9][9]={0},b[9][9]={0},n,i,j;
	cin>>a[4][4];
	cin>>n;
	while(n>0)
	{
		n--;
		for(i=0;i<9;i++)
			for(j=0;j<9;j++)
				if(a[i][j]!=0)
					b[i][j]=a[i][j]*2;
		for(i=0;i<9;i++)
			for(j=0;j<9;j++)
				if(a[i][j]!=0)
				{
					b[i+1][j]=a[i][j]+b[i+1][j];
					b[i-1][j]=a[i][j]+b[i-1][j];
					b[i][j+1]=a[i][j]+b[i][j+1];
					b[i][j-1]=a[i][j]+b[i][j-1];
					b[i+1][j+1]=a[i][j]+b[i+1][j+1];
					b[i-1][j-1]=a[i][j]+b[i-1][j-1];
					b[i+1][j-1]=a[i][j]+b[i+1][j-1];
					b[i-1][j+1]=a[i][j]+b[i-1][j+1];
				}
		for(i=0;i<9;i++)
			for(j=0;j<9;j++)
				a[i][j]=b[i][j];
		for(i=0;i<9;i++)
			for(j=0;j<9;j++)
				b[i][j]=0;
	}
	for(i=0;i<9;i++)
	{
		for(j=0;j<8;j++)
			cout<<a[i][j]<<' ';
		cout<<a[i][8];
		cout<<endl;
	}
	return 0;
}
main()
{
      int a[10][10],b[10][10];
      int m,n;
      scanf("%d %d",&m,&n);
      for(int j=1;j<=9;j++)
              {
                      for(int k=1;k<=9;k++)
                      {
                              a[j][k]=0;
                              b[j][k]=0;
                      }
              }
      a[5][5]=m;
      b[5][5]=m;
      for(int i=1;i<=n;i++)
      {
              for(int j=2;j<=8;j++)
              {
                      for(int k=2;k<=8;k++)
                      {
                              b[j+1][k+1]= b[j+1][k+1]+a[j][k];
                              b[j][k+1]= b[j][k+1]+a[j][k];
                              b[j+1][k]= b[j+1][k]+a[j][k];
                              b[j][k]= b[j][k]+a[j][k];
                              b[j-1][k+1]= b[j-1][k+1]+a[j][k];
                              b[j-1][k]= b[j-1][k]+a[j][k];
                              b[j+1][k-1]= b[j+1][k-1]+a[j][k];
                              b[j][k-1]= b[j][k-1]+a[j][k];
                              b[j-1][k-1]= b[j-1][k-1]+a[j][k];
                      }
              }
              for(int j=1;j<=9;j++)
              {
                      for(int k=1;k<=9;k++)
                      {
                              a[j][k]=b[j][k];
                      }
              }
      }
      for(int j=1;j<=9;j++)
              {
                      for(int k=1;k<=8;k++)
                      {
                              printf("%d ",a[j][k]);
                      }
                      printf("%d\n",a[j][9]);
              }
}
int a[9][9],b[9][9],i,j,k,m,n;
int main()
{
    scanf("%d %d",&m,&n);
    a[4][4]=m;
    for (i=1;i<=n;i++)
    {
        for (j=0;j<9;j++)
            for (k=0;k<9;k++)
            {
                if (a[j][k]>0)
                {
                    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+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];
                    b[j][k]+=2*a[j][k];
                }
            }
        for (j=0;j<9;j++)
            for (k=0;k<9;k++)
            {
                a[j][k]=b[j][k];
                b[j][k]=0;
            }
    }
    for (j=0;j<9;j++)
    {
        for (k=0;k<8;k++)
            printf("%d ",a[j][k]);
        printf("%d\n",a[j][8]);
    }
    return 0;
}
int main()
{
    int a,b,i,m,n;
    int c[13][13];
    for(a=1;a<=11;a++)
    {
        for(b=1;b<=11;b++)
        {
            c[a][b]=0;  
        }
    }
    int e[13][13];
    scanf("%d%d\n",&m,&n);
    c[6][6]=m;
    for(i=1;i<=n;i++)
    {
         for(a=2;a<=10;a++)
         {
              for(b=2;b<=10;b++)
              {
                   e[a][b]=2*c[a][b]+c[a-1][b-1]+c[a-1][b]+c[a-1][b+1]+c[a][b-1]+c[a][b+1]+c[a+1][b-1]+c[a+1][b]+c[a+1][b+1];
              }
         }
         for(a=2;a<=10;a++)
         {
              for(b=2;b<=10;b++)
              {
                   c[a][b]=e[a][b];
              }
         }
    }
    for(a=2;a<=10;a++)
    {
         for(b=2;b<=10;b++)
         {
              if(b==10) printf("%d\n",c[a][b]);
              else printf("%d ",c[a][b]);
         }
    }
return 0;
}
int main()
{
	int m,n,i,j,d;
	int a[10][10]={0};
	int b[10][10]={0};
	cin >>m>>n;//??
	a[5][5]=m;//???
	for (d=1;d<=n;d++)//????
	{
		memset(b,0,100*sizeof(int));//???
		for (i=1;i<=9;i++)
			for (j=1;j<=9;j++)
			{
				if (a[i][j]==0) continue;
				b[i][j]+=a[i][j]*2;
				b[i+1][j]+=a[i][j];
				b[i-1][j]+=a[i][j];
				b[i][j+1]+=a[i][j];
				b[i][j-1]+=a[i][j];
				b[i+1][j+1]+=a[i][j];
				b[i+1][j-1]+=a[i][j];
				b[i-1][j+1]+=a[i][j];
				b[i-1][j-1]+=a[i][j];
			}//??????9??????
		memset(a,0,100*sizeof(int));
	    for (i=1;i<=9;i++)
			for (j=1;j<=9;j++)
				a[i][j]=b[i][j];//?b??a?????????
	}
	for (i=1;i<=9;i++)
	{
		for (j=1;j<9;j++)
			cout <<a[i][j]<<' ';
		cout <<a[i][9]<<endl;
	}//??
	return 0;
}
int main()
{
	int m, n, pan[9][9] = {0}, i, j, k, t,pan1[9][9];
	cin >> m >> n;
	pan[4][4] = m;
	for(i = 0; i < n; i++)
	{
		for(j = 0; j < 9; j++)
			for(k = 0; k < 9; k++)
				pan1[j][k] = 0;
		for(j = 0; j < 9; j++)
			for(k = 0; k < 9; k++)
				if(pan[j][k] != 0)
				{
					t = pan[j][k] * 10;
					pan1[j][k] += 2 * pan[j][k];
					pan1[j-1][k-1] += (t-2 * pan[j][k]) / 8;
					pan1[j-1][k] += (t-2 * pan[j][k]) / 8;
					pan1[j-1][k+1] += (t-2 * pan[j][k]) / 8;
					pan1[j][k-1] += (t-2 * pan[j][k]) / 8;
					pan1[j][k+1] += (t-2 * pan[j][k]) / 8;
					pan1[j+1][k-1] += (t-2 * pan[j][k]) / 8;
					pan1[j+1][k] += (t-2 * pan[j][k]) / 8;
					pan1[j+1][k+1] += (t-2 * pan[j][k]) / 8;
				}
		for(j = 0; j < 9; j++)
			for(k = 0; k < 9; k++)
				pan[j][k] = pan1[j][k];
	}
	for(j = 0; j < 9; j++)
	{
		for(k = 0; k < 8; k++)
			cout << pan[j][k] << ' ';
		cout << pan[j][k] << endl;
	}
	return 0;
}
void output(int a[9][9])
{
     int x, y;
     	for(x = 0;x <= 8;x ++)
	{
		for(y = 0;y <= 8;y ++)
		{
			printf("%d", a[x][y]);
			if(y != 8)printf(" ");
		}
		printf("\n");
	}
}



int main()
{
	int a[9][9] = {0};
	int i, j, k;


	int addup[9][9] = {0};

	int m , day;
	int x, y;
	scanf("%d", &m);
	scanf("%d", &day);
	a[4][4] = m;

	for(i = 1;i <= day;i ++)
	{
		for(x = 0;x <= 8; x++)
		{
			//printf("[%d]\n", a[0][0]);
			for(y = 0;y <= 8;y ++)
			{
//				if(a[x][y] != 0)
				{
					addup[x - 1][y - 1] += a[x][y];
					addup[x - 1][y] += a[x][y];
					addup[x - 1][y + 1] += a[x][y];
					addup[x][y - 1] += a[x][y];
					addup[x][y] += 2 * a[x][y];
					addup[x][y + 1] += a[x][y];
					addup[x + 1][y - 1] += a[x][y];
					addup[x + 1][y] += a[x][y];
					addup[x + 1][y + 1] += a[x][y];

                    /*if((x == 4) && (y == 4))
                    {
                          for(k = x - 1;k <= x + 1;k ++)
                          {
                                for(j = y - 1;j <= y + 1;j ++)
                                {
                                      printf("[%3d] ", addup[k][j]);
                                }
                                printf("\n");
                          }
                          printf("+_+_+_\n");
                          output(addup);
                          printf("+_+_+_\n");
                    }*/
					




				}
			}
		}
		//printf("[%d]\n", a[0][0]);
		/*printf("-----add--------\n");
        output(addup);
		printf("-----add end--------\n");*/
		for(x = 0;x <= 8;x ++)
		{
			for(y = 0;y <= 8;y ++)
			{
				a[x][y] = addup[x][y];
				addup[x][y] = 0;
			}
		}
  /*printf("--[][]--\n");
		output(addup);
          printf("--[][]--\n");*/

	}
 output(a);
}
int a[10][10] = {0};
void bac(int n)
{
	int i,j;
	int b[10][10] = {0};
	if (n == 0)
		return;
	for (i = 1; i <= 9; i++)
	{
		for (j = 1; j <= 9; j++)
		{
			if (a[i][j] != 0)
			{

				b[i - 1][j] += a[i][j];
				b[i + 1][j] += a[i][j];
				b[i - 1][j - 1]+= a[i][j];
				b[i - 1][j + 1]+= a[i][j];
				b[i+1][j-1]+=a[i][j];
				b[i+1][j+1]+=a[i][j];
				b[i][j-1]+=a[i][j];
				b[i][j+1]+=a[i][j];		
				a[i][j] = a[i][j] * 2;
			}
		}
	}
	for (i = 1; i<= 9; i++)
		for (j = 1; j <= 9; j++)
			a[i][j]+=b[i][j];
	bac(n - 1);
	return;
	
}
int main()
{
	int i,j;
	int m, n;
	cin >> m >> n;
	a[5][5] = m;
	bac(n);
	for (i = 1; i <= 9; i++)
	{
		for (j = 1; j<= 8; j++)
			cout << a[i][j] << " ";
		cout << a[i][j] << endl;
	}
	return 0;
}
int a[9][9] = {0};
void change(int a[9][9],int k);
int main()
{
	int m,n,i,j;
	cin >> m >> n;
	a[4][4] = m;
	change(a,n);
	for(i = 0; i < 9; i++)
	{
		for(j = 0; j < 9; j++)
		{
			if(j != 8)
				cout << a[i][j] << " ";
			else
				cout << a[i][j];
		}
		cout << endl;
	}
	return 0;
}
void change(int a[9][9],int k)
{
	if(k == 0)
		return;
	int i,j,sign[9][9] = {0},b[9][9] = {0};
	for(i = 0; i < 9; i++)
	{
		for(j = 0; j < 9; j++)
		{
			if((a[i][j] != 0)&&(sign[i][j] == 0))
			{
				sign[i][j]++;
				b[i][j] = a[i][j];
			}
		}
	}
	for(i = 0; i < 9; i++)
	{
		for(j = 0; j < 9; j++)
		{
			if(sign[i][j] == 1)
			{
				a[i][j] += 2 * b[i][j];
				a[i][j + 1] += b[i][j];
				a[i][j - 1] += b[i][j];
				a[i + 1][j] += b[i][j];
				a[i - 1][j] += b[i][j];
				a[i - 1][j - 1] += b[i][j];
				a[i - 1][j + 1] += b[i][j];
				a[i + 1][j - 1] += b[i][j];
				a[i + 1][j + 1] += b[i][j];
			}
		}
	}
	for(i = 0; i < 9; i++)
		for(j = 0; j < 9; j++)
		{
			a[i][j] = a[i][j] - b[i][j];
		}
	change(a,k - 1);
}
int m,n;
int num1[11][11]={0},num2[11][11]={0};
int i,j,t;
int num(int x,int y)
{
    int N;
    N=num1[x-1][y-1]+num1[x][y-1]+num1[x+1][y-1]+num1[x-1][y]+num1[x+1][y]+num1[x-1][y+1]+num1[x][y+1]+num1[x+1][y+1];
    return N;
}
main()
{
    scanf("%d %d",&m,&n);
    num1[5][5]=num2[5][5]=m;
    for(t=1;t<=n;t++)
    {
        for(i=5-t;i<=5+t;i++)
        {
            for(j=5-t;j<=5+t;j++)
            {
                num2[i][j]=2*num1[i][j]+num(i,j);
            }
        }
        for(i=5-t;i<=5+t;i++)
        {
            for(j=5-t;j<=5+t;j++)
            {
                num1[i][j]=num2[i][j];
            }
        }
    }
    for(i=1;i<10;i++)
        {
            for(j=1;j<10;j++)
            {
                if(j==1)printf("%d",num1[i][j]);
                else printf(" %d",num1[i][j]);
            }
            printf("\n");
        }
}