semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
	int i, d, n, a[5][9][9]={{0}}, j, k, p, q;
	cin >> n >> d;
	a[0][4][4]=n;
	p=4;
	q=4;
	for (i=1; i <= d; i++)
		{
			for (j=p; j <= q; j++)
				for (k=p; k <= q; k++)
					a[i][j][k] += a[i-1][j][k];
			for (j=p; j <= q; j++)
				for (k=p; k <= q; k++)
						{
							a[i][j][k] += a[i-1][j][k];
							a[i][j+1][k] += a[i-1][j][k];
							a[i][j][k+1] += a[i-1][j][k];
							a[i][j-1][k] += a[i-1][j][k];
							a[i][j][k-1] += a[i-1][j][k];
							a[i][j+1][k+1] += a[i-1][j][k];
							a[i][j+1][k-1] += a[i-1][j][k];
							a[i][j-1][k+1] += a[i-1][j][k];
							a[i][j-1][k-1] += a[i-1][j][k];							
						}
				p--;
				q++;
		}
	for (j=0; j<9; j++)
		{
			for (k=0; k<8; k++)
				cout << a[d][j][k] << ' ';
			cout << a[d][j][8] << endl;
		}
	return 0;
}
main()
{
    int n,d;
    int a[9][9],b[9][9];
    scanf("%d %d",&n,&d);
    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]=n;
    b[4][4]=n;
    for(int i=0;i<d;i++)
    {
        for(int k=0;k<9;k++)
        for(int j=0;j<9;j++)
        {
        b[k][j]*=2;
        if(k!=0)b[k][j]+=a[k-1][j];
        if(k!=8)b[k][j]+=a[k+1][j];
        if(j!=0)b[k][j]+=a[k][j-1];
        if(j!=8)b[k][j]+=a[k][j+1];
        if(k!=0&&j!=0)b[k][j]+=a[k-1][j-1];
        if(k!=8&&j!=0)b[k][j]+=a[k+1][j-1];
        if(k!=8&&j!=8)b[k][j]+=a[k+1][j+1];
        if(k!=0&&j!=8)b[k][j]+=a[k-1][j+1];
        }
        for(int k=0;k<9;k++)
        for(int j=0;j<9;j++)
        a[k][j]=b[k][j];
    }
    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 main()
{
    int m,n;
    int a[11][11]={0},add[11][11]={0};
    scanf ("%d %d",&m,&n);
    a[5][5]=m;
    for (int i=0;i<n;i++)
    {
        for (int x=1;x<10;x++)
        {
            for (int y=1;y<10;y++)
            add[x][y]=a[x][y]+a[x-1][y]+a[x][y-1]+a[x-1][y-1]+a[x-1][y+1]+a[x][y+1]+a[x+1][y+1]+a[x+1][y]+a[x+1][y-1];
        }
        for (int x=1;x<10;x++)
        {
            for (int y=1;y<10;y++)
            a[x][y]=a[x][y]+add[x][y];
        }
    }
    for (int i=1;i<10;i++)
    {
        for (int j=1;j<10;j++)
        {
            if (j==1) printf ("%d",a[i][j]);
            else printf (" %d",a[i][j]);
        }
        printf ("\n");
    }
    return 0;
}
int a[11][11][5] ;                            //??????????????????? a[i][j][d]??i?j??d?????? 

int f(int x , int y , int d)                  //??f?????x?y?d?????????-1??????????????0 
{
    int s ;                                   //?????s???????? 
    if ((a[x][y][d] > 0) || (d == 0))         //?????????????d = 0?????????? 
        return a[x][y][d] ; 
    if (a[x][y][d] == -1)                     //????????????-1????0 
        return 0 ; 
    s = f(x , y , d - 1) * 2 ;                //?????????????? 
    if (x > 1)                                //???????????????????????? 
    {
        s += f(x - 1 , y , d - 1) ; 
        if (y > 1)                            //?????????????????????????? 
            s += f(x - 1 , y - 1 , d - 1 ) ; 
        if (y < 9)                            //???????????????? 
            s += f(x - 1 , y + 1 , d - 1 ) ; 
    }
    if (x < 9)                                //?????????? 
    {
        s += f(x + 1 , y , d - 1) ; 
        if (y > 1)
            s += f(x + 1 , y - 1 , d - 1 ) ; 
        if (y < 9)
            s += f(x + 1 , y + 1 , d - 1 ) ; 
    }
    if (y > 1)                                //???????????????? 
        s += f(x , y - 1 , d - 1) ; 
    if (y < 9)
        s += f(x , y + 1 , d - 1) ; 
    if (s != 0)                               //????????0?????????? 
    {
        a[x][y][d] = s ; 
        return s ; 
    }
    else                                      //?????0??a???-1???0 
    {
        a[x][y][d] = -1 ; 
        return 0 ; 
    }
}

