semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
	int n,m,i,j,k,l,p,q,a[9][9],b[9][9],d;
	scanf("%d %d",&n,&d);
	for(i=0;i<9;i++)
	{
		for(j=0;j<9;j++)
		{
			a[i][j]=0;
			b[i][j]=0;
		}
	}
	a[4][4]=n;
	for( ;d>0;d--)
	{
		for(i=0;i<9;i++)
		{
			for(j=0;j<9;j++)
			{
				if(a[i][j]!=0)
				{
					b[i][j]+=a[i][j];
					for(p=i-1;p<=i+1;p++)
					{
						for(q=j-1;q<=j+1;q++)
						{
							b[p][q]+=a[i][j];
						}
					}
					a[i][j]=0;
				}
			}
		}
		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<9;j++)
		{
			if(j!=8)
			{
				printf("%d ",a[i][j]);
			}
			else
			{
				printf("%d\n",a[i][j]);
			}
		}
	}
	return 0;
}
void fanzhi(int a[][9], int b[][9], int n, int count);
int main()
{
	int m, n;
	int a[9][9] = {0}, b[9][9] = {0};
	cin >> m >> n;
	a[4][4] = m;
	b[4][4] = m;
	fanzhi(a, b, n, 0);
	return 0;
}
void fanzhi(int a[][9], int b[][9], int n, int count)
{
	int i, j;
	if(count == n)
	{
		for(i = 0; i < 9; i++)
			for(j = 0; j < 9; j++)
			{
				if(j == 8)
					cout << a[i][j] << endl;
				else
					cout << a[i][j] << " ";
			}
	}
	else
	{
		for(i = 0; i < 9; i++)
		{
			for(j = 0; j < 9; j++)
			{
				if(b[i][j] > 0)
				{
					a[i - 1][j] += b[i][j];
					a[i - 1][j - 1] += b[i][j];
					a[i - 1][j + 1] += b[i][j];
					a[i][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];
					a[i][j] += b[i][j];
				}
			}
		}
		for(i = 0; i < 9; i++)
			for(j = 0; j < 9; j++)
				b[i][j] = a[i][j];
		count ++;
		fanzhi(a, b, n, count);
	}
}
int b[15][15] = { 0 }, a[15][15] = { 0 }, n = 0;
void f(int t)
{
	if (t == n+1)
	{
		for (int i = 1; i <= 9; i++)
		{
			for (int k = 1; k <= 8; k++)
			{
				cout << a[i][k] << " ";
			}
			cout << a[i][9] << endl;
		}
	}
	else
	{
		memset(b, 0, sizeof(b));
		for (int j = 1; j <= 9; j++)
		{
			for (int k = 1; k <= 9; k++)
			{
				if (a[j][k] != 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];
			}
		}
		f(t + 1);
	}
}
int main()
{

	int m = 0;
	cin >> m >> n;
	a[5][5] = m;
        f( 1 );
	return 0;
}
/*????9???????????????m?????????????????????10???????10??????????????????????????????????????????n(1?n?4)????????????????
????
?????????????m????????????2?m?30???????n????????1?m?4??
????
??????????????????????????????n???????????????
????
2 1*/
int main()
{
        int a[10][10][5];
        int m;
        short int i,j,k,n,t=2;
        for(k=0;k<=4;k++)
        for(i=1;i<=9;i++)
        for(j=1;j<=9;j++) a[i][j][k]=0;
        cin>>a[5][5][0]>>n;
        m=a[5][5][0];
        a[5][5][1]=2*m;
        a[4][4][1]=a[4][6][1]=a[6][4][1]=a[6][6][1]=a[4][5][1]=a[5][4][1]=a[6][5][1]=a[5][6][1]=m;
        while(t<=n)
        {
        for(i=1;i<=9;i++)
        for(j=1;j<=9;j++)
        {
                if(a[i][j][t-1]!=0)
                {
                        a[i-1][j][t]+=a[i][j][t-1];
                        a[i][j-1][t]+=a[i][j][t-1];
                        a[i+1][j][t]+=a[i][j][t-1];
                        a[i][j+1][t]+=a[i][j][t-1];
                        a[i][j][t]+=2*a[i][j][t-1];
                        a[i-1][j+1][t]+=a[i][j][t-1];
                        a[i+1][j-1][t]+=a[i][j][t-1];
                        a[i-1][j-1][t]+=a[i][j][t-1];
                        a[i+1][j+1][t]+=a[i][j][t-1];
                }
        }
        t++;
        }
        for(i=1;i<=9;i++)
        for(j=1;j<=9;j++)
        {
                cout<<a[i][j][n];
                if(j==9) cout<<endl;
                else cout<<' ';
        }
        return 0;
}
main()
{
      int num,day,a[9][9],b[9][9],i,j,k,h,s;
      for(i=0;i<9;i++)
      for(j=0;j<9;j++)
      a[i][j]=0;
      scanf("%d%d",&num,&day);
      a[4][4]=num;
      for(i=0;i<day;i++)
      {
      for(k=0;k<2*i+3;k++)
      for(j=0;j<2*i+3;j++)
      b[3-i+k][3-i+j]=0; 
                    
      for(k=0;k<2*i+1;k++)
      for(j=0;j<2*i+1;j++)
      for(h=-1;h<2;h++)
      for(s=-1;s<2;s++)
      b[4-i+k+h][4-i+j+s]= b[4-i+k+h][4-i+j+s]+a[4-i+k][4-i+j];
      
      for(k=0;k<2*i+3;k++)
      for(j=0;j<2*i+3;j++)
      a[3-i+k][3-i+j]= b[3-i+k][3-i+j]+a[3-i+k][3-i+j];
      }
      for(i=0;i<9;i++)
      for(j=0;j<9;j++)
      {if(j==8)
      printf("%d\n",a[i][j]);
      else
      printf("%d ",a[i][j]);
      }
      
}
int main()
{
	int m,n,i,i1,i2,a[9][9],b[9][9],h,s;
	for (i1=0;i1<9;i1++)
	{
		for (i2=0;i2<9;i2++)
		{
			a[i1][i2]=0;
			b[i1][i2]=0;
		}
	}
	scanf("%d%d",&m,&n);
	a[4][4]=m;
	b[4][4]=m;
	for (i=0;i<n;i++)
	{
		for (i1=0;i1<9;i1++)
		{
			for (i2=0;i2<9;i2++)
			{
				if (a[i1][i2]!=0)
				{
					b[i1][i2]+=a[i1][i2];
					if (i1-1>=0)
					{
						if (i2-1>=0)
							b[i1-1][i2-1]+=a[i1][i2];
						b[i1-1][i2]+=a[i1][i2];
						if (i2+1<9)
							b[i1-1][i2+1]+=a[i1][i2];
					}
					if (i2-1>=0)
						b[i1][i2-1]+=a[i1][i2];
					if (i2+1<9)
						b[i1][i2+1]+=a[i1][i2];
					if (i1+1<9)
					{
						if (i2-1>=0)
							b[i1+1][i2-1]+=a[i1][i2];
						b[i1+1][i2]+=a[i1][i2];
						if (i2+1<9)
							b[i1+1][i2+1]+=a[i1][i2];
					}
				}
			}
		}
		for (h=0;h<9;h++)
		{
			for (s=0;s<9;s++)
			{
				a[h][s]=b[h][s];
			}
		}
		
	}
		for (i1=0;i1<9;i1++)
		{
		for (i2=0;i2<9;i2++)
		{
			if (i2!=8)
				printf("%d ", a[i1][i2]);
			else
				printf("%d\n", a[i1][i2]);
		}
	}
	return 0;
}
int main()
{
    int a[9][9],b[9][9],c[9][9];
    int i,j,m,n,k,p,q;
    for(i=0;i<9;i++)
    for(j=0;j<9;j++)
    {
                    a[i][j]=0;
                    b[i][j]=0;
                    c[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)
                     {
                                   b[i][j]=b[i][j]+3*a[i][j];
                                   b[i][j-1]+=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][j+1]+=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];
                    }          
                    }
    
    for(p=0;p<9;p++)
    for(q=0;q<9;q++)
    {
                    a[p][q]=b[p][q]-a[p][q];
                    b[p][q]=0;
    }
    }
    for(i=0;i<9;i++)
    for(j=0;j<9;j++)
    {
                    if(j==8)
                    printf("%d\n",a[i][j]);
                    else printf("%d ",a[i][j]);
    }
}
void germ(int a[9][9],int b[9][9],int n)
{
	int i,j;
	for(i=0;i<9;i++)
	{
		for(j=0;j<9;j++)
		{
			if(j>=1)
				b[i][j-1]+=a[i][j];
			if(i>=1&&j>=1)
				b[i-1][j-1]+=a[i][j];
			if(i>=1)
				b[i-1][j]+=a[i][j];
			if(i<=7&&j>=1)
				b[i+1][j-1]+=a[i][j];
			if(i<=7&&j<=7)
				b[i+1][j+1]+=a[i][j];
			if(i>=1&&j<=7)
				b[i-1][j+1]+=a[i][j];
			if(j<=7)
				b[i][j+1]+=a[i][j];
			if(i<=7)
				b[i+1][j]+=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];
		}
	}
	n-=1;
	if(n>0)
	{
		germ(a,b,n);
	}
	else if(n==0)
	{
		for(i=0;i<9;i++)
		{
			for(j=0;j<8;j++)
			{
				printf("%d ",b[i][j]);
			}
			printf("%d\n",b[i][j]);
		}
	}
}

