semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
    int a[9][9], b[9][9];
	int m, n;
	int i, j, k;
	cin>>m;
	cin>>n;
	for(j=0;j<9;j++)
	{
		for(i=0;i<9;i++)
		{
			a[j][i]=0;
		}
	}
		for(j=0;j<9;j++)
	{
		for(i=0;i<9;i++)
		{
			b[j][i]=0;
		}
	}
		for(k=0;k<n;k++)
        {
            if(k==0)
            {
                a[4][4]=2*m;
                a[3][3]=m;
                a[3][4]=m;
                a[3][5]=m;
                a[4][3]=m;
                a[4][5]=m;
                a[5][3]=m;
                a[5][4]=m;
                a[5][5]=m;
            }
            if(k==1)
            {
	            for(j=1;j<8;j++)
	            {
		            for(i=1;i<8;i++)
		            {
			            b[j][i]=2*a[j][i]+a[j-1][i-1]+a[j-1][i]+a[j-1][i+1]+a[j][i-1]+a[j][i+1]+a[j+1][i-1]+a[j+1][i]+a[j+1][i+1];
		            } 
	            }
	            for(j=0;j<9;j++)
	            {
		            for(i=0;i<9;i++)
	                {
			            a[j][i]=b[j][i];
		            }
	            }
            }
            if(k==2)
            {
	            for(j=1;j<8;j++)
	            {
		            for(i=1;i<8;i++)
		            {
			            b[j][i]=2*a[j][i]+a[j-1][i-1]+a[j-1][i]+a[j-1][i+1]+a[j][i-1]+a[j][i+1]+a[j+1][i-1]+a[j+1][i]+a[j+1][i+1];
		            } 
	            }
	            for(j=0;j<9;j++)
	            {
		            for(i=0;i<9;i++)
		            {
			            a[j][i]=b[j][i];
		            }
	            }
            }
            if(k==3)
            {
	            for(j=1;j<8;j++)
	            {
		            for(i=1;i<8;i++)
		            {
			            b[j][i]=2*a[j][i]+a[j-1][i-1]+a[j-1][i]+a[j-1][i+1]+a[j][i-1]+a[j][i+1]+a[j+1][i-1]+a[j+1][i]+a[j+1][i+1];
		            } 
	            }
                for(i=1;i<8;i++)
                {
                    b[0][i]=a[1][i-1]+a[1][i]+a[1][i+1];
                }
                for(i=1;i<8;i++)
                {
                    b[8][i]=a[7][i-1]+a[7][i]+a[7][i+1];
                }
                for(j=1;j<8;j++)
                {
                    b[j][0]=a[j-1][1]+a[j][1]+a[j+1][1];
                }
                for(j=1;j<8;j++)
                {
                    b[j][8]=a[j-1][7]+a[j][7]+a[j+1][7];
                } 
                b[0][8]=b[8][8]=b[8][0]=b[0][0]=a[1][1];                    
	            for(j=0;j<9;j++)
	            {
		            for(i=0;i<9;i++)
		            {
			            a[j][i]=b[j][i];
		            }
	            }
            }
        }                          
	for(j=0;j<9;j++)
	{
		for(i=0;i<8;i++)
		{
			cout<<a[j][i]<<" ";
		}
		    cout<<a[j][8]<<endl;
	}
	return 0;
}
main()
{
    int m,n;
    int b[5][11][11]={0};
    int i,j,k;
    scanf("%d %d",&m,&n);
    b[0][5][5]=m;
    for(i=1;i<n+1;i++)
    {
        for(j=5-i;j<=5+i;j++)
        {
            for(k=5-i;k<=5+i;k++)
            {
                b[i][j][k]=2*b[i-1][j][k]+b[i-1][j][k-1]+b[i-1][j][k+1]+b[i-1][j-1][k-1]+b[i-1][j-1][k+1]+b[i-1][j-1][k]+b[i-1][j+1][k]+b[i-1][j+1][k-1]+b[i-1][j+1][k+1];
            }
        }
    }
    for(i=1;i<10;i++)
    {
    printf("%d",b[n][i][1]);
    for(j=2;j<10;j++)
    printf(" %d",b[n][i][j]);
    printf("\n");
    }
}
int main(){
        int a[11][11][5];
        int m,n;
        scanf("%d%d",&m,&n);
        int i,j,k;

        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=0;i<=10;i++){
                        for(j=0;j<=10;j++){
							if(i>0&&i<10&&j>0&&j<10){
								a[i][j][k]=2*a[i][j][k-1]+a[i-1][j-1][k-1]+a[i-1][j][k-1]+a[i-1][j+1][k-1]+a[i][j-1][k-1]+a[i][j+1][k-1]+a[i+1][j-1][k-1]+a[i+1][j][k-1]+a[i+1][j+1][k-1];
							}
							else{
								a[i][j][k]=a[i][j][k-1];
							}
                                
                       }
                }

			


        }



       for(i=1;i<=9;i++){
                for(j=1;j<=9;j++){
					if(j<9){
                        printf("%d ",a[i][j][n]);
					}
					if(j==9){
						printf("%d\n",a[i][j][n]);
					}
                }

				
        }


        return 0;
}
/**
* @file 1.cpp
* @author ??? 1100012944
* @date 2011-11-23
* @description
* ???????????????
*/
int day, num0;
int germf(int x, int y, int t)
{
	if ( t == 0 && x == 5 && y == 5 )
		return num0;
	else if ( t == 0 && x >= 0 && x <= 10 && y >= 0 && y <= 10 )
		return 0;
	else if ( x >= 5 - day && x <= 5 + day && y >= 5 - day && y <= 5 + day )
		return (germf(x - 1, y - 1, t - 1) +
		        germf(x - 1, y, t - 1) +
				germf(x - 1, y + 1, t - 1) +
				germf(x, y - 1, t - 1) +
				germf(x, y + 1, t - 1) +
				germf(x + 1, y - 1, t - 1) +
				germf(x + 1, y, t - 1) +
				germf(x + 1, y + 1, t - 1) +
				2 * germf(x, y, t - 1));
	else
		return 0;
}
int main()
{
	int i, j;
	cin >> num0 >> day;
	for ( i = 1; i <= 9; i++)
	{
		cout << germf(i, 1, day);
		for ( j = 2; j <= 9; j ++)
			cout <<" "<< germf(i,j, day);
		cout << endl;
	}
	return 0;
}
void fz( int , int[11][11]);

