semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
	int stat[2][11][11];	
	int m, n;
	int i, j, k;
	int tmp1, tmp2;

	scanf("%d %d", &m, &n);
	for (i = 0; i < 2; i++) {
		for (j = 0; j < 11; j++) {
			for (k = 0; k < 11; k++) {
				stat[i][j][k] = 0;
			}
		}
	}
	stat[0][5][5] = 1;

	for (i = 0; i < n; i++) {	
		tmp1 = i % 2;
		tmp2 = (i + 1) % 2;
		for (j = 1; j <= 9; j++) {	
			for (k = 1; k <= 9; k++) {
				stat[tmp2][j][k] = stat[tmp1][j - 1][k - 1] + stat[tmp1][j - 1][k]
					+ stat[tmp1][j - 1][k + 1] + stat[tmp1][j][k - 1]
					+ stat[tmp1][j][k] * 2 + stat[tmp1][j][k + 1]
					+ stat[tmp1][j + 1][k - 1] + stat[tmp1][j + 1][k]
					+ stat[tmp1][j + 1][k + 1];
			}
		}
	}

	i = n % 2;
	for (j = 1; j <= 9; j++) {	
		for (k = 1; k <= 9; k++) {
			printf("%d", m * stat[i][j][k]);
			if(k!=9)
			printf(" ");
		}
		printf("\n");
	}

	return 0;
}
void zengjia();
int num[9][9] = {0};

int main()
{
	int m, n, i, j;
	cin >> m >> n;
	num[4][4] = m;
	for (i = 0; i < n; i++)
		zengjia();
	for (i = 0; i < 9; i++)
	{
		cout << num[i][0];
		for (j = 1; j < 9; j++)
			cout << " " << num[i][j];
		cout << endl;
	}
	return 0;
}
void zengjia()
{
	int num2[9][9] = {0};
	int i, j;
	for (i = 0; i < 9; i++)
		for (j = 0; j < 9; j++)
		{
			if (num[i][j] > 0)
			{
			if (i > 0)
				num2[i - 1][j] = num[i][j] + num2[i - 1][j];
			if (i < 8)
				num2[i + 1][j] = num[i][j] + num2[i+ 1][j];
			if (j > 0)
				num2[i][j - 1] = num[i][j] + num2[i][j - 1];
			if (j < 8)
				num2[i][j + 1] = num[i][j] + num2[i][j + 1];
			if (i > 0 && j > 0)
				num2[i - 1][j - 1] = num[i][j] + num2[i - 1][j - 1];
			if (i < 8 && j > 0)
				num2[i + 1][j - 1] = num[i][j] + num2[i + 1][j - 1];
			if (i > 0 && j < 8)
				num2[i - 1][j + 1] = num[i][j] + num2[i - 1][j + 1];
			if (i < 8 && j < 8)
				num2[i + 1][j + 1] = num[i][j] + num2[i + 1][j + 1];
			num2[i][j] = num[i][j] * 2 + num2[i][j];
			}
		}
	for (i = 0; i < 9; i++)
		for (j = 0; j < 9; j++)
			num[i][j] = num2[i][j];
	return;
}
int c[11][11]={0};                        //???n?????
int temp[11][11]={0};                 //????n-1?????
int n,m;
int deal(int num);
int main()
{
	int i,j;
	cin>>m>>n;
	c[5][5]=m;
	temp[5][5]=m;
	deal(1);
	for (i=1;i<=9;i++)
	{
		for (j=1;j<=8;j++)
			cout<<c[i][j]<<' ';
		    cout<<c[i][9];
		cout<<endl;
	}
	return 0;
}
int deal(int num)
{
	int i,j;
	if (num==n+1)                    //??????
		return 0;
	else
	{
		for (i=1;i<=9;i++)
			for (j=1;j<=9;j++)
			{
				c[i][j]+=temp[i][j];
				c[i+1][j]+=temp[i][j];
				c[i-1][j]+=temp[i][j];
				c[i][j+1]+=temp[i][j];
				c[i][j-1]+=temp[i][j];
				c[i+1][j+1]+=temp[i][j];
				c[i+1][j-1]+=temp[i][j];
				c[i-1][j+1]+=temp[i][j];
				c[i-1][j-1]+=temp[i][j];

			}
		for (i=1;i<=9;i++)
			for (j=1;j<=9;j++)
				temp[i][j]=c[i][j];
			deal(num+1);
	}

}
int m,n,i,j;//m???????????,n???????
	int a[10][10]={0};
	