main()
{
	int n,m,a[9][9]={0},b[9][9]={0};
	scanf("%d%d",&m,&n);
	a[4][4]=m;
	b[4][4]=m;
	germ(a,b,n);
}
int bottle[9][9]={0};
int totalday=0;
void mutiply(int day);
int main()
{
	cin>>bottle[4][4];
	int day;
	cin>>totalday;
	mutiply(1);
	for(int i=0;i<=8;i++)
	{   cout<<bottle[i][0];
		for(int j=1;j<=8;j++)
		{
			cout<<' '<<bottle[i][j];
		}
		cout<<endl;
	}
}
void mutiply(int day)
{
	if(day==totalday+1)
		return ;
	int board[9][9]={0};
	for(int i=1;i<=7;i++)
		for(int j=1;j<=7;j++)
		{
			board[i][j]=board[i][j]+bottle[i][j]*2;
			board[i-1][j]=board[i-1][j]+bottle[i][j];
			board[i+1][j]=board[i+1][j]+bottle[i][j];
			board[i][j-1]=board[i][j-1]+bottle[i][j];
			board[i][j+1]=board[i][j+1]+bottle[i][j];
			board[i-1][j-1]=board[i-1][j-1]+bottle[i][j];
			board[i-1][j+1]=board[i-1][j+1]+bottle[i][j];
			board[i+1][j-1]=board[i+1][j-1]+bottle[i][j];
			board[i+1][j+1]=board[i+1][j+1]+bottle[i][j];
		}
	for(int i=0;i<=8;i++)
		for(int j=0;j<=8;j++)
		{
			bottle[i][j]=board[i][j];
		}
	mutiply(day+1);
}
int a[10][10] = {0};
int b[10][10] = {0};
int i , j;
void f(int day);