int main()
{
    int m , i , j ;                           //????m?????i,j 
    memset(a , 0 , sizeof(a)) ;               //??a?? 
    cin >> a[5][5][0] >> m ;                  //????????????? 
    for (i = 1 ; i <= 9 ; i ++ )              //????????? 
    {
        cout << f(i , 1 , m) ; 
        for (j = 2 ; j <= 9 ; j ++ )
            cout << ' ' << f(i , j , m) ; 
        cout << endl ; 
    }
    return 0 ; 
}
int a[20][20];
int b[20][20];
int n,m;
void day(int x)
{
	if(x==n+1)
		return;
	for(int i=1;i<=9;i++)
	{
		for(int j=1;j<=9;j++)
		{
			b[i][j]=0;
		}
	}
	for(int i=1;i<=9;i++)
	{
		for(int j=1;j<=9;j++)
		{
			b[i][j]+=a[i][j];
			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];
		}
	}
	for(int i=1;i<=9;i++)
	{
		for(int j=1;j<=9;j++)
		{
			a[i][j]+=b[i][j];
		}
	}
	day(x+1);
}
int main()
{
	cin>>m>>n;
	a[5][5]=m;
	day(1);
	for(int i=1;i<=9;i++)
	{
		for(int j=1;j<=8;j++)
		{
			cout<<a[i][j]<<' ';
		}
		cout<<a[i][9];
		cout<<endl;
	}
	return 0;
}
int main()
{
	int m,n,i,j,a[11][11],b[11][11],d;
	cin >>m>>n;
	for (i=0;i<=10;i++)
	{
		for (j=0;j<=10;j++)
		{
			a[i][j]=b[i][j]=0;
		}
	}
	a[5][5]=m;
	for (d=1;d<=n;d++)
	{
		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];
			}
		}
		for (i=1;i<=9;i++)
		{
			for (j=1;j<=9;j++)
			{
				a[i][j]=b[i][j];
			}
		}
	}
	for (i=1;i<=9;i++)
	{
		for (j=1;j<=9;j++)
		{
			if (j==9)
				cout <<a[i][j]<<endl;
			else cout <<a[i][j]<<' ';
		}
	}
	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);
     getchar();getchar();
     return 0;
}
int main()
{
	int a[9][9]={0},b[9][9]={0};
	int n,t=0,i,j;
	cin>>n;
	a[4][4]=n;
	cin>>n;
	while(t<n)
	{
		for(i=1;i<8;i++)
			for(j=1;j<8;j++)
			{
				b[i-1][j-1]+=a[i][j];
				b[i-1][j]+=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];
				b[i+1][j-1]+=a[i][j];
				b[i+1][j]+=a[i][j];
				b[i+1][j+1]+=a[i][j];
				b[i][j]+=a[i][j];
			}
		for(i=0;i<9;i++)
			for(j=0;j<9;j++)
			{
				a[i][j]+=b[i][j];
				b[i][j]=0;
			}
		t++;
	}
	for(i=0;i<9;i++)
	{
		for(j=0;j<8;j++)
			{
				cout<<a[i][j]<<' ';
			}
		cout<<a[i][8]<<endl;
	}
	return 0;
}
/************************????????*******************
??
????9???????????????m?????????????????????10???????10??????????????????????????????????????????n(1?n?4)????????????????
????
?????????????m????????????2?m?30???????n????????1?m?4??
????
??????????????????????????????n???????????????
????
2 1
????
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 2 2 2 0 0 0
0 0 0 2 4 2 0 0 0
0 0 0 2 2 2 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
**************************************************************
programmer Qiu Hezi
version 1.0
creat date 2013.1.10 21:27
************************************************************/
struct dir
{
	int r;
	int l;
}direct[8]=
{
	{1 ,1}, {1,0} , {1,-1} , {0,1} , {0,-1} , {-1,1} , {-1,0} , {-1,-1}
};
int main ()
{
	int m=0 , n=0 ;
	cin>>m>>n;
	int num[5][9][9]={0};
	num[0][4][4]=m;
	for (int day=1 ; day<=n ; day++)
	{
		for (int x=0 ; x<9 ; x++)
		{
			for (int y=0 ; y<9 ; y++)
			{
				if (num[day-1][x][y]>0)
				{
					for (int i=0 ; i<8 ; i++)
						num[day][x+direct[i].r][y+direct[i].l]+=num[day-1][x][y];
					num[day][x][y]+=num[day-1][x][y]*2;
				}
			}
		}
	}
	for (int i=0 ; i<9 ; i++)
	{
		for (int j=0 ; j<9 ; j++)
		{
			cout<<num[n][i][j];
			if (j<8)
				cout<<" ";
		}
		cout<<endl;
	}
	return 0;
}
int main(){
	
	int day,ma[11][11]={0},mb[11][11]={0};
	cin>>ma[5][5]>>day;

	for(int t=1;t<=day;t++){
		if(t%2==1){
			for(int i=1;i<10;i++){
				for(int j=1;j<10;j++){
					mb[i][j]=ma[i][j]*2
					+ma[i+1][j]+ma[i+1][j+1]+ma[i+1][j-1]
					+ma[i-1][j]+ma[i-1][j+1]+ma[i-1][j-1]
					+ma[i][j+1]+ma[i][j-1];
				}
			}
		}
		else{
			for(int i=1;i<=9;i++){
				for(int j=1;j<=9;j++){
					ma[i][j]=mb[i][j]*2
					+mb[i+1][j]+mb[i+1][j+1]+mb[i+1][j-1]
					+mb[i-1][j]+mb[i-1][j+1]+mb[i-1][j-1]
					+mb[i][j+1]+mb[i][j-1];
				}
			}
		}
	}
	
	if(day%2==1){
		for(int i=1;i<=9;i++){
			for(int j=1;j<9;j++){
				cout<<mb[i][j]<<" ";
			}
			cout<<mb[i][9]<<endl;
		}
	}
	else{
		for(int i=1;i<=9;i++){
			for(int j=1;j<9;j++){
				cout<<ma[i][j]<<" ";
			}
			cout<<ma[i][9]<<endl;
		}
	}
}
int  xi[11][11]={0} , jun[11][11] ={0} ;
int i , j ;
void fanzhi(int t)
{
	if(t == 0)
		return ;
	int jun[11][11] = {0} ;
	for (i = 1 ; i <= 9 ; i ++)
	{
		for (j = 1 ; j <= 9 ; j ++)
		{
			jun[i-1][j-1] += xi[i][j] ;
			jun[i-1][j] += xi[i][j] ;
			jun[i-1][j+1] += xi[i][j] ;
			jun[i][j-1] += xi[i][j] ;
			jun[i][j+1] += xi[i][j] ;
			jun[i+1][j-1] += xi[i][j] ;
			jun[i+1][j] += xi[i][j] ;
			jun[i+1][j+1] += xi[i][j] ;
		}
	}
	for (i = 1 ; i <= 9 ; i ++)
	{
		for (j = 1 ; j <= 9 ; j ++)
			xi[i][j] = 2 * xi[i][j] +jun[i][j] ;
	}
	fanzhi(t-1) ;
}
int main ()
{
	int m , n ;
	cin >> m >> n ;
	xi[5][5] = m ;
	fanzhi(n) ;
	for (i = 1 ; i <= 9 ; i ++)
	{
		for (j = 1 ; j <= 9 ; j ++)
		{
			if(j>=2)
				cout <<' ' ;
			cout <<xi[i][j] ;
		}
		cout <<endl ;
	}
	return 0 ;
}
/*
*??? 1200012851
*???????
*2013.1.4
**/