int pat(int a[][10],int n)
{
	int b[10][10],x,y;
	if(n==0)
	{
		for(i=1;i<=9;i++)
		{
			for(j=1;j<=8;j++)
				cout<<a[i][j]<<" ";
			cout<<a[i][9]<<endl;
			
		
		}
		return 0;
	}
	else
	{
		for(i=1;i<=9;i++)
			for(j=1;j<=9;j++)
				b[i][j]=a[i][j]*2+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(x=1;x<=9;x++)
			for(y=1;y<=9;y++)
				a[x][y]=b[x][y];
		return pat(a,n-1);
	}
}
int main()
{
	cin>>m>>n;
	a[5][5]=m;
	
		pat(a,n);
	

	return 0;
	
}
int main()
{
	int m,n;       //?? ???????? ??
	int i,j,k,p,q;       //????
	int b[9][9][5]={0};   //?? ????0 b???? b[i][j][k]???i??j??k?
	scanf("%d %d", &m, &n);
	b[4][4][0]=m;
	//printf("%d", b[8][8][3]);
	
	for(i=1;i<=n;i++)   //??????
	{
		for(j=1;j<8;j++)
		{
			for(k=1;k<8;k++)
			{
				while(b[j][k][i-1]!=0)
				{
					//printf("xunhuan");
					b[j][k+1][i]+=b[j][k][i-1];
					b[j][k-1][i]+=b[j][k][i-1];
					b[j-1][k-1][i]+=b[j][k][i-1];
					b[j-1][k][i]+=b[j][k][i-1];
					b[j-1][k+1][i]+=b[j][k][i-1];
					b[j+1][k-1][i]+=b[j][k][i-1];
					b[j+1][k][i]+=b[j][k][i-1];
					b[j+1][k+1][i]+=b[j][k][i-1];
					b[j][k][i]+=2*b[j][k][i-1];
					break;
				}
			}
		}
	}
	for(p=0;p<=8;p++)
	{
		for(q=0;q<8;q++)
			printf("%d ", b[p][q][n]);
		printf("%d\n", b[p][8][n]);
	}

	return 0;
}
int main()
{
    int m,n,i,j,k;
    cin>>m>>n;
    int a[11][11][2];
    for(i=0;i<11;i++)
    {
        for(j=0;j<11;j++)
        {
            a[i][j][0]=0;
        }
    }
    a[5][5][0]=m;
    for(k=1;k<=n;k++)
    {
        for(i=1;i<=9;i++)
        { 
            for(j=1;j<=9;j++)
            {
                a[i][j][1]=a[i][j][0]*2+a[i][j-1][0]+a[i][j+1][0]+a[i+1][j][0]+a[i-1][j][0]+a[i+1][j+1][0]+a[i-1][j-1][0]+a[i+1][j-1][0]+a[i-1][j+1][0];
            }
        }
        for(i=1;i<=9;i++)
        {
            for(j=1;j<=9;j++)
            {
                a[i][j][0]=a[i][j][1];
            }
        }
    }
    for(i=1;i<=9;i++)
    {
        cout<<a[i][1][1];
        for(j=2;j<=9;j++)
        {
            cout<<' '<<a[i][j][1];
        }
        cout<<endl;
    }
    return 0;
}
int a[9][9]={0};
int b[9][9]={0};
void ganster()
{
     int i,j,c;
     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<9;j++)
        {
           if(a[i][j]!=0)
           {c=a[i][j];
           b[i][j]+=c;b[i][j-1]+=c;b[i][j+1]+=c;
           b[i+1][j]+=c;b[i+1][j-1]+=c;b[i+1][j+1]+=c;
           b[i-1][j]+=c;b[i-1][j-1]+=c;b[i-1][j+1]+=c;}
        }
     }
     for(i=0;i<9;i++)
     for(j=0;j<9;j++)
     a[i][j]+=b[i][j];
}
int main(void)
{
    int m,n,i,j;
    scanf("%d%d",&m,&n);
    a[4][4]=m;
    for(i=0;i<n;i++)
    {
         ganster();
    }
    for(i=0;i<9;i++)
    {
       for(j=0;j<8;j++)
       {
          printf("%d ",a[i][j]);
       }
       printf("%d\n",a[i][j]);
    }
        
}
int main()
{
 	int m,n,row,col,i;
 	int sz[11][11],by[11][11];
 	scanf("%d %d",&m,&n);
 	for(row=1;row<=9;row++){
			for(col=1;col<=9;col++){
				sz[row][col]=0;
				by[row][col]=0;
				}
			}
	sz[5][5]=m;
	by[5][5]=m;
	for(i=1;i<=n;i++){
	for(row=1;row<=9;row++){
		for(col=1;col<=9;col++){
			if(sz[row][col]!=0){
				by[row][col]=sz[row][col]+by[row][col];
				by[row-1][col]+=sz[row][col];
				by[row-1][col-1]+=sz[row][col];
				by[row-1][col+1]+=sz[row][col];
				by[row][col-1]+=sz[row][col];
				by[row][col+1]+=sz[row][col];
				by[row+1][col]+=sz[row][col];
				by[row+1][col-1]+=sz[row][col];
				by[row+1][col+1]+=sz[row][col];
				}
			}
		}
	for(row=1;row<=9;row++){
		for(col=1;col<=9;col++){
			sz[row][col]=by[row][col];
			}
		}
    }
    for(row=1;row<=9;row++){
		for(col=1;col<=9;col++){
			if(col!=9) printf("%d ",sz[row][col]);
			else printf("%d\n",sz[row][col]);
			}
		}
 	
    return 0;
}
int m,n;
int num(int a,int b,int c)
{
    int i,j;
    if((a==0)||(a==10)||(b==0)||(b==10))
    return 0;
    else if(c==0)
    {
       if (a==5&&b==5)
       return m;
       else return 0;
    }
    else 
    {  
       int d=num(a,b,c-1);
       for(i=a-1;i<=a+1;i++)
       {
          for(j=b-1;j<=b+1;j++)
          d=d+num(i,j,c-1);
       }
       return d;
    }
} 
int main()
{
    int i,j,s;
    scanf("%d %d",&m,&n);
    for(i=1;i<=9;i++)
    {
        for(j=1;j<=9;j++)
        {
            s=num(i,j,n);
            if(j==9)
            printf("%d\n",s);
            else printf("%d ",s);
         }
    }
    return 0;

}
int a[9][9] = {0}, b[9][9] = {0}; //a????????b????????