int main()
{
	int m , n ;
	cin >> m >> n;
	a[5][5] = m;
	f(n);
	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]);
		}
	return 0;
}
void f(int day)
{
	int k,l;
	for(i = 1 ; i <= 9 ; i ++)
		for(j = 1 ; j <= 9 ; j++) 
			b[i][j] = a[i][j];
    if(day > 0)
	{
		for(i = 1 ; i <= 9 ; i ++)
			for(j = 1 ; j <= 9 ; j++)
				if(a[i][j] != 0)
				{
					for(k = i - 1; k <= i + 1; k ++)
						for(l = j - 1; l <= j + 1; l++)
							a[k][l] = a[k][l] + b[i][j]; 
				}
	f(day - 1);
	}
}
int vi[9][9] = {0}, cp[9][9], m, n, em[9][9] = {0};
void go_on(int day); 
int main()
{
	int i,j;  // i??????m??????????n???
	cin >> m >> n;
	vi[4][4] = m;
	memcpy(cp, vi, 9 * 9 * 4);
	go_on(n);
	for (i = 0; i < 9; i++)
	{
		for (j = 0; j < 9; j++)
		{
			if (j != 8)
			{
			cout << vi[i][j] << " ";
			}
			else
			{
				cout << vi[i][j] << endl;
			}
		}
	}
	return 0;
}