int main()
{
	int a[2][11][11] = {0};
	int t, i, k, j, n, days, flag = 0;
	cin >> n >> days;
	a[0][5][5] = n;
	for (t = 1; t <= days; t++)
	{
		i = t % 2;
		for (k = 0; k < 11; k++)
			for (j = 0; j < 11; j++)
				a[i][k][j] = 0;
		for (k = 1; k <= 9; k++)
			for (j = 1; j <= 9; j++)
			{
				a[i][k][j] += 2 * a[1 - i][k][j];
				a[i][k + 1][j] += a[1 - i][k][j];
				a[i][k - 1][j] += a[1 - i][k][j];
				a[i][k][j + 1] += a[1 - i][k][j];
				a[i][k][j - 1] += a[1 - i][k][j];
				a[i][k + 1][j + 1] += a[1 - i][k][j];
				a[i][k - 1][j - 1] += a[1 - i][k][j];
				a[i][k - 1][j + 1] += a[1 - i][k][j];
				a[i][k + 1][j - 1] += a[1 - i][k][j];
			}
	}
	for (k = 1; k <= 9; k++)
	{
		for (j = 1; j <= 9; j++)
		{
			if (flag)
				cout << " ";
			cout << a[i][k][j];
			flag = 1;
		}
		flag = 0;
		cout << endl;
	}
	return 0;
}
int main()
{   
   int i,j,m,n,k;
   struct point
   {
       int now;
       int answer;
   }a[11][11];
  scanf("%d",&m);
  scanf("%d",&n);
  for (i=0;i<11;i++)
  for (j=0;j<11;j++)
  a[i][j].now=0;
  a[5][5].now=m;
  for (k=0;k<n;k++)
  {
      for (i=1;i<10;i++)
      for (j=1;j<10;j++)
      a[i][j].answer=2*a[i][j].now+a[i-1][j-1].now+a[i-1][j].now+a[i-1][j+1].now+a[i][j-1].now+a[i][j+1].now+a[i+1][j-1].now+a[i+1][j].now+a[i+1][j+1].now;
      for (i=1;i<10;i++)
      for (j=1;j<10;j++)
      a[i][j].now=a[i][j].answer;
  }
     for (i=1;i<10;i++)
    { 
     for (j=1;j<9;j++)
     printf("%d ",a[i][j].now);
     printf("%d\n",a[i][9].now);
    }
}
int main()
{
	int n,m,i;
	int num[11][11],tem[11][11];
	int j,k;
	for(i=0;i<11;i++)
	{
		for(j=0;j<11;j++)
		{
			num[i][j]=0;
			tem[i][j]=0;
		}
	}
	scanf("%d %d",&m,&n);
	num[5][5]=m;
    tem[5][5]=m;
	for(i=1;i<=n;i++)//i????
	{
		for(j=5-i;j<=5+i;j++)
		{
			for(k=5-i;k<=5+i;k++)
			{
				num[j][k]=tem[j-1][k-1]+tem[j][k-1]+tem[j+1][k-1]+tem[j-1][k]+tem[j+1][k]+tem[j+1][k+1]+tem[j][k+1]+tem[j-1][k+1]+2*tem[j][k];
			}
		}
	    for(j=5-i;j<=5+i;j++)
		{
			for(k=5-i;k<=5+i;k++)
			{
				tem[j][k]=num[j][k];
			}
		}
	}
	for(i=1;i<=9;i++)
	{
		for(j=1;j<9;j++)
		{
			printf("%d ",num[j][i]);
		}
		printf("%d\n",num[9][i]);
	}
	return 0;
}
int main()
{
	 int zz[11][11][5];
	 int i,j,k;
	 int m,n;
	 for ( i = 0 ; i < 11 ; i ++ )
		 for ( j = 0 ; j < 11 ; j ++ )
			 for ( k = 0 ; k < 5 ; k ++ )
			 zz[i][j][k]=0;
	 cin>>m>>n;
	 zz[5][5][n]=m;
	 while ( n != 0 )
	 {
		 for ( i = 1 ; i < 10 ; i ++ )
		 {
			 for ( j = 1 ; j < 10 ; j ++ )
			 {
				 if ( zz[i][j][n] > 0 )
				 {
					 zz[i][j][n-1] += 2 * zz[i][j][n];
					 zz[i-1][j-1][n-1] += zz[i][j][n];
					 zz[i-1][j][n-1] += zz[i][j][n];
					 zz[i-1][j+1][n-1] += zz[i][j][n];
					 zz[i][j-1][n-1] += zz[i][j][n];
					 zz[i][j+1][n-1] += zz[i][j][n];
					 zz[i+1][j-1][n-1] += zz[i][j][n];
					 zz[i+1][j][n-1] += zz[i][j][n];
					 zz[i+1][j+1][n-1] += zz[i][j][n];
				 }
			 }
		 }
		 for ( i = 0 ; i < 11 ; i ++ )
		 {
			 for ( j = 0 ; j < 11 ; j ++ )
			 {
				 if ( i == 0 || j == 0 || i == 10 || j == 10 )
					 zz[i][j][n-1]=0;
			 }
		 }
		 n--;
	 }
	 for ( i = 1 ; i < 10 ; i ++ )
	 {
		 for ( j = 1 ; j < 10 ; j ++ )
		 {
			 if ( j != 9 )
			 cout<<zz[i][j][0]<<' ';
			 else
				 cout<<zz[i][j][0];
		}
		 cout<<endl;
	 }
}
int main()
{
	int i,j,m,n,a[9][9]={0},b[9][9]={0};
	cin>>m>>n;
	a[4][4]=m;
	while(n--)
	{
		for(i=0;i<9;i++)
			for(j=0;j<9;j++)
				if(a[i][j]!=0)
				{
					b[i][j]+=2*a[i][j];
					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];
				}
		for(i=0;i<9;i++)
			for(j=0;j<9;j++)
				a[i][j]=b[i][j];
			memset(b,0,sizeof(b));
	}
	for(i=0;i<9;i++)
	{
		for(j=0;j<8;j++)
			cout<<a[i][j]<<' ';
	    cout<<a[i][8]<<endl;
	}
	return 0;
}
int main()
{
	int a[9][9]={0};
	int b[9][9]={0};
	int m,t;
	cin>>m>>t;
	a[4][4]=m;
	int i;int k,l;
	for(i=0;i<t;i++)
	{
		
		for(k=0;k<9;k++)
		{
			for(l=0;l<9;l++)
			{
				if(a[k][l]!=0)
				{
					b[k][l]=b[k][l]+a[k][l]*2;
					if(k>0)b[k-1][l]=b[k-1][l]+a[k][l];
					if(k<8)b[k+1][l]=b[k+1][l]+a[k][l];
					if(l>0)b[k][l-1]=b[k][l-1]+a[k][l];
					if(l<8)b[k][l+1]=b[k][l+1]+a[k][l];
					if(k>0 && l>0)b[k-1][l-1]=b[k-1][l-1]+a[k][l];
					if(k>0 && l<8)b[k-1][l+1]=b[k-1][l+1]+a[k][l];
					if(k<8 && l>0)b[k+1][l-1]=b[k+1][l-1]+a[k][l];
					if(k<8 && l<8)b[k+1][l+1]=b[k+1][l+1]+a[k][l];

				}
			}
		}
		for(k=0;k<9;k++)
		{
			for(l=0;l<9;l++)
			{
				a[k][l]=b[k][l];b[k][l]=0;
			}
		}
	}
	for(k=0;k<9;k++)
		{
			for(l=0;l<9;l++)
			{
				cout<<a[k][l];
				if(l!=8)cout<<" ";
			}
			cout<<endl;
		}
	return 0;
}
main()
{int square[9][9]={0};
int squ[9][9]={0};
 int m,n,i,j,k,t,q;
 scanf("%d",&m);
 scanf("%d",&n);
 square[4][4]=squ[4][4]=m;
 for(i=1;i<=n;i++)
 {for(j=0;j<=8;j++)
 {for(k=0;k<=8;k++)
    if (square[j][k]!=0)
	{squ[j][k]=squ[j][k]+square[j][k];
     squ[j][k+1]+=square[j][k];
	 squ[j][k-1]+=square[j][k];
	 squ[j+1][k]+=square[j][k];
	 squ[j+1][k+1]+=square[j][k];
	 squ[j+1][k-1]+=square[j][k];
	 squ[j-1][k]+=square[j][k];
	 squ[j-1][k+1]+=square[j][k];
	 squ[j-1][k-1]+=square[j][k];
	}
 }
  for(t=0;t<=8;t++)
     for(q=0;q<=8;q++)
	 {   
	 square[q][t]=squ[q][t];}
 }
 for(t=0;t<=8;t++)
 {for(q=0;q<=7;q++)
 printf("%d ",square[t][q]);
 printf("%d",square[t][8]);
 printf("\n");
 }
}
int main()
{
	int dish[9][9]={0},temp[9][9]={0},i=0,j=0,n=0,m=0;
	cin>>m>>n;
	dish[4][4]=m;
	int *p=dish[0],*q=temp[0];
    for(i=0;i<n;i++)
	{
		for(j=0;j<81;j++,p++,q++)
		{
			if(*p!=0)
			{
				*q+=2**p;
				*(q-1)+=*p;*(q+1)+=*p;
				*(q-9)+=*p;*(q+9)+=*p;
				*(q-10)+=*p;*(q+10)+=*p;
				*(q-8)+=*p;*(q+8)+=*p;
			}
		}
		p=dish[0];q=temp[0];
		for(j=0;j<81;j++,p++,q++)
		{
			*p=*q;
			*q=0;
		}
		p=dish[0];q=temp[0];
	}
	for(i=0;i<81;i++)
	{
		if((i+1)%9==0)cout<<*(p+i)<<endl;
		else cout<<*(p+i)<<" ";
	}
	return 0;
}
//************************************************************************
//????????
//???  ???
//???  12-4
//************************************************************************