void propagate( int m, int n )
{
 	 int k = 0;
 	 int num; //?????? 
 
	 a[4][4] = m;
	 
	 while ( k < n )
	 {
    	 for ( int i = 0; i < 9; i++ )
	 	 {
	   	  	 for ( int j = 0; j < 9; j++ )
	 	 	 {
	 	   	  	 b[i][j] = 0; //????? 
		  	 }
		 }
		 
	  	for (int i = 0; i < 9; i++ )
		{
 		 	for ( int j = 0; j < 9; j++ )
 		 	{
	 	  	 	if ( a[i][j] != 0 )
	 	  	 	{
	 	   	 	   	num = a[i][j];
					a[i][j] = 2 * num;
					b[i-1][j-1] += num;
					b[i-1][j] += num;
					b[i-1][j+1] += num;
					b[i+1][j] += num;
					b[i+1][j+1] += num;
					b[i+1][j-1] += num;
					b[i][j+1] += num;
					b[i][j-1] += num; 
			  	}
		   	}
	 	}
		 
		for ( int i = 0; i < 9; i++ )
		{
 		 	for ( int j = 0; j < 9; j++ )
 		 	{
	 	  	 	a[i][j] += b[i][j];
		   	}
	 	}	  	   
        k++;
  	 }
  	 
  	 for ( int x = 0; x < 9; x++ )
  	 {
   	  	 for ( int y = 0; y < 9; y++ )
		 {
 	 	  	 if ( y == 0 )
				 cout << a[x][y];
			 else if ( y == 8 )
			 	  cout << " " << a[x][y] << endl;
			 else
			 	 cout << " " << a[x][y]; 
   		 } 
	 }
}

