semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int area[11][11]={0};
void grow(int day)
{
	int temp[11][11]={0};
	for(int i=1;i<10;i++)
	{
		for(int j=1;j<10;j++)
		{	
			temp[i-1][j]+=area[i][j]*1;
			temp[i+1][j]+=area[i][j]*1;
			temp[i][j-1]+=area[i][j]*1;
			temp[i][j+1]+=area[i][j]*1;
			temp[i+1][j+1]+=area[i][j]*1;
			temp[i-1][j+1]+=area[i][j]*1;
			temp[i+1][j-1]+=area[i][j]*1;
			temp[i-1][j-1]+=area[i][j]*1;
			temp[i][j]+=area[i][j]*2;
		}
	}
	for(int i=1;i<10;i++)
	{
		for(int j=1;j<10;j++)
		{
			area[i][j]=temp[i][j];
		}
	}
	day-=1;
	if(day>0)
	{
		grow(day);
	}
}
void print()
{
	for(int i=1;i<10;i++)
	{
		for(int j=1;j<9;j++)
		{
			cout<<area[i][j]<<" ";
		}
		cout<<area[i][9]<<endl;
	}
}
int main()
{
	int start=0,day=0;
	cin>>start>>day;
	area[5][5]=start;
	grow(day);
	print();
	return 0;
}
int main()
{
	int a[11][11],b[11][11],i,j,n,d,days,k,l;
	for (i=0;i<=10;i++)
	{
		for (j=0;j<=10;j++)
		{
			a[i][j]=0;
			b[i][j]=0;
		}
	}
	cin>>n>>days;
	a[5][5]=n;
	for (d=1;d<=days;d++)
	{
		for (k=0;k<=10;k++)
			for (l=0;l<=10;l++)
				b[k][l]=0;
		for (i=1;i<=9;i++)
		{
			for (j=1;j<=9;j++)
			{
				if (a[i][j]!=0)
				{
					b[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]+a[i][j]*2;
				}
				else
				{
					if (a[i][j]==0&&((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])!=0))
						b[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 (k=1;k<=9;k++)
			for (l=1;l<=9;l++)
				a[k][l]=b[k][l];
	}
	for (i=1;i<=9;i++)
	{
		for (j=1;j<=8;j++)
		{
			cout<<a[i][j]<<" ";
		}
		cout<<a[i][9];
		cout<<endl;
	}
	return 0;
}
int main()
{
	int num[9][9]={0};
	int t;cin>>num[4][4]>>t;
	for(int i=0;i<t;i++)
	{
		int beifen[9][9]={0};
		for(int j=0;j<9;j++)
		{
			for(int k=0;k<9;k++)
			{
				if(num[j][k]!=0)
				{
					beifen[j][k]+=num[j][k]*2;
					beifen[j][k+1]+=num[j][k];
					beifen[j][k-1]+=num[j][k];
					beifen[j+1][k+1]+=num[j][k];
					beifen[j-1][k+1]+=num[j][k];
					beifen[j-1][k-1]+=num[j][k];
					beifen[j+1][k-1]+=num[j][k];
					beifen[j+1][k]+=num[j][k];
					beifen[j-1][k]+=num[j][k];
				}
			}
		}
		for(int j=0;j<9;j++)
		{
			for(int k=0;k<9;k++)
				num[j][k]=beifen[j][k];
		}
	}
	for(int i=0;i<9;i++)
	{
		for(int j=0;j<8;j++)
		{
			cout<<num[i][j]<<' ';
		}
		cout<<num[i][8]<<endl;
	}
	
	return 0;
}
//????
int bac[5][11][11];

void boom (int m,int n)
{
	int i,j,d1,d2;
	if (n == 0)
		bac[n][5][5] = m;
	else 
		boom (m , n - 1);
	if (n > 0)
		for (i = 1; i <= 9; i++)
			for (j = 1; j <= 9; j++)
			{
				bac[n][i][j] = bac[n - 1][i][j];
				for (d1 = -1; d1 <= 1; d1++)
					for (d2 = -1; d2 <= 1; d2++)
						bac[n][i][j] += bac[n - 1][i + d1][j + d2];
			}
}

int main()
{
	int m,n,i,j,day;
	cin >> m >> n;
	for (i = 0; i <= 10; i++)
		for (j = 0;j <= 10; j++)
			for (day = 0; day <= 4; day++)
				bac[day][i][j] = 0;
	boom (m,n);
	for (i = 1; i <= 9; i++)
	{
		for (j = 1; j <= 8; j++)  
			cout << bac[n][i][j] << ' ';
		cout << bac[n][i][9] << endl;
	}
	cin >> i;
	return 0;
}
int	m, n;

int	board[2][9][9] = {0};

void	fanzhi(int k)
{
	if(k == n)
	{
		return;
	}

	int	s = k % 2;
	int	i, j;
	for (i = 0; i < 9; i ++)
	{
		for (j = 0; j < 9; j ++)
		{

			board[1 - s][i - 1][j] += board[s][i][j];
			board[1 - s][i + 1][j] += board[s][i][j];
			board[1 - s][i][j - 1] += board[s][i][j];
			board[1 - s][i][j + 1] += board[s][i][j];
			board[1 - s][i + 1][j + 1] += board[s][i][j];
			board[1 - s][i - 1][j + 1] += board[s][i][j];
			board[1 - s][i + 1][j - 1] += board[s][i][j];
			board[1 - s][i - 1][j - 1] += board[s][i][j];
			board[1 - s][i][j] += board[s][i][j] * 2;

			board[s][i][j] = 0;
		}
	}

	fanzhi(k + 1);
	return;
}
int main()
{
	cin >> m;
	cin >> n;
	board[0][4][4] = m;


	fanzhi(0);


	int	i, j;
	int	p = n % 2;
	for (i = 0; i < 9; i ++)
	{
		int	shou = 0;
		for (j = 0; j < 9; j ++)
		{
			if(shou != 0)
			{
				cout << " ";
			}
			shou = 1;

			cout << board[p][i][j];
		}
		cout << endl;
	}

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

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

void born(int x, int n)
{
	if(x < n)
	{
		int i, j, k, l;
		int a[9][9] = {0};
		for(i = 4 - x; i <= 4 + x; i++)
			for(j = 4 - x; j <= 4 + x; j++)
			{
				if(bac[i][j] != 0)
				{
					a[i][j] += bac[i][j];
					for(k = i - 1; k <= i + 1; k++)
						for(l = j - 1; l <= j + 1; l++)
						{
							a[k][l] += bac[i][j];
						}
				}
			}
		for(i = 0; i < 9; i++)
			for(j = 0; j < 9; j++)
			{
				bac[i][j] = a[i][j];
			}
		born(x+1, n);
	}
}

int main()
{
	int m, n;
	cin >> m >> n;
	bac[4][4] = m;
	born(0, n);
	for(int i = 0; i < 9; i++)
		for(int j = 0; j < 9; j++)
		{
			cout << bac[i][j];
			if(j != 8)
				cout << " ";
			else
				cout << endl;
		}
	return 0;
}
int x[9][9];
int num(int i, int j, int k)
{
	if (k == 1)
		return x[i][j];
	else
	{
		int t = num(i, j, k - 1);
		int d[3] = {-1, 0, 1}, l[3] = {-1, 0, 1};
		for (int p = 0; p < 3; p ++)
			for (int q = 0; q < 3; q ++)
				if ((i + d[p]) >= 0 && (i + d[p] <= 8) && (j + l[q] >= 0) && (j + l[q] <= 8))
					t = t + num(i + d[p], j + l[q], k - 1);
 		return t;
	}
}
int main()
{
	int i, j, m, n;
	for (i = 0; i < 9; i ++)
		for (j = 0; j < 9; j ++)
			x[i][j] = 0;
	cin >> m;
	x[4][4] = m;
	cin >> n;
	for (i = 0; i < 9; i ++)
	{
		for (j = 0; j < 8; j ++)
			cout << num(i, j, n + 1) << " ";
		cout << num(i, 8, n + 1) << endl;
	}
	return 0;
}
//*****************************************
//* ?????(11.8) ???????? **
//* ?????? 1300012741 **
//* ???2013.10.16 **
//*****************************************


void	bacteria( int, int[9][9] );

int main()
{
	int numBacteria, numDay;
	int container[9][9] = { 0 };
	int i, j;

	cin >> numBacteria >> numDay;
	container[4][4] = numBacteria;

	bacteria( numDay, container );

	for ( i = 0; i < 9; i++ )
	{
		for ( j = 0; j < 9; j++ )
		{
			cout << container[i][j];
			if ( j != 8 )
				cout << " ";
		}
		cout << endl;
	}

	return 0;
}

void bacteria( int numDay, int container[9][9] )
{
	int i, j;
	int tempContainer[9][9] = { 0 };

	if ( !numDay )
		return;
	else
		bacteria( numDay - 1, container );

	for ( i = 0; i < 9; i++ )
		for ( j = 0; j < 9; j++ )
			if ( container[i][j] )
			{
				tempContainer[i - 1][j] += container[i][j];
				tempContainer[i + 1][j] += container[i][j];
				tempContainer[i][j - 1] += container[i][j];
				tempContainer[i][j + 1] += container[i][j];
				tempContainer[i - 1][j - 1] += container[i][j];
				tempContainer[i - 1][j + 1] += container[i][j];
				tempContainer[i + 1][j - 1] += container[i][j];
				tempContainer[i + 1][j + 1] += container[i][j];
				tempContainer[i][j] += 2 * container[i][j];
			}
	for ( i = 0; i < 9; i++ )
		for ( j = 0; j < 9; j++ )
			if ( tempContainer[i][j] )
				container[i][j] = tempContainer[i][j];

	return;
}
int main()
{
    int a[9][9]={0},b[9][9]={0};
    int i,j,k,m,n,fx,fy;
    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++)
            b[i][j]=0;
        for(i=1;i<8;i++)
        {
            for(j=1;j<8;j++)
            {
                b[i][j]=b[i][j]+a[i][j];
                for(fx=-1;fx<=1;fx++)
                {
                    for(fy=-1;fy<=1;fy++)
                    {
                        b[i+fx][j+fy]=b[i+fx][j+fy]+a[i][j];
                    }
                }
            }
        }
        for(i=0;i<9;i++)
            for(j=0;j<9;j++)
                a[i][j]=b[i][j];
    }
    for(i=0;i<9;i++)
    {
        printf("%d",a[i][0]);
        for(j=1;j<9;j++)
            printf(" %d",a[i][j]);
        printf("\n");
    }
}
int main()
{
    int a[5][11][11]={0},m,n,i,j,k,p,q;
    scanf("%d%d", &m, &n);
    a[0][5][5]=m;
    for(k=1;k<=n;k++) for(i=1;i<=9;i++) for(j=1;j<=9;j++)
    {for(p=i-1;p<=i+1;p++) for(q=j-1;q<=j+1;q++) a[k][i][j]+=a[k-1][p][q]; a[k][i][j]+=a[k-1][i][j];}
    for(i=1;i<=9;i++)
    {
                     for(j=1;j<=8;j++) printf("%d ", a[n][i][j]);
                     printf("%d\n", a[n][i][9]);
    }                                          
    return 0;
}
//*************************
//*??:???????? **
//*??:??? 1300013007**
//*??:2013.12.6        **
//*************************


int bacteria[11][11] = {0}, flag[11][11] = {0}, add[11][11] = {0};

void reproduce(int x, int y)
{
	if(x > 1)  add[x-1][y] += (bacteria[x][y] / 2);
	if(x < 9)  add[x+1][y] += (bacteria[x][y] / 2);
	if(y > 1)  add[x][y-1] += (bacteria[x][y] / 2);
	if(y < 9)  add[x][y+1] += (bacteria[x][y] / 2);
	if(x > 1 && y > 1)	add[x-1][y-1] += (bacteria[x][y] / 2);
	if(x < 9 && y < 9)  add[x+1][y+1] += (bacteria[x][y] / 2);
	if(x > 1 && y < 9)	add[x-1][y+1] += (bacteria[x][y] / 2);
	if(x < 9 && y > 1)	add[x+1][y-1] += (bacteria[x][y] / 2);
}

int main()
{
	int m, n;
	int i, j, k;
	cin >> m >> n;     //m???????????,n???????
	bacteria[5][5] = m;
	for(i = 1; i <= n; i++)
	{
		for(j = 1; j <= 9; j++)
			for(k = 1; k <= 9; k++)
				if(bacteria[j][k] != 0)
				{
					flag[j][k] = 1;
					bacteria[j][k] *= 2;
				}
		for(j = 1; j <= 9; j++)
			for(k = 1; k <= 9; k++)
				if(flag[j][k] != 0)
				{
					flag[j][k] = 0;
					reproduce(j, k);
				}
		for(j = 1; j <= 9; j++)
			for(k = 1; k <= 9; k++)
			{
				bacteria[j][k] += add[j][k];
				add[j][k] = 0;
			}	
	}
	for(j = 1; j <= 9; j++)
		for(k = 1; k <= 9; k++)
		{
			if(k == 1)
				cout << bacteria[j][k];
			else
			{
				cout << ' ' <<  bacteria[j][k];
				if(k == 9)
					cout << endl;
			}
		}
	return 0;
}
int main()
{
    int s[9][9],s1[9][9],i=0,j=0,m=0,n=0,k=0;
    for(i=0;i<=8;i++)//??? 
    {
        for(j=0;j<=8;j++)
        {
           s[i][j]=0; 
           s1[i][j]=0;               
        }                 
    }
    cin>>m>>n;
    s[4][4]=m;
    for(k=1;k<=n;k++)//?? 
    {
             for(i=1;i<=7;i++)     //?? 
             {
                    for(j=1;j<=7;j++)
                    {
                       if(s[i][j]!=0)
                       {
                           s1[i][j]+=2*s[i][j];
                           s1[i+1][j]+=s[i][j];
                           s1[i-1][j]+=s[i][j];
                           s1[i][j+1]+=s[i][j];
                           s1[i][j-1]+=s[i][j];
                           s1[i+1][j+1]+=s[i][j];
                           s1[i-1][j-1]+=s[i][j];
                           s1[i+1][j-1]+=s[i][j];
                           s1[i-1][j+1]+=s[i][j];
                           
                       }                
                    }                 
             }  
             for(i=0;i<=8;i++) 
             {
                    for(j=0;j<=8;j++)
                    {
                         s[i][j]=s1[i][j];                 
                    }                   
             }  
             for(i=0;i<=8;i++) //s1?? 
             {
                    for(j=0;j<=8;j++)
                    {
                         s1[i][j]=0;                 
                    }                   
             }
                         
    }
    for(i=0;i<=8;i++)//?? 
    {
       for(j=0;j<=8;j++)
       {
          if(j==0)
          {cout<<s[i][j];continue;}
          if(j==8)
          {cout<<" "<<s[i][j]<<endl;continue; }
          cout<<" "<<s[i][j];
       }                 
    }
return 0;    
}
main()
{
      int m,n,i,j,k;
      scanf("%d %d",&m,&n);
      int a[11][11],b[11][11];
      for(i=0;i<11;i++)
      for(j=0;j<11;j++)
        a[i][j]=b[i][j]=0;
      a[5][5]=b[5][5]=m;
      for(k=0;k<n;k++)
      {
                      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]+a[i-1][j-1]+a[i+1][j+1]+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];
                                       } 
                                      
     }
     for(i=1;i<=9;i++)
     for(j=1;j<=9;j++)
     {
                      if(j==9)
                      {
                              printf("%d\n",a[i][j]);
                              }
                      else
                      {
                          printf("%d ",a[i][j]);
                          }
     }
     getchar();getchar();
}
int main(int argc, char* argv[])
{
	
	const int sz=9;
	int k,i,j,m,n,fx,fy;
	int a[sz][sz],b[sz][sz];
	scanf("%d%d",&m,&n);
	memset (a,0,sizeof (a));
	a[sz/2][sz/2]=m;
	for (k=0;k<n;k++)
	{
		memset(b,0,sizeof (b));
	for (i=1;i<sz-1;i++)
	{
		for (j=1;j<sz-1;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<sz;i++)
{
	for (j=0;j<sz-1;j++)
		printf ("%d ",a[i][j]);
	printf ("%d\n",a[i][sz-1]);
}
return 0;
}
int main()
{
	int a[15][15]={0};
	int m=0,n=0;
	cin>>m>>n;
	a[5][5]=m;
	for(int i=1;i<=n;i++)
	{
		int b[15][15]={0};
		for(int j=1;j<=9;j++)
		{
			for(int k=1;k<=9;k++)
			{
				if(a[j][k]!=0)
				{
					//int b[15][15]={0};
					for(int p=j-1;p<=j+1;p++)
					{
						for(int q=k-1;q<=k+1;q++)
						{
							b[p][q]+=a[j][k];
						}
					}
					b[j][k]+=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 i=1;i<=9;i++)
	{
		for(int k=1;k<=8;k++)
		{
			cout<<a[i][k]<<" ";
		}
		cout<<a[i][9]<<endl;
	}
	
	return 0;
}
//**********************************
//*  ????homework_20.cpp       *
//*  ??????1200012884        * 
//*  ?????2012?11?15?      *
//*  ?????????????    *
//**********************************
int a[9][9] = {0};
int b[9][9] = {0};
int x[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
int y[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

int main()
{
	int p, q, i;
	int m, n;
	cin >> m >> n;
	a[4][4] = m;
	for (;n > 0;n--)
	{
		for (p = 0;p < 9;p++)
			for (q = 0;q < 9;q++)
			{
				for (i = 0;i < 8;i++)
					b[p + x[i]][q + y[i]] += a[p][q];
				b[p][q] += a[p][q] * 2;
			}
		for (p = 0;p < 9;p++)
			for (q = 0;q < 9;q++)
			{
				a[p][q] = b[p][q];
				b[p][q] = 0;
			}
	}
	for (p = 0;p < 9;p++)
	{
		for (q = 0;q < 8;q++)
			cout << a[p][q] << " ";
		cout << a[p][8] << endl;
	}
    return 0;
}
int main()
{
	int a[100][11][11],i,j,num,days,day;
	for(day=0;day<100;day++)
		for(i=0;i<11;i++)
			for(j=0;j<11;j++)
				a[day][i][j]=0;
	cin>>num>>days;
	a[0][5][5]=num;
	for(day=0;day<days;day++)
		for(i=1;i<=9;i++)
			for(j=1;j<=9;j++)
				a[day+1][i][j]=(a[day][i-1][j-1]+a[day][i-1][j]+a[day][i-1][j+1]+
				                a[day][i][j-1]+a[day][i][j+1]+
								a[day][i+1][j-1]+a[day][i+1][j]+a[day][i+1][j+1])+
								2*a[day][i][j];
	for(i=1;i<=9;i++)
			for(j=1;j<=9;j++)
			{
				if(j==9)
					cout<<a[days][i][j]<<endl;
				else
					cout<<a[days][i][j]<<' ';
			}
	return 0;
}
int main()
{
    int a[11][11],n,i,j,x,b[11][11];
    for(i=0;i<=10;i++)
        for(j=0;j<=10;j++)
            a[i][j]=0;
    for(i=0;i<=10;i++)
        for(j=0;j<=10;j++)
            b[i][j]=0;
    scanf("%d",&a[5][5]);
    scanf("%d",&n);
    for(x=1;x<=n;x++)
    {    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(i=1;i<=9;i++)
             for(j=1;j<=9;j++)
                 a[i][j]=b[i][j];
    }
    for(i=1;i<=9;i++)
    {
                     printf("%d",b[i][1]);
                     for(j=2;j<=9;j++)
                         printf(" %d",b[i][j]);
                     printf("\n");
    }
    return 0;
}
int cell[15][15] = {0};

void change()
{
	int cell2[15][15] = {0};
	for(int i = 1; i <= 9; i++)
		for(int j = 1; j<= 9; j++)
		{
			if(cell[i][j] != 0)
			{
				int k = cell[i][j] * 2;
				cell2[i][j] += k;
				cell2[i - 1][j] += cell[i][j];
				cell2[i + 1][j] += cell[i][j];
				cell2[i][j + 1] += cell[i][j];
				cell2[i][j - 1] += cell[i][j];
				cell2[i - 1][j - 1] += cell[i][j];
				cell2[i + 1][j - 1] += cell[i][j];
				cell2[i - 1][j + 1] += cell[i][j];
				cell2[i + 1][j + 1] += cell[i][j];
			}
		}
	for(int i = 1; i <= 9; i++)
		for(int j = 1; j <= 9; j++)
			cell[i][j] = cell2[i][j];
}
int main() {
	
	int m = 0, n = 0;
	cin >> m >> n;
	cell[5][5] = m;
	for(int i = 0; i < n; i++)
	    change();
	for(int i = 1; i <= 9; i++){
		for(int j = 1; j < 9; j++) 
			cout << cell[i][j] << ' ';
		cout << cell[i][9] << endl;
		
	}

	return 0;
}
main()
{
     int m,n,i,j,t;
     scanf("%d %d",&m,&n);
     int a[9][9];
     
     int b[9][9];
     for(i=0;i<9;i++)
        for(j=0;j<9;j++)
     
           {a[i][j]=0;b[i][j]=0;}
           
           a[4][4]=m;b[4][4]=m;
     for(t=0;t<n;t++)
     {
     for(i=0;i<9;i++)
        for(j=0;j<9;j++)
        a[i][j]=0;
      for(i=0;i<9;i++)
        for(j=0;j<9;j++)
          {
                        if(b[i][j]!=0)
                          { a[i][j]=a[i][j]+2*b[i][j];
                            a[i+1][j]=a[i+1][j]+b[i][j];
                            a[i-1][j]=a[i-1][j]+b[i][j];
                            a[i+1][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][j+1]=a[i][j+1]+b[i][j];
                            a[i-1][j-1]=a[i-1][j-1]+b[i][j];
                            a[i][j-1]=a[i][j-1]+b[i][j];
                            a[i+1][j-1]=a[i+1][j-1]+b[i][j];
                          }
          }
       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==8)
         { printf("%d",a[i][j]); 
         printf("\n"); 
         }
         else
        printf("%d ",a[i][j]);
          
         }  

      }
int main()
{
	int m,n,a[11][11][6]={0},i,j,k;
	cin>>m>>n;
	a[5][5][1]=m;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<10;j++)
		{
			for(k=1;k<10;k++)
			{
				a[j][k][i+1]=2*a[j][k][i]+a[j-1][k-1][i]+a[j-1][k][i]+a[j-1][k+1][i]+a[j][k-1][i]+a[j][k+1][i]+a[j+1][k-1][i]+a[j+1][k][i]+a[j+1][k+1][i];
			}
		}
	}
	for(j=1;j<10;j++)
	{
		for(k=1;k<9;k++)
		{
			cout<<a[j][k][n+1]<<" ";
		}
		cout<<a[j][9][n+1]<<endl;
	}
	return 0;
}
int main()
{
	int m,n;
	scanf("%d %d",&m,&n);
	int a[9][9]={0},b[9][9]={0};
	a[4][4]=m;
	int i,j,k,fx,fy;
	for(i=0;i<n;i++)
	{
		memset(b,0,sizeof(b));
		for(j=1;j<8;j++)
		{
			for(k=1;k<8;k++)
			{
				b[j][k]+=a[j][k];
			
				for(fx=-1;fx<=1;fx++)
					for(fy=-1;fy<=1;fy++)
						b[j+fx][k+fy]+=a[j][k];
			}
		}
		memcpy(a,b,sizeof(a));
	}
	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[11][11]={0},b[11][11]={0},m,n,x,i,r;
    scanf("%d%d",&m,&n);
    a[5][5]=m;
    b[5][5]=m;
    for(x=0;x<n;x++){ 
    for(i=1;i<10;i++){
                     for(r=1;r<10;r++){
                                      a[i][r]=2*b[i][r]+b[i-1][r-1]+b[i-1][r]+b[i-1][r+1]+b[i][r-1]+b[i][r+1]+b[i+1][r-1]+b[i+1][r]+b[i+1][r+1]; 
                                      }
                     }
    for(i=1;i<10;i++){
                      for(r=1;r<10;r++){
                                        b[i][r]=a[i][r];
                                        }
                      }
                      }
    for(i=1;i<10;i++){
                      for(r=1;r<9;r++){
                                        printf("%d ",a[i][r]);
                                        }
                      printf("%d\n",a[i][r]);
                                        }    
    return 0;
}
main()
{
      int real[9][9]={0};
      int virtl[9][9]={0};
      int m,n,i,j,k;
      scanf("%d%d",&m,&n);
      for(i=3;i<6;i++)
          for(j=3;j<6;j++)
              real[i][j]=m;
      real[4][4]=2*m;
      
      for(k=3;k>4-n;k--)
      {
        
                 for(i=0;i<9;i++)
              {
                  for(j=0;j<8;j++)
                  {
                  virtl[i][j]=real[i][j];
                  real[i][j]=0;
                  }
              }
        
         for(i=k;i<9-k;i++)
         {
             for(j=k;j<9-k;j++)
             {
                 real[i][j]=real[i][j]+2*virtl[i][j];
                 real[i-1][j-1]+=virtl[i][j];
                 real[i-1][j]+=virtl[i][j];
                 real[i-1][j+1]+=virtl[i][j];
                 real[i][j-1]+=virtl[i][j];
                 real[i][j+1]+=virtl[i][j];
                 real[i+1][j-1]+=virtl[i][j];
                 real[i+1][j]+=virtl[i][j];
                 real[i+1][j+1]+=virtl[i][j];
             }
         }
      }
      
      
      
      
      
      
      
      
      for(i=0;i<9;i++)
      {
          for(j=0;j<8;j++)
              printf("%d ",real[i][j]);
          printf("%d\n",real[i][8]);
      }

}