int a[9][9];      //?????????

void f(int);      //???n????

int main()
{
	int m, n;                   //????????????
	int i, j;

	cin >> m >> n;

	a[4][4] = m;

	f(n);                         //?????????n??????

	for(i = 0; i < 9; i ++)              //????????
	{
		cout << a[i][0];

		for(j = 1; j < 9; j ++)
			cout << " " << a[i][j] ;
					
		cout << endl;
	}

	
	return 0;
}

void f(int n)
{
	int i, j, k, l;

	while(n --)                                 //???n???
	{
		int b[9][9] = {0};                      //????????????????

		for(i = 0; i < 9; i ++)
		for(j = 0; j < 9; j ++)
		{
			if(a[i][j] != 0)                               //????????????????????????
			{
				for(k = i - 1; k <= i + 1; k ++)
				for(l = j - 1; l <= j + 1; l ++)
					b[k][l] += a[i][j];
				b[i][j] += a[i][j];
			}
		}

		for(i = 0; i < 9; i ++)                              //????????????a
		for(j = 0; j < 9; j ++)
			a[i][j] = b[i][j];
	}

}
int main()
{
	int n,m,a[9][9]={0},temp[9][9]={0};
	cin>>n>>m;
	a[4][4]=n;
	while(m)
	{
		m--;
		for(int i=1;i<8;i++)
		{
			for(int j=1;j<8;j++)
			{
				if(a[i][j]!=0)
				{
					for(int p=i-1;p<=i+1;p++)
					{
						for(int q=j-1;q<=j+1;q++)
						{
							temp[p][q]+=a[i][j];
						}
					}
					temp[i][j]+=a[i][j];
				}
			}
		}
		for(int i=0;i<9;i++)
		{
			for(int j=0;j<9;j++)
			{
				a[i][j]=temp[i][j];
				temp[i][j]=0;
			}
		}
	}
	for(int i=0;i<9;i++)
	{
		for(int j=0;j<9;j++)
		{
			if(j==8)
				cout<<a[i][j];
			else
				cout<<a[i][j]<<" ";
		}
		cout<<endl;
	}
	return 0;
}
int main()
{
    int m,n,i,j,x,y,aaa,bbb;
    int num[9][9][5]={{0}};
    scanf("%d %d",&m,&n);
    num[4][4][0]=m;
    for (i=0;i<=n-1;i++)
    {
        aaa=0;
        bbb=0;
        for (x=0;x<=8;x++)
        {
            for (y=0;y<=8;y++)
            {
                if (num[y][x][i]!=0)
                {
                    num[y-1][x-1][i+1]+=num[y][x][i];
                    num[y-1][x][i+1]+=num[y][x][i];
                    num[y-1][x+1][i+1]+=num[y][x][i];
                    num[y][x-1][i+1]+=num[y][x][i];
                    num[y][x+1][i+1]+=num[y][x][i];
                    num[y+1][x-1][i+1]+=num[y][x][i];
                    num[y+1][x][i+1]+=num[y][x][i];
                    num[y+1][x+1][i+1]+=num[y][x][i];
                    num[y][x][i+1]+=2*num[y][x][i];
                    aaa++;
                }
                if (aaa==(2*i+1)*(2*i+1))
                {
                    bbb=1;
                    break;
                }
            }
            if (bbb==1)break;
        }
    }
    for (y=0;y<=8;y++)
    {
        for (x=0;x<=8;x++)
        {
            if (x==8)
            {
                printf("%d",num[y][x][n]);
            }
            else
            printf("%d ",num[y][x][n]);
        }
        printf("\n");
    }
    return 0;
}
int a[9][9];
    int b[9][9];