int main()
{
 	int m, n;
 	
 	cin >> m >> n;
 	
 	propagate( m, n );
 	
 	return 0;
}
int a[9][9]={0},m,n;
void produce(int i,int j,int n)
{
	if(n == 0)
	{
		return;
	}
	else
	{
		a[i - 1][j - 1] += m;
		a[i - 1][j] += m;
		a[i - 1][j + 1] += m;
		a[i][j - 1] +=m;
		a[i][j] += m;
		a[i][j + 1] += m;
		a[i + 1][j - 1] += m;
		a[i + 1][j] += m;
		a[i + 1][j + 1] += m;
		produce(i,j,n-1);
		produce(i,j,n-1);
		produce(i-1,j-1,n-1);
		produce(i-1,j,n-1);
		produce(i-1,j+1,n-1);
		produce(i,j-1,n-1);
		produce(i,j+1,n-1);
		produce(i+1,j-1,n-1);
		produce(i+1,j,n-1);
		produce(i+1,j+1,n-1);
	}
}


int main()
{
	cin>>m>>n;
	a[4][4]=m;
	produce(4,4,n);
	int row=0,col=0;
	for(row=0;row<=8;row++)
	{
		for(col=0;col<=8;col++)
		{
			if(col != 8)
			{
				cout<<a[row][col]<<" ";
			}
			else
			{
				cout<<a[row][col]<<endl;
			}
		}
	}
	return 0;
}
main()
{
      int a[9][9],b[9][9],i,j,k,m,n,fx,fy;
      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(fx=-1;fx<=1;fx++)
                                             {
                                                        for(fy=-1;fy<=1;fy++)
                                                        b[i+fx][j+fy]+=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]);
      }
}
int a[11][11];
void day()
{
     int i,j,b[11][11];
     for(i=0;i<11;i++)for(j=0;j<11;j++)b[i][j]=a[i][j];
     for(i=1;i<=9;i++)
     for(j=1;j<=9;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]+=a[i][j];
     }
     for(i=0;i<11;i++)for(j=0;j<11;j++)a[i][j]=b[i][j];
}    
int main()
{
    int i,j,n,days;
    for(i=0;i<11;i++)for(j=0;j<11;j++)a[i][j]=0;
    cin>>n;cin>>days;
    a[5][5]=n;
    for(i=1;i<=days;i++)day();
    for(i=1;i<10;i++)
    {
                     cout<<a[i][1];for(j=2;j<10;j++)cout<<' '<<a[i][j];cout<<endl;
    }
    getchar();getchar();
    return 0;
}
int main()
{
	int i, j, m, day, a[9][9] = {0};
	cin >> m >> day;
	a[4][4] = m;
	while(day--)
	{
		int b[9][9] = {0};
		for(i = 0; i < 9; i++)
		{
			for(j = 0; j < 9; j++)
			{
				if(a[i][j] > 0)
				{
					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];
				}
			}
		}
		for(i = 0; i < 9; i++)
		{
			for(j = 0; j < 9; j++)
			{
				a[i][j] = 2 * a[i][j] +  b[i][j];
			}
		}
	}
	for(i = 0; i < 9; i++)
	{
		for(j = 0; j < 9; j++)
		{
			if(j == 0)
			{
				cout << a[i][j];
			}
			else if(j == 8)
			{
				cout << " " << a[i][j] << endl;
			}
			else if(j > 0 && j < 8)
			{
				cout << " " << a[i][j];
			}
		}
	}
	return 0;
}
int main()
{
	int a[5][11][11]={0};
	int m,n,i,j,k;
	cin>>m>>n;
	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][k]=2*a[i][j][k]+a[i][j-1][k-1]+a[i][j-1][k+1]+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];
			}
	for(j=1;j<=9;j++)
	{cout<<a[n][j][1];
	for(k=2;k<=9;k++)
		cout<<' '<<a[n][j][k];
	cout<<endl;
	}
	return 0;
}
int main()
{
	int n[5][9][9],a,b,k=0,i,j;
	cin>>a>>b;
	memset(n,0,sizeof(n));
	n[0][4][4]=a;
	for(i=1;i<=b;i++)
	{
		for(j=0;j<9;j++)
		{
			for(k=0;k<9;k++)
			{
				n[i][j][k]=n[i-1][j][k]*2;
				if(j>0)
				{
					n[i][j][k]+=n[i-1][j-1][k];
					if(k>0)
					{
						n[i][j][k]+=n[i-1][j-1][k-1];
					}
					if(k<8)
					{
						n[i][j][k]+=n[i-1][j-1][k+1];
					}
				}
				if(k>0)
				{
					n[i][j][k]+=n[i-1][j][k-1];
				}
				if(k<8)
				{
					n[i][j][k]+=n[i-1][j][k+1];
				}
				if(j<8)
				{
					n[i][j][k]+=n[i-1][j+1][k];
					if(k>0)
					{
						n[i][j][k]+=n[i-1][j+1][k-1];
					}
					if(k<8)
					{
						n[i][j][k]+=n[i-1][j+1][k+1];
					}
				}
			}
		}
	}
	for(i=0;i<9;i++)
	{
		cout<<n[b][i][0];
		for(j=1;j<9;j++)
		{
			cout<<' '<<n[b][i][j];
		}
		cout<<endl;
	}
	return 0;
}
void xijun(int a[5][11][11],int x,int n)
{
	int i,j,k;

	for(i=1;i<=n;i++)
	{

	
		for(j=1;j<10;j++)
		{
			for(k=1;k<10;k++)
			{
				a[i][j][k]=2*(a[i-1][j][k])+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];
			}
		}
	}
}
void main()
{
	int m,n;
	scanf("%d%d",&m,&n);
	int a[5][11][11]={0};
	a[0][5][5]=m;
	xijun (a,m,n);
	int i,j;
	for(i=1;i<10;i++)
	{
		for(j=1;j<10;j++)
		{
			if(j==9)
			{
				printf("%d\n",a[n][i][j]);
				continue;
			}
			printf("%d ",a[n][i][j]);
		}
	}
}
int main()
{
    int num[10][10];    //?? 1 ? 9 
    int next[10][10];
    int m,n;
    int i,j,k;
    
    for(i=0;i<10;i++)
       for(j=0;j<10;j++)
          {num[i][j]=0;
           next[i][j]=0;}
       
    cin>>m;   //??num?5??5?????m? 
    cin>>n;   //n? 
    
    num[5][5]=m;
    for(i=0;i<n;i++)
         {
          for(j=1;j<9;j++)
              for(k=1;k<9;k++)
                  if(num[j][k]!=0)
                       {
                        next[j][k]+=num[j][k]*2;
                        next[j-1][k]+=num[j][k];           
                        next[j+1][k]+=num[j][k];
                        next[j][k-1]+=num[j][k];
                        next[j][k+1]+=num[j][k];
                        next[j-1][k-1]+=num[j][k];
                        next[j-1][k+1]+=num[j][k];
                        next[j+1][k+1]+=num[j][k];
                        next[j+1][k-1]+=num[j][k];
                        }
                        
          for(j=0;j<10;j++)
               for(k=0;k<10;k++)
               {num[j][k]=next[j][k];              
                next[j][k]=0;}    
          }
    
    for(i=1;i<10;i++)
         {
          for(j=1;j<9;j++)
              cout<<num[i][j]<<" ";
          cout<<num[i][j]<<endl;} 
    return 0;
}
int a[20][20],b[20][20];
void print()
{
     int i,j;
     for (i=1;i<=9;i++)
     for (j=1;j<=9;j++)
        if (j<9) printf("%d ",a[i][j]);
        else printf("%d\n",a[i][j]);
}
main()
{     int m,n,i,j,d;
      scanf("%d %d",&m,&n);
      for (i=0;i<=10;i++)
      for (j=0;j<=10;j++)
      a[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]=0;
          for (i=1;i<=9;i++)
          for (j=1;j<=9;j++)
          if (a[i][j]>0) 
          {
          b[i][j]=b[i][j]+a[i][j]*2;
          b[i-1][j-1]=b[i-1][j-1]+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][j-1]=b[i][j-1]+a[i][j];
          b[i][j+1]=b[i][j+1]+a[i][j];
          b[i+1][j-1]=b[i+1][j-1]+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];
          }
          for (i=1;i<=9;i++)
          for (j=1;j<=9;j++)
          a[i][j]=b[i][j];
          if (d==n) 
          print();
      }
}
int main(){
	int sz[11][11][5]={0},n,i,k,d;
	scanf("%d",&sz[5][5][0]);
	scanf("%d",&n);
	for(d=0;d<n;d++){
		for(i=1;i<10;i++){
			for(k=1;k<10;k++){
				sz[i][k][d+1]=2*sz[i][k][d];
				sz[i][k][d+1]+=sz[i-1][k][d]+sz[i][k-1][d]+sz[i+1][k][d]+sz[i][k+1][d]+sz[i+1][k+1][d]+sz[i-1][k-1][d]+sz[i+1][k-1][d]+sz[i-1][k+1][d];
			}
		}
	}
	for(i=1;i<10;i++){
		for(k=1;k<9;k++){
			printf("%d ",sz[i][k][n]);
		}
		printf("%d\n",sz[i][9][n]);
	}
	return 0;
}
int main()
{
    int a[9][9]={{0}},b[9][9]={{0}};
    int days,i,j,k,l,m;
    cin>>a[4][4]>>days;
    for(i=0;i<days;i++)
      {for(l=0;l<9;l++)
         for(m=0;m<9;m++)
                b[l][m]=0;
      for(j=1;j<8;j++)
        for(k=1;k<8;k++)
          {
            if(a[j][k]==0)continue;
            else
            {
                b[j][k]+=2*a[j][k];
                b[j-1][k-1]+=a[j][k];
                b[j+1][k+1]+=a[j][k];
                b[j-1][k+1]+=a[j][k];
                b[j+1][k-1]+=a[j][k];
                b[j][k+1]+=a[j][k];
                b[j-1][k]+=a[j][k];
                b[j+1][k]+=a[j][k];
                b[j][k-1]+=a[j][k];
                a[j][k]=0;
            }
          }
        for(j=0;j<9;j++)
          for(k=0;k<9;k++)
            a[j][k]=b[j][k];
      }
    for(j=0;j<9;j++)
       {
         cout<<a[j][0];
         for(k=1;k<9;k++)
         {cout<<" "<<a[j][k];}
         cout<<endl;
       }
    cin>>days;
    return 0;
}
//
//  main.c
//  aa
//
//  Created by Duan on 12-11-27.
//  Copyright (c) 2012? __MyCompanyName__. All rights reserved.
//