int main()
{
	int f ,d ;
	int pym[11][11]={0};
	cin >> f >> d;
	pym[5][5] = f;
	fz( d , pym );
	for( int i = 1 ; i <= 9 ; i++)
	{
		for( int j = 1 ; j <= 9 ; j ++)
		{
			if( j < 9)
			{
			cout<<pym[i][j]<<" ";
			}
			else
			{
				cout<<pym[i][j];
			}
		}
		cout<<endl;
	}
	return 0;
}


void fz( int day , int pym[11][11])
{
	if( day == 0)
	{
		return ;
	}
	else
	{
	int temp[11][11] = {0};
	for( int a = 1 ; a <=10 ; a++)
	{
		for( int b = 1 ; b <= 10 ; b ++)
		{
			if( pym[a][b] > 0)
			{
				temp[a][b] += 2 * pym[a][b];
				temp[a - 1][b] +=  pym[a][b];
				temp[a + 1][b] +=  pym[a][b];
				temp[a ][b - 1] +=  pym[a][b];
				temp[a ][b + 1] += pym[a][b];
				temp[a + 1][b + 1] += pym[a][b];
				temp[a + 1 ][b - 1] += pym[a][b];
				temp[a - 1 ][b + 1] += pym[a][b];
				temp[a - 1][b - 1] += pym[a][b];
		
			}
			else
			{
				continue;
			}

		}
	}
	for( int c = 1 ; c <=10 ; c++)
	{
		for( int d = 1 ; d <= 10 ; d ++)
		{
			pym[c][d] = temp[c][d];
		}
	}
	fz( day - 1, pym);
	}
}
main()
{
    int i,j,k,l,m,n,x;
    int b[11][11]={0};
    int c[11][11]={0};
    scanf("%d %d",&x,&m);
    c[5][5]=x;
    for(n=1;n<=m;n++)
    {
        	for(i=1;i<10;i++)
		{
			for(j=1;j<10;j++)
			b[i][j]=c[i][j];
		}
        for(i=5-n;i<=5+n;i++)
        {
            for(j=5-n;j<=5+n;j++)
            {
                for(k=-1;k<=1;k++)
                {
                    for(l=-1;l<=1;l++)
                    {
                        c[i][j]=c[i][j]+b[i-l][j-k];
                    }
                }
            }
        }
    }
     for(i=1;i<10;i++)
    {
        for(j=1;j<10;j++)
        {
            if(j==1)
            {printf("%d",c[i][j]);}
            else
            {printf(" %d",c[i][j]);}
        }
        printf("\n");
    }
}
int main()
{
	int m,n,day,dish[11][11],left[11][11],add[11][11],i,j,k;
	cin>>m>>day;
	for(i=0;i<11;i++)
	{
		for(j=0;j<11;j++)
		{
			dish[i][j]=0;
		}
	}
	dish[5][5]=m;
	for(n=0;n<day;n++)
	{
		for(i=1;i<10;i++)
		{
			for(j=1;j<10;j++)
			{						
				left[i][j]=2*dish[i][j];
              	add[i][j]=dish[i][j-1]+dish[i-1][j]+dish[i][j+1]+dish[i+1][j]+dish[i-1][j-1]+dish[i+1][j+1]+dish[i-1][j+1]+dish[i+1][j-1];
				
			}
		}
		for(i=1;i<10;i++)
		{
			for(j=1;j<10;j++)
			{
				dish[i][j]=left[i][j]+add[i][j];
			}
		}
	}
    for(i=1;i<10;i++)
    {
		k=0;
		for(j=1;j<10;j++)
		{	
			if(k==0)
				cout<<dish[i][j];
			if(k>0)
				cout<<" "<<dish[i][j];
			k++;
		}
		cout<<endl;
    }
	return 0;
}
int main()
{
	int a[9][9],b[9][9];
	int n,m,i,j,k;
	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;
	b[4][4]=m;
	for(k=0;k<n;k++)
	{
		for(i=0;i<9;i++)
		{
			for(j=0;j<9;j++)
			{
				
				if(b[i][j]!=0)
				{
					a[i][j]=b[i][j]+a[i][j];
					a[i-1][j]=b[i][j]+a[i-1][j];
					a[i-1][j-1]=b[i][j]+a[i-1][j-1];
					a[i][j-1]=b[i][j]+a[i][j-1];
					a[i+1][j-1]=b[i][j]+a[i+1][j-1];
					a[i+1][j]=b[i][j]+a[i+1][j];
					a[i][j+1]=b[i][j]+a[i][j+1];
					a[i+1][j+1]=b[i][j]+a[i+1][j+1];
					a[i-1][j+1]=b[i][j]+a[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++)
		{
			printf("%d",b[i][j]);
			if(j!=8)
				printf(" ");
			else
				printf("\n");
		}
	}	
	return 0;
}
/*
 * Q6.cpp
 *
 *  Created on: 2011-1-9
 *      Author: jsgl
 */



int board[9][9];

void printBoard();

int main() {
	memset(board, 0, sizeof(board));

	int m, n, i, j, k;
	cin >> m >> n;

	board[4][4] = m;
	for (i = 3; i < 6; i++)
		for (j = 3; j < 6; j++)
			board[i][j] += m;

	int temp[9][9];
	if (n >= 2) {
		memset(temp, 0, sizeof(temp));
		for (i = 3; i < 6; i++)
			for (j = 3; j < 6; j++) {
				board[i][j] *= 2;
				temp[i][j] = board[i][j];
			}
		//printBoard();
		for (i = 3; i < 6; i++)
			for (j = 3; j < 6; j++) {
				board[i - 1][j] += temp[i][j] / 2;
				board[i + 1][j] += temp[i][j] / 2;
				board[i][j + 1] += temp[i][j] / 2;
				board[i][j - 1] += temp[i][j] / 2;
				board[i - 1][j - 1] += temp[i][j] / 2;
				board[i + 1][j + 1] += temp[i][j] / 2;
				board[i - 1][j + 1] += temp[i][j] / 2;
				board[i + 1][j - 1] += temp[i][j] / 2;
			}
	}

	if (n >= 3) {
		memset(temp, 0, sizeof(temp));
		for (i = 2; i < 7; i++)
			for (j = 2; j < 7; j++) {
				board[i][j] *= 2;
				temp[i][j] = board[i][j];
			}
		for (i = 2; i < 7; i++)
			for (j = 2; j < 7; j++) {
				board[i - 1][j] += temp[i][j] / 2;
				board[i + 1][j] += temp[i][j] / 2;
				board[i][j + 1] += temp[i][j] / 2;
				board[i][j - 1] += temp[i][j] / 2;
				board[i - 1][j - 1] += temp[i][j] / 2;
				board[i + 1][j + 1] += temp[i][j] / 2;
				board[i - 1][j + 1] += temp[i][j] / 2;
				board[i + 1][j - 1] += temp[i][j] / 2;
			}
	}

	if (n >= 4) {
		memset(temp, 0, sizeof(temp));
		for (i = 1; i < 8; i++)
			for (j = 1; j < 8; j++) {
				board[i][j] *= 2;
				temp[i][j] = board[i][j];
			}
		for (i = 1; i < 8; i++)
			for (j = 1; j < 8; j++) {
				board[i - 1][j] += temp[i][j] / 2;
				board[i + 1][j] += temp[i][j] / 2;
				board[i][j + 1] += temp[i][j] / 2;
				board[i][j - 1] += temp[i][j] / 2;
				board[i - 1][j - 1] += temp[i][j] / 2;
				board[i + 1][j + 1] += temp[i][j] / 2;
				board[i - 1][j + 1] += temp[i][j] / 2;
				board[i + 1][j - 1] += temp[i][j] / 2;
			}
	}

	printBoard();
	return 0;
}

void printBoard() {
	int i, j;
	for (i = 0; i < 9; i++) {
		cout << board[i][0];
		for (j = 1; j < 9; j++)
			cout << " " << board[i][j];
		cout << endl;
	}
}
int board[11][11] = {0}, temp[11][11] = {0};

void increase(int day)
{
     if (day == 0)
     {
             return;
     }
     int i, j;
     for (i = 1; i < 10; i++)
     {
         for (j = 1; j < 10; j++)
         {
             temp[i + 1][j + 1] += board[i][j];
             temp[i + 1][j - 1] += board[i][j];
             temp[i - 1][j - 1] += board[i][j];
             temp[i - 1][j + 1] += board[i][j];
             temp[i - 1][j] += board[i][j];
             temp[i + 1][j] += board[i][j];
             temp[i][j - 1] += board[i][j];
             temp[i][j + 1] += board[i][j];
             temp[i][j] += board[i][j];
         }
     }
     memcpy(board, temp, sizeof(int)*121);
     return increase(day - 1);
}

int main()
{
    int num, day,i,j;
    cin >> num >> day;
    board[5][5] = num;
    temp[5][5] = num;
    increase(day);
    for (i = 1; i < 10; i++)
    {
         for (j = 1; j < 9; j++)
         {
             cout << temp[i][j] << " ";
         }
         cout << temp[i][j] << endl; 
     }
    return 0;
}
//????A????006
//????????????2010? ???
int main()
{int a[11][11][5];
int m,n,i,j,k,x,y,flag=0;
cin>>m>>n;
for(j=0;j<11;j++)
{
for(k=0;k<11;k++)
a[j][k][0]=0;
}
for(x=0;x<4;x++)
{for(y=0;y<11;y++)
{a[0][y][x]=0;
a[y][0][x]=0;
a[10][y][x]=0;
a[y][10][x]=0;}
}
a[5][5][0]=m;
for(i=1;i<=n;i++)
{
for(j=1;j<10;j++)
{
for(k=1;k<10;k++)
a[j][k][i]=a[j][k][i-1]*2+a[j][k-1][i-1]+a[j][k+1][i-1]+a[j+1][k][i-1]+a[j+1][k+1][i-1]+a[j+1][k-1][i-1]+a[j-1][k-1][i-1]+a[j-1][k][i-1]+a[j-1][k+1][i-1];
}}
for(j=1;j<10;j++)
{
for(k=1;k<10;k++)
{cout<<a[j][k][n];
flag=flag+1;
if(flag!=9) cout<<" ";
else if(flag==9) 
{cout<<endl;
flag=0;}
}
}
return 0;
}
main()
{
    int m,n,i,j,k;
    scanf("%d",&m);
    scanf("%d",&n);
    int a[11][11];
    int b[9][9];
    for(i=0;i<11;i++)
    {
        for(j=0;j<11;j++)
        {
            a[i][j]=0;
        }
    }
    a[5][5]=m;
    for(i=0;i<9;i++)
    {
        for(j=0;j<9;j++)
        {
            b[i][j]=0;
        }
    }
    for(i=1;i<=n;i++)
    {
        for(j=0;j<9;j++)
        {
            for(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(j=0;j<9;j++)
        {
            for(k=0;k<9;k++)
            {
                a[j+1][k+1]=b[j][k];
            }
        }
    }
        for(i=0;i<9;i++)
        {
            for(j=0;j<8;j++)
            {
                printf("%d ",b[i][j]);
            }
            printf("%d\n",b[i][8]);
        }
}
int main()
{
	int m, n,b[9][9] = {0},c[9][9] ={0},i,j,k;
	cin >> m >> n;
	b[4][4] = m;
	for (k = 1;k <=n;k++)
	{
		for (i = 0;i < 9;i++)
			for (j = 0;j <9;j++)
			{
				if (b[i][j]!=0)
				{
					c[i][j]+=2*b[i][j];
					c[i-1][j-1]+=b[i][j];
					c[i-1][j]+=b[i][j];
					c[i-1][j+1]+=b[i][j];
					c[i][j-1]+=b[i][j];
					c[i][j+1]+=b[i][j];
					c[i+1][j-1]+=b[i][j];
					c[i+1][j]+=b[i][j];
					c[i+1][j+1]+=b[i][j];
					b[i][j] += 0;
				}
			}
			for (i = 0;i <9;i++)
			    for (j = 0;j <9;j++)
				   if (c[i][j] !=0)
				   {
					   b[i][j] = c[i][j];
					   c[i][j] = 0;
				   }
	}
	for (i = 0;i <9;i++)
	{
		cout << b[i][0];
	    for (j = 1;j <9;j++)
			cout <<" " << b[i][j];
		cout << endl;
	}
	return 0;
}
int main()
{
	int m=0,n=0;
	int i=0,j=0;
	int col_num=0,row_num;
	int In[9][9]={{0}};
	int Out[9][9]={{0}};
	int Temp[9][9]={{0}};
	int around[8][2]={{1,0},{-1,0},{0,1},{0,-1},{1,1},{1,-1},{-1,1},{-1,-1}};
	scanf("%d %d",&m,&n);
	In[4][4]=m;
	for(i=0;i<n;i++)
	{
		if(i!=0)
		{
			memcpy(In,Out,81*sizeof(int));
			memset(Out,0,81*sizeof(int));
		}
		for(row_num=4-i;row_num<=4+i;row_num++)
		{
			for(col_num=4-i;col_num<=4+i;col_num++)
			{
				Out[row_num][col_num]=Out[row_num][col_num]+2*In[row_num][col_num];
				for(j=0;j<8;j++)
				{
					Out[row_num+around[j][0]][col_num+around[j][1]]=Out[row_num+around[j][0]][col_num+around[j][1]]+In[row_num][col_num];
				}
			}
		}
	}
	for(row_num=0;row_num<9;row_num++)
	{
		for(col_num=0;col_num<9;col_num++)
		{
			if(col_num!=8)
			{
				printf("%d ",Out[row_num][col_num]);
			}
			else
			{
				printf("%d\n",Out[row_num][col_num]);
			}
		}
	}
}
int main()
{
	//???????
	int m, n, i,j, k, l;
	int sqare[2][11][11]={0};//[2]??????????????????????,[9][9]???[2][2]?????
	cin>>m>>n;
	for(j=0; j<2; j++)
	for(k=1; k<=9; k++)
	for(l=1; l<=9; l++)
	{
		sqare[j][k][l]=0;
	}
	sqare[0][5][5]=m;
	for(i=0; i<n; i++)//??
	{
		//??????????
		for(k=1; k<=9; k++)
		for(l=1; l<=9; l++)
		{
			sqare[1][k][l]+=2*sqare[0][k][l];
			sqare[1][k-1][l]+=sqare[0][k][l];
			sqare[1][k+1][l]+=sqare[0][k][l];
			sqare[1][k][l+1]+=sqare[0][k][l];
			sqare[1][k][l-1]+=sqare[0][k][l];
			sqare[1][k-1][l-1]+=sqare[0][k][l];
			sqare[1][k-1][l+1]+=sqare[0][k][l];
			sqare[1][k+1][l-1]+=sqare[0][k][l];
			sqare[1][k+1][l+1]+=sqare[0][k][l];
		}
		//?????????
		for(k=1; k<=9; k++)
		for(l=1; l<=9; l++)
		{
			sqare[0][k][l]=sqare[1][k][l];
		}

		//?0
		for(k=1; k<=9; k++)
		for(l=1; l<=9; l++)
		{
			sqare[1][k][l]=0;
		}
	}
	//??
	for(k=1; k<=9; k++)
	{
		for(l=1; l<=9; l++)
		{
			if(l==1)
				cout<<sqare[0][k][l];
			else
				cout<<" "<<sqare[0][k][l];
		}
		cout<<endl;
	}
	return 0;
}
int main()
{
	int i,j,k,n,m,a[11][11],b[11][11];
	memset(a,0,sizeof(a));memset(b,0,sizeof(b));
	cin >> m >> n;
	a[5][5]=m;
	for(k=1;k<=n;k++)
	{
		for(i=1;i<=9;i++)
		{
			for(j=1;j<=9;j++)
				b[i][j]=a[i][j];
		}
		memset(a,0,sizeof(a));
		for(i=1;i<=9;i++)
		{
			for(j=1;j<=9;j++)
			{
				if(b[i][j]!=0)
				{
					a[i][j]+=2*b[i][j];
					a[i-1][j]+=b[i][j];
					a[i+1][j]+=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-1]+=b[i][j];
					a[i+1][j+1]+=b[i][j];
					a[i+1][j-1]+=b[i][j];
				}
			}

		}
	}
	for(i=1;i<=9;i++)
	{
		cout <<a[i][1];
		for(j=2;j<=9;j++)
		{
			cout << " " << a[i][j];
			if(j==9)
				cout << endl;
		}
	}
	return 0;
}
int main (){
	int m,n;
	int a[11][11]={0};
	int b[11][11]={0};
	int day,i,j;
	
	scanf("%d%d",&m,&n);
	a[5][5]=m;
	
	for(day=0;day<n;day++){
		for(i=1;i<10;i++){
			for(j=1;j<10;j++){
				if(a[i][j]!=0){
					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(i=1;i<10;i++){
			for(j=1;j<10;j++){
				a[i][j]+=b[i][j];
				b[i][j]=0;
			}
		}
		

	}
	for(i=1;i<10;i++){
		for(j=1;j<10;j++){
			if(j!=9){
				printf("%d ",a[i][j]);
			}
			if(j==9){
				printf("%d\n",a[i][j]);
			}
		}
	}
	return 0;
}
int main() 
{
 	int a[10][10] = {0}, b[10][10] = {0}, n, m;
 	int t[8][2] = {0, 1, 0, -1, 1, -1, 1, 1, 1, 0, -1, -1, -1, 0, -1, 1};
	cin >> m >> n;
 	a[5][5] = m;
	while (n--)
	{
		memset(b, 0, sizeof(b));
		for (int i = 1; i <= 9; i++)
		for (int j = 1; j <= 9; j++)
		{
			
			if (a[i][j] != 0)
			{
				for (int k = 0; k <= 7; k++)
				{
					b[i+t[k][0]][j+t[k][1]] += a[i][j];
				}
				b[i][j] += a[i][j] * 2;
			}
		}
		for (int i = 1; i <= 9; i++)
		for (int j = 1; j <= 9; j++)
		{
			a[i][j] = b[i][j];
		}
	}
	for (int i = 1;i <= 9; i++)
	{
		cout << a[i][1];
		for (int j = 2; j<= 9; j++) cout << " " << a[i][j];
		cout << endl;
	}
 	return 0;
}
main()
{
      int **squre1;
      int **squre2;
      squre1=(int**)calloc(len,sizeof(int*));
      squre2=(int**)calloc(len,sizeof(int*));
      for(int i=0;i<9;i++)
      {
              squre1[i]=(int*)calloc(len,sizeof(int));
              squre2[i]=(int*)calloc(len,sizeof(int));
      }
      int day;
      scanf("%d%d",&squre1[4][4],&day);
      for(int n=0;n<day;n++)
      {
              for(int i=4-n;i<=4+n;i++)
              for(int j=4-n;j<=4+n;j++)
              for(int x=i-1;x<=i+1;x++)
              for(int y=j-1;y<=j+1;y++)
              if(n%2==0)
              squre2[x][y]=0;
              else
              squre1[x][y]=0;
              
              for(int i=4-n;i<=4+n;i++)
              for(int j=4-n;j<=4+n;j++)
              for(int x=i-1;x<=i+1;x++)
              for(int y=j-1;y<=j+1;y++)
              {
                      if(x==i&&y==j)
                      {if(n%2==0)
                      squre2[x][y]+=2*squre1[i][j];
                       else
                        squre1[x][y]+=2*squre2[i][j];
                        }
                        else
                        if(n%2==0)
                        squre2[x][y]+=squre1[i][j];
                        else
                        squre1[x][y]+=squre2[i][j];
                        }

      }        
       
      if(day%2==0)
      for(int i=0;i<len;i++)
      {
              int count=0;
              for(int j=0;j<len;j++)
              {
                      if(count==0)
                      {printf("%d",squre1[i][j]);
                      count=1;}
                      else
                      printf(" %d",squre1[i][j]);
              }
              printf("\n");
      }
      else
      for(int i=0;i<len;i++)
      {
              int count=0;
              for(int j=0;j<len;j++)
              {
                      if(count==0)
                      {printf("%d",squre2[i][j]);
                      count=1;}
                      else
                      printf(" %d",squre2[i][j]);
              }
              printf("\n");
      }
     
      
    
}
/*
 * 1.cpp
 *
 *  Created on: 2012-12-25
 *      Author: Administrator
 */
int main()
{
	int a[10][10] = {0}, b[10][10] = {0};
	int i, j, m, n, p = 0, k;
	cin >> m >> n;
	a[5][5] = m;
	for(k = 0; k < n; k++)
	{
		for(i = 1; i <= 9; i++)
			for(j = 1; j <= 9; j++)
			{
				if(a[i][j] != 0)
				{
					p = a[i][j];
					b[i][j] = b[i][j] + 2 * p;
					b[i - 1][j] = b[i - 1][j] + p;
					b[i + 1][j] = b[i + 1][j] + p;
					b[i - 1][j + 1] = b[i - 1][j + 1] + p;
					b[i - 1][j - 1] = b[i - 1][j - 1] + p;
					b[i][j + 1] = b[i][j + 1] + p;
					b[i][j - 1] = b[i][j - 1] + p;
					b[i + 1][j + 1] = b[i + 1][j + 1] + p;
					b[i + 1][j - 1] = b[i + 1][j - 1] + p;
				}
			}
		for(i = 1; i <= 9; i++)
			for(j = 1; j <= 9; j++)
			{
				a[i][j] = b[i][j];
				b[i][j] = 0;
			}
	}
	for (i = 1; i <= 9; i++)
	{
		for(j = 1; j <= 9; j++)
		{
			cout << a[i][j];
			if(j != 9)
				cout << ' ';
		}
		cout << endl;
	}
	return 0;
}
int main(){
     int A[5][12][12],i,j,k,m,n;
     for(i=0;i<5;i++)
    {
        for(j=0;j<11;j++)
           {
              for(k=0;k<11;k++)
               {
                    A[i][j][k]=0;
                }
            }
      }
    scanf("%d%d",&n,&m);
    A[0][6][6]=n;
    for(i=0;i<m;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+1][j+1][k]+=A[i][j][k];
                        A[i+1][j-1][k]+=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+1]+=A[i][j][k];
                        A[i+1][j+1][k-1]+=A[i][j][k];
                        A[i+1][j-1][k-1]+=A[i][j][k];
                                           
               }
           }
     }
       for(i=2;i<11;i++)
     {
            for(j=2;j<10;j++)
           {
               printf("%d ",A[m][i][j]);
           }
           printf("%d",A[m][i][10]);
           printf("\n");
     }
     return 0;
}
int a[9][9], b[9][9];
int start, days;

void initial(){//make a and b all 0
	int i, j;
	for(i= 0; i< 9; i++){
		for(j= 0; j< 9; j++){
			a[i][j]= 0;
			b[i][j]= 0;
		}
	}
}


void input(){//set the start germ number
	cin>>start>>days;
	a[4][4]= start;
}
void output(){//print a
	int i= 0, j= 0;
	for(i= 0; i< 9; i++){
		for(j= 0; j< 9; j++){
			if(j== 0)
				cout<<a[i][j];
			else
				cout<<' '<<a[i][j];
		}
		cout<<endl;
	}
}
void grow(int day){//germs grow one day
	if(day> days)
		return;
	int i= 0, j= 0;
	for(i= 0; i< 9; i++){
		for(j= 0; j< 9; j++){
			if(a[i][j]> 0){
				b[i][j]+= a[i][j];
				if((i- 1)>= 0 && (i- 1)<= 9)		b[i- 1][j]+= a[i][j];
				if((i+ 1)>= 0 && (i+ 1)<= 9)		b[i+ 1][j]+= a[i][j];
				if((j- 1)>= 0 && (j- 1)<= 9)		b[i][j- 1]+= a[i][j];
				if((j+ 1)>= 0 && (j+ 1)<= 9)		b[i][j+ 1]+= a[i][j];

				if((i- 1)>= 0 && (i- 1)<= 9 && (j- 1)>= 0 && (j- 1)<= 9)		b[i- 1][j- 1]+= a[i][j];
				if((i- 1)>= 0 && (i- 1)<= 9 && (j+ 1)>= 0 && (j+ 1)<= 9)		b[i- 1][j+ 1]+= a[i][j];
				if((i+ 1)>= 0 && (i+ 1)<= 9 && (j+ 1)>= 0 && (j+ 1)<= 9)		b[i+ 1][j+ 1]+= a[i][j];
				if((i+ 1)>= 0 && (i+ 1)<= 9 && (j- 1)>= 0 && (j- 1)<= 9)		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];
			b[i][j]= 0;
		}
	}
	grow(day+ 1);
}
int main(){
	initial();
	input();
	grow(1);
	output();
	return 0;
}