int main()
{
    void sc(int i,int j);
    int n,m,k,i,j;
    for(i=0;i<9;i++)
    for(j=0;j<9;j++)
    {a[i][j]=0;b[i][j]=0;}
    scanf("%d %d",&m,&n);
    a[4][4]=m;
   for(k=0;k<n;k++)
       {
                    for(i=0;i<9;i++)
                       for(j=0;j<9;j++)
                          {
                              if(a[i][j]!=0)    sc(i,j);  
                          }
                    for(i=0;i<9;i++)
                       for(j=0;j<9;j++)
                         {
                                     a[i][j]=b[i][j];b[i][j]=0;  
                         } 
                         
       }
                        for(i=0;i<9;i++)
                        {for(j=0;j<8;j++)
                        {printf("%d ",a[i][j]);}
                        printf("%d\n",a[i][8]);}
                        
} 
void sc(int i,int j)
{
     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]=b[i][j]+a[i][j]*2;
}
//********************************
//*???????????   **
//*?????? 1300012861 **
//*???2013.12.04  **
//********************************
int a[12][12] = {0}, b[12][12] = {0}, m, n; 
void result(int day, int a[][12])
{
	int i, j; 
	if ( day == n ) //?????? 
	{
		for ( i = 1; i <= 9; i++) //?????
		{
			for ( j = 1; j < 9; j++)
				cout << a[i][j] << " "; 
			cout << a[i][9] << endl;  
			cout << endl; 
		}
		return;
	}
	for ( i = 1; i <= 9; i++)
	{
		for ( j = 1; j <= 9; j++)
		{
			if ( a[i][j] != 0 )
				b[i][j] = a[i][j]; //???????? ????
		}
	}
	for ( i = 1; i <= 9; i++ )
	{
		for ( j = 1; j <= 9; j++)
		{
			if ( b[i][j] != 0 ) //???????
			{
				a[i][j] += b[i][j]; //????2?
				a[i-1][j-1] += b[i][j]; //?????????
				a[i-1][j] += b[i][j];
				a[i-1][j+1] += b[i][j];
				a[i][j-1] += b[i][j];
				a[i][j+1] += b[i][j];
				a[i+1][j-1] += b[i][j];
				a[i+1][j] += b[i][j];
				a[i+1][j+1] += b[i][j];
			}
		}
	}
	result(day+1, a); //??????? 
	return;
} 
int main()
{
	cin >> m >> n; 
	a[5][5] = m; //????????
	result (0, a); //???????
	return 0; 
}
void f(int a[12][12],int m)
{   if(m==0)   return ;
    int i,j;
    int b[12][12]={0};
    for(i=1;i<=9;i++)
      for(j=1;j<=9;j++)
        {  if(a[i][j]!=0)
              {  b[i][j]=b[i][j]+2*a[i][j];
                 b[i+1][j]=b[i+1][j]+a[i][j];
                 b[i-1][j]=b[i-1][j]+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]=b[i-1][j+1]+a[i][j];
                 b[i][j+1]=b[i][j+1]+a[i][j];
                 b[i][j-1]=b[i][j-1]+a[i][j];
              }
        }
    for(i=1;i<=9;i++)
      for(j=1;j<=9;j++)
        {  a[i][j]=b[i][j];
        }
    f(a,m-1);
}
int main()
{   int a[12][12]={0};
    int n,m;
    cin>>n>>m;
    a[5][5]=n;
    f(a,m);
    int i,j;
    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 a[9][9]={0},b[9][9]={0},i,j,k,m,n,l,x,y,t;//a??????????b????????????????
	cin>>m;
	cin>>n;
	a[4][4]=m;
	for(i=0;i<n;i++)
	{
		for(y=0;y<=8;y++)
			for(t=0;t<=8;t++)
			b[y][t]=0;
		for(j=4-i;j<=(4+i);j++)
		{
			for(k=4-i;k<=(4+i);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][k+1]=b[j][k+1]+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];
			}
		}
				for(l=3-i;l<=(5+i);l++)
				{
					for(x=3-i;x<=(5+i);x++)
					{
						a[l][x]=2*a[l][x]+b[l][x];//????????
					}
				}

	}
	for(i=0;i<=8;i++)
	{
		for(j=0;j<=7;j++)
		{
			cout<<a[i][j]<<" ";
		}
		cout<<a[i][8]<<endl;//????
	}
	return 0;
}