void go_on (int x)
{
	int p, q, i, j;
	if (x == 1)
	{
		for (i = -1; i <= 1; i++)
		{
			for (j = -1; j <= 1; j++)
			{
				if ((i != 0) || (j != 0))
				{
					em[4 + i][4 + j] += vi[4][4];
				}
				else
				{
					em[4 + i][4 + j] += vi[4][4] * 2;
				}
			}
		}  // ????????????em?????????
	    for (i = 0; i < 9; i++)
		{
			for (j = 0; j < 9; j++)
			{
				vi[i][j] = vi[i][j] + em[i][j] - cp[i][j];
			}
		}
		memcpy(cp,vi,9 * 9 * 4);
		for (i = 0; i <= 8; i++)
		{
			for (j = 0; j <= 8; j++)
			{
				em[i][j] = 0;
			}
		}
		return;
	}
	if (x > 1)   // ??x = 2
	{
		go_on (x - 1);
		for (p = 5 - x; p <= x + 3; p++)
		{
			for (q = 5 - x; q <= x + 3; q++)
			{
				for (i = -1;i <= 1; i++)
				{
					for (j = -1; j <= 1; j++)
					{
						if ((i != 0) || (j != 0))
						{
							em[p + i][q + j] += vi[p][q];
						}
						else
						{
							em[p + i][q + j] += vi[p][q] * 2;
						}
					}
				}
			}
		}
		for (i = 0; i < 9; i++)
		{
			for (j = 0; j < 9; j++)
			{
				vi[i][j] = vi[i][j] + em[i][j] - cp[i][j];
			}
		}
		memcpy(cp,vi, 9*9*4);
		for (i = 0; i <= 8; i++)
		{
			for (j = 0; j <= 8; j++)
			{
				em[i][j] = 0;
			}
		}
	}
}
int main()
{
int m,n,i,j;
cin>>m>>n;
int a[11][11]={0},save[11][11]={0};
a[5][5]=m;
while(n--)
{
for(i=1;i<=9;i++)
for(j=1;j<=9;j++)
if(a[i][j]!=0)
{
save[i-1][j]+=a[i][j];
save[i+1][j]+=a[i][j];
save[i][j-1]+=a[i][j];
save[i][j+1]+=a[i][j];
save[i-1][j-1]+=a[i][j];
save[i-1][j+1]+=a[i][j];
save[i+1][j-1]+=a[i][j];
save[i+1][j+1]+=a[i][j];
a[i][j]*=2;
}
for(i=1;i<=9;i++)
for(j=1;j<=9;j++)
if(save[i][j]!=0)
{a[i][j]+=save[i][j];
save[i][j]=0;}
}
for(i=1;i<=9;i++)
{
for(j=1;j<=8;j++)
cout<<a[i][j]<<' ';
cout<<a[i][9]<<endl;
}
return 0;
}
int main()
{
	int arr[9][9]={{0}},m,n;
	cin>>m>>n;
        arr[4][4]=m;
	for(;n>0;n--)
	{
		int temp[9][9]={{0}};
		for(int i=0;i<9;i++)
			for(int j=0;j<9;j++)
			{
				if(arr[i][j]>0)
				{
					temp[i][j]+=2*arr[i][j];
					temp[i-1][j-1]+=arr[i][j];
					temp[i-1][j]+=arr[i][j];
					temp[i-1][j+1]+=arr[i][j];
					temp[i][j-1]+=arr[i][j];
					temp[i][j+1]+=arr[i][j];
					temp[i+1][j]+=arr[i][j];
					temp[i+1][j-1]+=arr[i][j];
					temp[i+1][j+1]+=arr[i][j];
				}
			}
		for(int i=0;i<9;i++)
			for(int j=0;j<9;j++)
				arr[i][j]=temp[i][j];
	}
	for(int i=0;i<9;i++)
	{
		for(int j=0;j<8;j++)
			cout<<arr[i][j]<<' ';
		cout<<arr[i][8]<<endl;
	}
	return 0;
}
int main(int argc, char* argv[])
{
	int m,day,i,j,k;
	int a[9][9],b[9][9];
	for(i=0;i<9;i++)
		for(j=0;j<9;j++)
		{a[i][j]=0;
		 b[i][j]=0;
		}
	scanf("%d%d",&m,&day);
	a[4][4]=m;
	b[4][4]=m;
	for(k=0;k<day;k++)
	   {for(i=0;i<9;i++)
		  {for(j=0;j<9;j++)
		     if(a[i][j]!=0)
			 {b[i][j]+=a[i][j];
		     b[i][j-1]+=a[i][j];
		     b[i][j+1]+=a[i][j];
		     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];
			 }
			}
	   for(i=0;i<9;i++)
		   for(j=0;j<9;j++)
			   a[i][j]=b[i][j];
	}
	for(i=0;i<9;i++)
	{for(j=0;j<8;j++)
	    printf("%d ",a[i][j]);
	 printf("%d\n",a[i][8]);
	}
	return 0;
}
const int Length = 9;
int board[Length][Length] = {0};
void f(int m, int n)
{
	int i,j;
	int temp[Length][Length] = {0};
	if(n == 0) board[4][4] = m;
	else
	{
		f(m,n-1);
		for(i=0;i<Length;i++)
		{	
			for(j=0;j<Length;j++)
			{
				temp[i][j] = board[i][j];
				board[i][j] = 0;
			}
		}
		for(i = 0; i<Length ; i++)
		{
			for(j = 0; j<Length ;j++)
			{
				if(temp[i][j] != 0)
				{
					board[i][j] += temp[i][j] *2;
					board[i+1][j]+= temp[i][j];
					board[i-1][j]+= temp[i][j];
					board[i][j+1]+= temp[i][j];
					board[i][j-1]+= temp[i][j];
					board[i-1][j-1]+= temp[i][j];
					board[i+1][j+1]+= temp[i][j];
					board[i-1][j+1]+= temp[i][j];
					board[i+1][j-1]+= temp[i][j];
				}
			}
		}
	}
}
int main()
{
	int m,n,i,j;
	cin>>m>>n;
	f(m,n);
	for(i=0;i<Length;i++)
	{
		for(j=0;j<Length-1;j++)
		{
			cout<<board[i][j]<<" ";
		}
		cout<<board[i][Length-1]<<endl;
	}
	return 0;
}
int a[10][10];
void function();
int main()
{
	for(int i=1;i<=9;i++)
		for(int j=1;j<=9;j++)
			a[i][j]=0;
	int n,d;
	cin>>n>>d;
	a[5][5]=n;

	for(int i=1;i<=d;i++)
		function();

	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;
}