void nextday(int a[11][11],int b[11][11])
{
    int i,j;
    for (i=1;i<=9;i++)
        for (j=1;j<=9;j++)
            b[i][j]=0;
    for (i=1;i<=9;i++)
        for (j=1;j<=9;j++)
        {
            b[i][j]+=a[i][j]*2;
            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];
        }
}
void printarray(int a[11][11])
{
    int i,j;
    for (i=1;i<=9;i++)
        for (j=1;j<=9;j++)
        {
            printf("%d",a[i][j]);
            if (j!=9) printf(" ");
            else printf("\n");
        }
}

int main()
{
    int m,n,i;
    scanf("%d %d",&m,&n);
    int a[11][11]={0},b[11][11]={0};
    a[5][5]=m;
    for (i=0;i<=n;i++)
    {
        if (i%2==0) nextday(a, b);
        else nextday(b, a);
    }
    if(i%2==0) printarray(b);
    else printarray(a);
}
int main()
{
    int a[11][11]={0},b[11][11]={0};
    int n,t;
    int i,j;
    scanf("%d%d",&t,&n);
    a[5][5]=t;
    while (n>0)
    {
        for (i=1;i<=9;i++) for (j=1;j<=9;j++)
        {
                b[i][j]=2*a[i][j]+a[i-1][j]+a[i-1][j-1]+a[i-1][j+1]+
                                  a[i+1][j]+a[i+1][j+1]+a[i+1][j-1]+
                                  a[i][j-1]+a[i][j+1];
        }
        for (i=1;i<=9;i++) for (j=1;j<=9;j++)
              a[i][j]=b[i][j];
        n--;
    }
    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[11][11]={0},b[11][11] ={0};
  int m,n,i,j,k;
  int(*p1)[11],(*p2)[11],(*pTemp)[11];
  p1=a;
  p2=b;
  
  
  for (i=0;i<=10;i++)
    {   for (j=0;j<=10;j++)
        {
         a[i][j]=0;
         b[i][j]=0;
        }
     }
  scanf("%d%d",&m,&n);
  a[5][5]=m;
  
  for (k=1;k<=n;k++)
     {   
         for ( i=1;i<=9;i++)
          {
              for ( j=1;j<=9;j++) 
              {
                   int sum=  + *(*(p1+i)+ j-1)+*(*(p1+i)+ j+1) +*(*(p1+i-1)+ j) +*(*(p1+i-1)+ j-1)+*(*(p1+i-1)+ j+1) +*(*(p1+i+1)+ j) +*(*(p1+i+1)+ j-1)+*(*(p1+i+1)+ j+1) ;
                * (*(p2+i)+j )  = sum +( *     (   * (p1+i)  +j )      )  *2 ;
              }
          }
         pTemp=p1;
         p1=p2;
         p2=pTemp; 
     }
     
    for ( i=1;i<=9;i++)
          {
              for ( j=1;j<=9;j++) 
              {
                  if (j!=9)
                  printf("%d ",p1[i][j]);
                  else 
                  printf( "%d\n",p1[i][j]);
              }
          }
  
 
    
}
void fanzhi();
int a[9][9]={0};
int zhen[9][9]={0};
int main()
{
    int i,j,n,m;
    cin>>m;
    cin>>n;
    a[4][4]=m;
    for(i=1;i<=n;i++)
    {
      fanzhi();                 
    }
   for(i=0;i<=8;i++)
   {
     for(j=0;j<=7;j++)
     cout<<a[i][j]<<" ";
     cout<<a[i][8];
     cout<<endl;                  
   }
    
    return 0;
}

void fanzhi()
{int i,j;
   memset(zhen,0,sizeof(zhen));
   for(i=0;i<=8;i++)
     for(j=0;j<=8;j++)
     {
       zhen[i+1][j]+=a[i][j];
       zhen[i][j]+=a[i][j]*2;               
       zhen[i-1][j]+=a[i][j];
       zhen[i][j-1]+=a[i][j];
       zhen[i][j+1]+=a[i][j];
       zhen[i+1][j+1]+=a[i][j];
       zhen[i-1][j+1]+=a[i][j];
       zhen[i+1][j-1]+=a[i][j];
       zhen[i-1][j-1]+=a[i][j];          
     }
    for(i=0;i<=8;i++)
      for(j=0;j<=8;j++)
       {
          a[i][j]=zhen[i][j];          
       }   
}
int main()
{
	int m, n, a[9][9] = {0}, b[9][9] = {0}, d[8][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}, {1, -1}, {-1, 1}, {-1, -1}, {1, 1}};
	cin >> m >> n;
	a[4][4] = m;
	for (int i = 1; i <= n; i ++)
	{
		for (int j = 0; j < 9; j ++)
			for (int k = 0; k < 9; k ++)
			{
				if (a[j][k] != 0)
				{
					for (int t = 0; t < 8; t ++)
					{
						int x = d[t][0];
						int y = d[t][1];
						b[j + x][k + y] = b[j + x][k + y] + a[j][k];
					}
					b[j][k] = b[j][k] + 2 * a[j][k];
				}
			}
		for (int j = 0; j < 9; j ++)
			for (int k = 0; k < 9; k ++)
			{
				a[j][k] = b[j][k];
				b[j][k] = 0;
			}
	}
	for (int j = 0; j < 9; j ++)
		for (int k = 0; k < 9; k ++)
		{
			if (k < 8)
			{
				cout << a[j][k] << " ";
			}
			if (k == 8)
			{
				cout << a[j][k] << endl;
			}
		}
	return 0;
}
//****************************************
//*???  ???????        **
//*????? 1100012996       **
//*???2011.11.23**
//****************************************
int main()
{
	int a[9][9] = {0}, b[9][9];
	int i , j , k , m , n , p , q ;
	cin >> m >> n;
	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 ( p = -1; p <= 1 ; p++)
					for (q = -1; q <= 1; q++)
					{
						b[i + p][j + q] += a[i][j];
					}
			}
			memcpy(a , b ,sizeof(a));
	}
	for (i = 0; i < 9; i++)
		for (j = 0; j < 9; j++)
		{
			if (j == 0)
			{
				cout << a[i][j];
			}
			
			else
			{
				cout << " " << a[i][j];
			}
			if (j == 8)
			{
				cout << endl;
			}
		}
	return 0;
}
//****************************
//*???:2.cpp               *
//*??:??                  *
//*????:2013?12?6?     *
//*????:????????   *
//****************************
int a[11][11] = {0};                         //??????a[][]??????,???b????????????
void done ( int m, int n )                   //???done????????a??
{
	int b[11][11] = {0}, i, j;               //??????b[][]???????????????????????
	if ( n == 0 )                            //?????????????
		a[5][5] = m;
	else
	{
		done ( m, n - 1 );                   //??????
		for ( i = 1; i <= 9; i ++ )          //??????a
			for ( j = 1; j <= 9; j ++ )
			{
				if ( a[i][j] != 0 )          //??a[][]????????????????
				{                            //????????????????????????
					for ( int k = i - 1; k <= i + 1; k ++ )
						for ( int t = j - 1; t <= j + 1; t ++ )
							b[k][t] = a[i][j] + b[k][t];
					b[i][j] = b[i][j] + a[i][j];    //???????????????????????
				}
			}
		for ( i = 1; i <= 9; i ++ )          //????????b???????a?????????????
			for ( j = 1; j <= 9; j ++ )
				a[i][j] = b[i][j];
	}
}
int main()                              //???
{
	int m, n, i, j;                     //??????m,????n
	cin >> m >> n;
	done ( m, n );                      //????done???
	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;
}