void function()
{ int rem[10][10];
	for(int i=1;i<=9;i++)
		for(int j=1;j<=9;j++)
			rem[i][j]=0;

	for(int i=2;i<=8;i++)
		for(int j=2;j<=8;j++)
			if(a[i][j]!=0){
				rem[i][j]=rem[i][j]+a[i][j]*2;
				rem[i-1][j-1]+=a[i][j]; rem[i-1][j]+=a[i][j]; rem[i-1][j+1]+=a[i][j]; rem[i][j-1]+=a[i][j]; 
				rem[i][j+1]+=a[i][j]; rem[i+1][j-1]+=a[i][j]; rem[i+1][j]+=a[i][j]; rem[i+1][j+1]+=a[i][j];
				a[i][j]=0;
			}

	for(int i=2;i<=8;i++){
		if(a[1][i]!=0){
			rem[1][i]+=a[1][i]*2;
			int x=a[1][i]*8/5;
			rem[1][i+1]+=x;rem[1][i-1]+=x;rem[2][i+1]+=x;rem[2][i-1]+=x;rem[2][i]+=x;
			a[1][i]=0;
		}
		if(a[9][i]!=0){
			rem[9][i]+=a[9][i]*2;
			int x=a[9][i]*8/5;
			rem[9][i+1]+=x;rem[9][i-1]+=x;rem[8][i+1]+=x;rem[8][i-1]+=x;rem[8][i]+=x;
			a[9][i]=0;
		}
		if(a[i][1]!=0){
			rem[i][1]+=a[i][1]*2;
			int x=a[i][1]*8/5;
			rem[i+1][1]+=x;rem[i-1][1]+=x;rem[i+1][2]+=x;rem[i-1][2]+=x;rem[i][2]+=x;
			a[i][1]=0;
		}
		if(a[i][9]!=0){
			rem[i][9]+=a[i][9]*2;
			int x=a[i][9]*8/5;
			rem[i+1][9]+=x;rem[i-1][9]+=x;rem[i+1][8]+=x;rem[i-1][8]+=x;rem[i][8]+=x;
			a[i][1]=0;
		}
	}

	if(a[1][1]!=0){
		rem[1][1]=a[1][1]*2;
		int x=a[1][1]*8/3;
		rem[1][2]+=x;rem[2][1]+=x;rem[2][2]+=x;
		a[1][1]=0;
	}
	if(a[1][9]!=0){
		rem[1][9]=a[1][9]*2;
		int x=a[1][9]*8/3;
		rem[1][8]+=x;rem[2][8]+=x;rem[2][9]+=x;
		a[1][9]=0;
	}
	if(a[9][1]!=0){
		rem[9][1]=a[9][1]*2;
		int x=a[9][1]*8/3;
		rem[9][2]+=x;rem[8][1]+=x;rem[8][2]+=x;
		a[1][1]=0;
	}
	if(a[9][9]!=0){
		rem[9][9]=a[9][9]*2;
		int x=a[9][9]*8/3;
		rem[9][8]+=x;rem[8][8]+=x;rem[8][9]+=x;
		a[9][9]=0;
	}
		

   for(int i=1;i<=9;i++)
		for(int j=1;j<=9;j++)
			a[i][j]=a[i][j]+rem[i][j];

   /*for(int i=1;i<=9;i++){
		for(int j=1;j<=8;j++)
			cout<<a[i][j]<<" ";
		cout<<a[i][9];
		cout<<endl;
	}*/
}
int main()
{
 int n,m,i,j,k;
 scanf("%d %d",&m,&n);
 int A[5][9][9];
    for(j=0;j<9;j++)
   {
    for(k=0;k<9;k++)
    {
     A[0][j][k]=0;
    }
   
   A[0][4][4]=m;
   }
    
  for(i=0;i<n;i++)
  {
     
     for(k=1;k<8;k++)
	 {
                  A[i+1][0][k]=A[i][0][k-1]+A[i][0][k+1]+A[i][1][k]+A[i][1][k+1]+A[i][1][k-1];
	 }
	 
    
     for(k=1;k<8;k++)
	 {
                  A[i+1][8][k]=A[i][8][k-1]+A[i][8][k+1]+A[i][7][k]+A[i][7][k+1]+A[i][7][k-1];
    }
    
    
     for(j=1;j<8;j++)
	 {
                  A[i+1][j][0]=A[i][j+1][0]+A[i][j-1][0]+A[i][j+1][1]+A[i][j-1][1]+A[i][j][1];
    }
     
    
     for(j=1;j<8;j++)
	 {
            A[i+1][j][8]=A[i][j+1][8]+A[i][j-1][8]+A[i][j+1][7]+A[i][j-1][7]+A[i][j][7];
    }
    
	
     A[i+1][0][0]=A[i][1][1]+A[i][1][0]+A[i][0][1];
	
   
	
     A[i+1][8][0]=A[i][7][1]+A[i][7][0]+A[i][8][1];

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


	
	
	for(d=1;d<=n;d++)
	{
		if(d%2==1)
		{		
			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];
					       b[i][j]+=a[i][j]*2;
                           a[i][j]=0;
					  }
				 }
			}
		}
	
	else
		{
			for(i=0;i<9;i++)
			{
		         for(j=0;j<9;j++)
				 {

				      if(b[i][j]!=0)
					  {
					       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];
					       a[i][j]+=b[i][j]*2;
                           b[i][j]+=0;
					  }
				 }
			}

		}

	}

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

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

	}
	
	return 0;
}
main()
{
      int m,n,a[11][11],b[11][11],i,j,k;
      scanf("%d %d",&m,&n);
      for(i=0;i<11;i++)
      {
             for(j=0;j<11;j++)
             {    
                  a[i][j]=0;
                  b[i][j]=0;
             }
      }
      b[5][5]=m;
      for(k=1;k<=n;k++)
      {
          for(i=5-n;i<=5+n;i++)
          {
                for(j=5-n;j<=5+n;j++)
                {
                     a[i][j]=2*b[i][j]+b[i+1][j+1]+b[i][j+1]+b[i+1][j]+b[i-1][j-1]+b[i-1][j+1]+b[i+1][j-1]+b[i-1][j]+b[i][j-1];
                }
          }
          for(i=5-n;i<=5+n;i++)
          {
                for(j=5-n;j<=5+n;j++)
                {
                     b[i][j]=a[i][j];
                }
          }
          
      }
      for(i=1;i<10;i++)
      {
             for(j=1;j<10;j++)
             { 
                  if(j==1)   
                  printf("%d",a[i][j]);
                  else if(j!=1&&j!=9)
                  printf(" %d",a[i][j]);
                  else if(j==9)
                  printf(" %d\n",a[i][j]);
             }
      }
     
}
int main()
{
	int a[10][10] = {0}, b[10][10] = {0};
	int i, j, m, n;
	cin >> m >> n;
	a[5][5] = m;
	while (n--)
	{
		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][j + 1] = b[i][j + 1] + a[i][j];
					b[i][j - 1] = b[i][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 + 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];
				}
			}
		}
		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 <= 8; j++)
			cout << a[i][j] << ' ';
		cout << a[i][9] << endl;
	}
	
	return 0;
}
int main()
{const int d=10;
	int a[d][d],b[d][d];
int i,j,k,m,n,fx,fy;
scanf("%d%d",&m,&n);
memset(a,0,sizeof(a));
a[5][5]=m;
for(i=0;i<n;i++)
{
	memset(b,0,sizeof(b));
	for(k=1;k<d-1;k++)
	{ for(j=1;j<d-1;j++)
    { b[k][j]+=a[k][j];
	for(fx=-1;fx<=1;fx++)
	{for(fy=-1;fy<=1;fy++)
	  b[k+fx][j+fy]+=a[k][j];
	}
	}
	}
	memcpy(a,b,sizeof(a));}
	for(i=1;i<d;i++)
	{ for(j=1;j<d-1;j++)
	printf("%d ",a[i][j]);
	printf("%d\n",a[i][d-1]);
	}
	return 0;
}
int main (){
int m,n,i,j,k,sz[5][20][20]={0};
   scanf("%d %d",&m,&n);
   n=n+1;
  
       
       
       sz[0][5][5]=m;
  for(k=0;k<n;k++){
       for(i=1;i<10;i++){
          for(j=1;j<10;j++){
             sz[k+1][i][j]=(sz[k][i][j]*2+sz[k][i][j+1]+sz[k][i][j-1]+sz[k][i-1][j]+sz[k][i+1][j]+sz[k][i+1][j+1]+sz[k][i+1][j-1]+sz[k][i-1][j+1]+sz[k][i-1][j-1]);
          }
       }
}
     for(i=1;i<9;i++){
        for(j=1;j<9;j++){
             printf("%d ",sz[n-1][i][j]);
         }
         printf("%d\n",sz[n-1][i][9]);
         
     }
     for(i=9,j=1;j<9;j++){
          printf("%d ",sz[n-1][i][j]);
     }
     printf("%d",sz[n-1][9][9]);

return 0;
}
int main()
{
	int sz[9][9];
	int sj[9][9];

	int a,n,row,col,r,m,x,y;
	scanf("%d %d",&a,&n);
	for(row=0;row<9;row++)
	{
		for(col=0;col<9;col++)
		{
			sz[row][col]=0;
			sj[row][col]=0;
		}
	}
	sz[4][4]=a;


	for(row=0;row<9;row++)
	{
		for(col=0;col<9;col++)
		{
			sj[row][col]=sz[row][col];
			
		}
	}
	for(row=0;row<9;row++)
	{
		for(col=0;col<9;col++)
		{
			if(sz[row][col]!=0)
			{
				for(r=(row-1);r<=(row+1);r++)
				{
					for(m=(col-1);m<=(col+1);m++)
					{
						sj[r][m]+=sz[row][col];
					}
				}
			}
		}
	}
	if(n==1)
	{
		for(x=0;x<9;x++)
		{
			for(y=0;y<8;y++)
			{
				printf("%d ",sj[x][y]);
			}
			printf("%d\n",sj[x][y]);
		}
	
	}

		for(row=0;row<9;row++)
	{
		for(col=0;col<9;col++)
		{
			sz[row][col]=sj[row][col];
			
		}
	}
	for(row=0;row<9;row++)
	{
		for(col=0;col<9;col++)
		{
			
			if(sj[row][col]!=0)
			{
				for(r=row-1;r<=row+1;r++)
				{
					for(m=col-1;m<=col+1;m++)
					{
						sz[r][m]+=sj[row][col];
					}
				}
			}
		}
	}
	if(n==2)
	{
		for(x=0;x<9;x++)
		{
			for(y=0;y<8;y++)
			{
				printf("%d ",sz[x][y]);
			}
			printf("%d\n",sz[x][y]);
		}

	}


		for(row=0;row<9;row++)
	{
		for(col=0;col<9;col++)
		{
			sj[row][col]=sz[row][col];
			
		}
	}

		for(row=0;row<9;row++)
	{
		for(col=0;col<9;col++)
		{
			
			if(sz[row][col]!=0)
			{
				for(r=row-1;r<=row+1;r++)
				{
					for(m=col-1;m<=col+1;m++)
					{
						sj[r][m]+=sz[row][col];
					}
				}
			}
		}
	}
	if(n==3)
	{
		for(x=0;x<9;x++)
		{
			for(y=0;y<8;y++)
			{
				printf("%d ",sj[x][y]);
			}
			printf("%d\n",sj[x][y]);
		}

	}

		for(row=0;row<9;row++)
	{
		for(col=0;col<9;col++)
		{
			sz[row][col]=sj[row][col];
			
		}
	}


	for(row=0;row<9;row++)
	{
		for(col=0;col<9;col++)
		{
			
			if(sj[row][col]!=0)
			{
				for(r=row-1;r<=row+1;r++)
				{
					for(m=col-1;m<=col+1;m++)
					{
						sz[r][m]+=sj[row][col];
					}
				}
			}
		}
	}
	if(n==4)
	{
		for(x=0;x<9;x++)
		{
			for(y=0;y<8;y++)
			{
				printf("%d ",sz[x][y]);
			}
			printf("%d\n",sz[x][y]);
		}
	
	}

	return 0;
	}
int main(){
	int a[5][10][10]={0},k,i,j,m,n;
	scanf("%d%d",&m,&n);
	for (i=0;i<=10;i++){
			for (j=0;j<=10;j++){
				a[0][i][j]=0;
			}
	}
	a[0][5][5]=m;
	for (k=1;k<=n;k++){
		for (i=1;i<=9;i++){
			for (j=1;j<=9;j++){
				a[k][i][j]=a[k-1][i][j]*2+a[k-1][i-1][j-1]+a[k-1][i][j-1]+a[k-1][i-1][j]+a[k-1][i][j+1]+a[k-1][i+1][j]+a[k-1][i+1][j+1]+a[k-1][i+1][j-1]+a[k-1][i-1][j+1];
			}
		}
	}
	for (i=1;i<=9;i++){
		for (j=1;j<=9;j++){
			if ((abs(i-5)>n)||(abs(j-5)>n))
				a[k][i][j]=0;
		}
	}
	for (i=1;i<=9;i++){
		for (j=1;j<=9;j++){
			if (j!=9)
			   printf("%d ",a[n][i][j]);
			else printf("%d",a[n][i][j]);
		}
		printf("\n");
	}
	return 0;
}