semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
    int f[2][15][15];
    int i, j, k, m, n, p, q, t;
    scanf("%d %d", &m, &n);
    memset(f, 0, sizeof(f));
    f[0][5][5] = m;
    p = 0;
    q = 1;
    for(k=1; k<=n; k++)
    {
        for(i=1; i<=9; i++)
            for(j=1; j<=9; j++)
                f[q][i][j] = 0;
        for(i=1; i<=9; i++)
            for(j=1; j<=9; j++)
                if(f[p][i][j]!=0)
                {
                    f[q][i][j] += f[p][i][j]*2;
                    f[q][i-1][j-1] += f[p][i][j];
                    f[q][i-1][j] += f[p][i][j];
                    f[q][i-1][j+1] += f[p][i][j];
                    f[q][i][j-1] += f[p][i][j];
                    f[q][i][j+1] += f[p][i][j];
                    f[q][i+1][j-1] += f[p][i][j];
                    f[q][i+1][j] += f[p][i][j];
                    f[q][i+1][j+1] += f[p][i][j];
                }
        t = p; p = q; q = t;
    }
    for(i=1; i<=9; i++)
    {
        for(j=1; j<9; j++)
            printf("%d ", f[p][i][j]);
        printf("%d\n", f[p][i][9]);
    }
    return 0;
}
main()
{
    int a[11][11]={0};
    int b[11][11];
    int m,n,k,i,j;
    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++)
            {
                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++)
        {
            for(j=1;j<=8;j++)
            {
                printf("%d ",a[i][j]);
            }
            printf("%d\n",a[i][j]);
        }
}
//****************************************
//*???????????               **
//*?????? 1100012763              **
//*???2011.11.23                     **
//****************************************
int zou[2][8]={{-1,-1,-1,0,1,1,1,0},
               {-1,0,1,1,1,0,-1,-1}};
int day;
int flag[9][9] , map[9][9] , stack[9][9]; 
 
void flood(int count)
{
	int i , j , k , x , y;
	if (count <= day)
	{
		for (i = 0; i <= 8; i++)
		{
			for (j = 0; j <= 8; j++)
                if (map[i][j] > 0)
				{
					flag[i][j] = 1;
					stack[i][j] = map[i][j];
				}
		}
		for (i = 0; i <= 8; i++)
		{
			for (j = 0; j <= 8; j++)
			{
				if (flag[i][j] > 0)
				{
				    for (k = 0; k <= 7; k++)
					{
					    x = i + zou[0][k];
					    y = j + zou[1][k];
					    if (x < 0 || y < 0 || x > 8 || y > 8)
						    continue;
					    map[x][y] = map[x][y] + stack[i][j];
					}
				    map[i][j] = map[i][j] + 2 * stack[i][j];
					map[i][j] = map[i][j] - stack[i][j];
				}
			}
		}
		flood(count + 1);
	}
}

int main() 
{
	int i , j , num;
	cin >> num >> day;
    for (i = 0; i <= 8; i++)
		for (j = 0; j <= 8; j++)
		{
			map[i][j] = 0;
			flag[i][j] = 0;
			stack[i][j] = 0;
		}
    map[4][4] = num;
	flood(1);

	for (i = 0; i <= 8; i++)
	{
		if (i > 0)
			cout << endl;
		for (j = 0; j <= 8; j++)
		{
			if (j > 0)
				cout << ' ';
			cout << map[i][j];
		}
	}

	return 0;
}
int main()
{
    int juzhen[11][11],zhi[11][11];//??? 
    int chu,day,i,j,n;//chu?????day????? 
    cin>>chu>>day;
    for(i=0;i<11;i++)
      for(j=0;j<11;j++) juzhen[i][j]=0;
    juzhen[5][5]=chu;//??????????
    for(n=0;n<day;n++)
    {
                      for(i=1;i<10;i++)
                      {
                                      for(j=1;j<10;j++)
                                      {
                                                      zhi[i][j]=2*juzhen[i][j]+juzhen[i][j-1]+juzhen[i][j+1]+
                                                      juzhen[i-1][j-1]+juzhen[i-1][j]+juzhen[i-1][j+1]+juzhen[i+1][j-1]+
                                                      juzhen[i+1][j]+juzhen[i+1][j+1];//????? 
                                      }
                      }
                      for(i=1;i<10;i++)
                        for(j=1;j<10;j++) juzhen[i][j]=zhi[i][j];
    }
    for(i=1;i<10;i++)
    {
                    for(j=1;j<10;j++)
                    {
                                    if (j==9) cout<<juzhen[i][j]<<endl;//???? 
                                    else cout<<juzhen[i][j]<<" ";
                    }
    }
    return 0;
}
int main()
{
int m,n;
scanf("%d %d",&m,&n);
int sz[5][9][9];
for(int i=0;i<9;i++)
{
                for(int j=0;j<9;j++)
                {sz[0][i][j]=0;}
                }
                sz[0][4][4]=m;
                
                
                
                for(int t=0;t<n;t++)
{


    for(int k=0;k<9;k++)
    {
            for(int hl=0;hl<9;hl++)
          {
                    if(k!=0&&hl!=0&&k!=8&&hl!=8)
                    {
                     sz[t+1][k][hl]=2*sz[t][k][hl]+sz[t][k][hl-1]+sz[t][k][hl+1]+sz[t][k-1][hl+1]+sz[t][k+1][hl+1]+sz[t][k-1][hl]+sz[t][k-1][hl-1]+sz[t][k+1][hl]+sz[t][k+1][hl-1];
                                                }
                    if(k==0&&hl!=0&&hl!=8)
                    {sz[t+1][0][hl]=2*sz[t][0][hl]+sz[t][0][hl-1]+sz[t][0][hl+1]+sz[t][1][hl+1]+sz[t][1][hl]+sz[t][1][hl-1];
                                         }
                    if(k==8&&hl!=0&&hl!=8)
                    {sz[t+1][8][hl]=2*sz[t][8][hl]+sz[t][8][hl-1]+sz[t][8][hl+1]+sz[t][7][hl+1]+sz[t][7][hl]+sz[t][7][hl-1];
                                         }
                    if(k!=0&&hl==0&&k!=8)
                    {
                     sz[t+1][k][0]=2*sz[t][k][0]+sz[t][k][1]+sz[t][k-1][1]+sz[t][k+1][1]+sz[t][k-1][0]+sz[t][k+1][0];
                                                }
                    if(k!=0&&hl==8&&k!=8)
                    {
                     sz[t+1][k][8]=2*sz[t][k][8]+sz[t][k][7]+sz[t][k-1][7]+sz[t][k+1][7]+sz[t][k-1][8]+sz[t][k+1][8];
                                                }
                    if(k==0&&hl==0)
                    {
                     sz[t+1][0][0]=2*sz[t][0][0]+sz[t][0][1]+sz[t][1][1]+sz[t][1][0];
                                                }
                    if(k==0&&hl==8)
                    {
                     sz[t+1][0][8]=2*sz[t][0][8]+sz[t][0][7]+sz[t][1][7]+sz[t][1][8];
                                                }
                                                
                                                
                   if(k==8&&hl==0)
                    {
                     sz[t+1][8][0]=2*sz[t][8][0]+sz[t][8][1]+sz[t][7][1]+sz[t][7][0];
                                                }
                    if(k==8&&hl==8)
                    {
                     sz[t+1][8][8]=2*sz[t][8][8]+sz[t][8][7]+sz[t][7][7]+sz[t][7][8];
                                                }
                                                
                                                
                    
          }
          
    }
}
                
                
                
                
                for(int row=0;row<9;row++)
                {
                for(int lo=0;lo<8;lo++)
                {printf("%d ",sz[n][row][lo]);}
                printf("%d\n",sz[n][row][8]);
                        }

      

	return 0;
}
int main()
{
    const int x = 9;
    int i, j, k, m, n, fx, fy;
int a[9][9], b[9][9];
    
    
    scanf("%d%d", &m, &n);
    memset(a, 0, sizeof(a));
    a[x / 2][x / 2] = m;
    
    for (k = 0; k < n; k++) {
        memset(b, 0, sizeof(b));
        for (i = 1; i < x - 1; i++) {
            for (j = 1; j < x - 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 < x; i++) {
        for (j = 0; j < x - 1; j++)
            printf("%d ", a[i][j]);
        printf("%d\n", a[i][x - 1]);
    }
    
    return 0;
}
int a[9][9] = {0};
int b[9][9] = {0};
int n, day = 0;

void feed()
{
     if (day == n)
         return;
     for (int i = 0; i <= 8; i++)
         for (int j = 0; j <= 8; j++)
         {
             b[i][j] += 2 * a[i][j];
             if (i + 1 <= 8)
             {
                 b[i + 1][j] += a[i][j];
                 if (j + 1 <= 8)
                     b[i + 1][j + 1] += a[i][j];
                 if (j - 1 >= 0)
                     b[i + 1][j - 1] += a[i][j];
             }
             if (i - 1 >= 0)
             {
                 b[i - 1][j] += a[i][j];
                 if (j + 1 <= 8)
                     b[i - 1][j + 1] += a[i][j];
                 if (j - 1 >= 0)
                     b[i - 1][j - 1] += a[i][j];
             }
             if (j + 1 <= 8)
                 b[i][j + 1] += a[i][j];
             if (j - 1 >= 0)
                 b[i][j - 1] += a[i][j];
         }
         for (int i = 0; i <= 8; i++)
             for (int j = 0; j <= 8; j++)
                 {
                      a[i][j] = b[i][j];
                      b[i][j] = 0;
                 }
         day++;
         feed();
}

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

}
int main()
{
	int m,n,a[10][10],k,i,j,c[10][10];
	cin>>m>>n;
	memset(a,0,sizeof(a));
	a[5][5]=m;
	for (k=1;k<=n;k++)
		{
		memset(c,0,sizeof(c));
		for (i=1;i<=9;i++)
			for (j=1;j<=9;j++)
			{
				c[i][j]+=a[i][j];
				c[i-1][j]+=a[i][j];
				c[i+1][j]+=a[i][j];
				c[i][j-1]+=a[i][j];
				c[i][j+1]+=a[i][j];
				c[i-1][j-1]+=a[i][j];
				c[i-1][j+1]+=a[i][j];
				c[i+1][j-1]+=a[i][j];
				c[i+1][j+1]+=a[i][j];
			}
		for (i=1;i<=9;i++)
			for (j=1;j<=9;j++)
				a[i][j]+=c[i][j];

		}
	for (i=1;i<=9;i++)
		for (j=1;j<=9;j++)
		{
			cout<<a[i][j];
			if (j!=9) cout<<" ";
			if ((i!=9)&&(j==9)) cout<<endl;
		}
	return 0;
}
int main(int argc, char* argv[])
{
	int A[9][9]={0},B[9][9]={0};
	int i,j,n,k;
	scanf ("%d%d",&(A[4][4]),&n);
	for (k=0;k<n;k++)
	{
	for (i=1;i<8;i++)
	{
		for (j=1;j<8;j++)
		{
			B[i][j]=2*A[i][j]+A[i-1][j-1]+A[i-1][j]+A[i-1][j+1]+A[i][j-1]+A[i][j+1]+A[i+1][j-1]+A[i+1][j]+A[i+1][j+1];
		}
	}

	for (j=1;j<8;j++)
	{
		B[0][j]=2*A[0][j]+A[0][j-1]+A[0][j+1]+A[1][j]+A[1][j+1]+A[1][j-1];
	}
	
    for (j=1;j<8;j++)
	{
		B[8][j]=2*A[8][j]+A[8][j-1]+A[8][j+1]+A[7][j]+A[7][j+1]+A[7][j-1];
	}
	for (j=1;j<8;j++)
	{
		B[j][0]=2*A[j][0]+A[j-1][0]+A[j-1][1]+A[j][1]+A[j+1][0]+A[j+1][1];
	}
	for (j=1;j<8;j++)
	{
		B[j][8]=2*A[j][8]+A[j-1][8]+A[j-1][7]+A[j][7]+A[j+1][7]+A[j+1][8];
	}
    B[8][8]=2*A[8][8]+A[8][7]+A[7][8]+A[7][7];
	B[0][8]=2*A[0][8]+A[0][7]+A[1][8]+A[1][7];
	B[8][0]=2*A[8][0]+A[8][1]+A[7][0]+A[7][1];
	B[0][0]=2*A[0][0]+A[0][1]+A[1][0]+A[1][1];
    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;
}
int maze[9][9];
int day = 0;
void search(int n)
{
	while(day != n)
	{
		day++;
		int add[9][9];
		memset(add, 0, sizeof(add));
		for (int i = 4 - day + 1; i <= 4 + day - 1; i++)
			for (int j = 4 - day + 1; j <= 4 + day - 1; j++)
			{
				add[i+1][j] += maze[i][j];
				add[i-1][j] += maze[i][j];
				add[i+1][j+1] += maze[i][j];
				add[i-1][j-1] += maze[i][j];
				add[i+1][j-1] += maze[i][j];
				add[i-1][j+1] += maze[i][j];
				add[i][j+1] += maze[i][j];
				add[i][j-1] += maze[i][j];
				add[i][j] +=  maze[i][j];
			}
		for (int i = 4 - day; i <= 4 + day; i++)
			for (int j = 4 - day; j <= 4 + day; j++)
			{
				maze[i][j] += add[i][j];
			}
	}
	return;
}
int main()
{
	int m, n;
	cin >> m >> n;
	maze[4][4] = m;
	search(n);
	for (int i = 0; i < 9; i++)
	{
		cout << maze[i][0];
		for (int j = 1; j < 9; j++)
			cout << " " << maze[i][j];
		cout << endl;
	}
	return 0;
}
//********************************
//*???????????    **
//*????? 1300012990 **
//*???2013.12.07  **
//********************************
int b[9][9], old[9][9];
void num( int a,int e);
void ab(int c,int d);	
int main()
{
	int m,n,i,j;
	memset(b, 0, sizeof(b)); 
	cin >> m >> n;
	b[4][4]=m;
	num(0,n);
	for(i=0;i<=8;i++)
	{
		cout << b[i][0];
		for(j=1;j<=8;j++)
			cout << " " << b[i][j] ;
		cout << endl;
	}
	return 0;
}
void num( int a,int e)
{
	int i,j;
	for(i=0;i<=8;i++)
		for(j=0;j<=8;j++)
			old[i][j]=b[i][j];
	for(i = 4 - a; i <= 4 + a; i++)
		for(j = 4 - a; j <= 4 + a; j++)
			ab(i, j);  
	a++;
	if(a==e)
		return;
	else
		num(a,e);
}
void ab(int c,int d)
{
	int i, j;
	for(i = c - 1; i <= c + 1; i++)
		for(j = d - 1; j <= d + 1; j++)
			b[i][j] = b[i][j] + old[c][d]; 
	return;
}
int main()
{
	int i, j, m, n, k,a[9][9], b[9][9];

	memset(a,0,9*9*sizeof(int));
	memset(b,0,9*9*sizeof(int));
	cin >> m >> n;
	a[4][4] = m;
	b[4][4] = m;
	for (k = 0;k <= n;k++)
	{
		for (i = 4 - k;i < 4 + k;i++)
		{
			for (j = 4 - k;j < 4 + k;j++)
			{
				b[i-1][j-1] += a[i][j];
				b[i-1][j]   += a[i][j];
				b[i-1][j+1] += a[i][j];
				b[i][j-1]   += a[i][j];
				b[i][j+1]   += a[i][j];
				b[i+1][j-1] += a[i][j];
				b[i+1][j]   += a[i][j];
				b[i+1][j+1] += a[i][j];
				b[i][j] += a[i][j];
			}
		}

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

	for (i = 0;i < 9;i++)     //????
	{
		for (j = 0;j < 9;j++)
		{
			if (i < 8)
			{
				if (j < 8)
					cout << a[i][j] << " ";
				else 
					cout << a[i][j] << endl;
			}
			else 
			{
				if (j < 8)
					cout << a[i][j] << " ";
				else 
					cout << a[i][j];
			}
		}
	}
	return 0;
}
void change(int [][9]);
int main()
{
	int m, n, i, j;
	int matrix[9][9] = {0};
	cin >> m >> n;
	matrix[4][4] = m;
	for (i = 0; i < n; i++)
	{
		change(matrix);
	}
	for (i = 0; i < 9; i++)
	{
		cout << matrix[i][0];
		for (j = 1; j < 9; j++)
		{
			cout << ' ' << matrix[i][j];
		}
		cout << endl;
	}
	return 0;
}
void change(int matrix[9][9])
{
	int i, j;
	int plus[9][9] = {0};
	for (i = 0; i < 9; i++)
	{
		for (j = 0; j < 9; j++)
		{
			if (matrix[i][j] > 0)
			{
				plus[i][j] += matrix[i][j];
				plus[i - 1][j] += matrix[i][j];
				plus[i][j - 1] += matrix[i][j];
				plus[i + 1][j] += matrix[i][j];
				plus[i][j + 1] += matrix[i][j];
				plus[i - 1][j - 1] += matrix[i][j];
				plus[i - 1][j + 1] += matrix[i][j];
				plus[i + 1][j + 1] += matrix[i][j];
				plus[i + 1][j - 1] += matrix[i][j];
			}
		}
	}
	for (i = 0; i < 9; i++)
	{
		for (j = 0; j < 9; j++)
		{
			matrix[i][j] += plus[i][j];
		}
	}
}
int main()
{
int m,n,i,j;
int a[11][11],b[11][11];
cin>>m>>n;
for(i=0;i<11;i++)
  for(j=0;j<11;j++){
      a[i][j] = 0;
	  b[i][j] = 0;
		  if(i==5 && j==5){
		     a[i][j] = m;
		  }
}
  

  while(n--){
   for(i=1;i<=9;i++)
    for(j=1;j<=9;j++){
		if(a[i][j] != 0){
            b[i-1][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] += a[i][j];	
			b[i-1][j+1] += a[i][j];	
			b[i][j+1] += a[i][j];
			b[i+1][j+1] += a[i][j];
			b[i][j] += 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<=9;j++){
		if(j==9){
			cout<<" "<<a[i][j]<<endl;;
		
		}
		else if(j==1){
		    cout<<a[i][j];
		}
		else cout<<" "<<a[i][j];
	}
	
return 0;
}
int main()
{
	int num, d;
	int a[11][11];
	int b[11][11];
	int i, j;
	for(i=0;i<=10;i++)
	{
	for(j=0;j<=10;j++)
	{
		a[i][j]=0;
		b[i][j]=0;
	}
	}
	cin>>num>>d;
	a[5][5]=num;
	b[5][5]=num;
	while(d--)
	{
	for(i=0;i<=10;i++)
	for(j=0;j<=10;j++)
		a[i][j]=0;
		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-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];
					a[i][j-1]+=b[i][j];
					a[i][j+1]+=b[i][j];
	
				}
			
			
			}
		for(i=1;i<=9;i++)
		{
			for(j=1;j<=9;j++)
			{
				b[i][j]=a[i][j];
			}		
		}
	
	}
	for(i=1;i<=9;i++)
	{
	for(j=1;j<=9;j++)
	{
		if(j!=1)
			cout<<" ";
		cout<<a[i][j];
	}
	cout<<endl;
	}
	return 0;
}
int A[9][9][5];
int main()
{
	int i,j,m,t,k;
	int number1,number2;
	for(i=0;i<9;i++)
	{
		for(j=0;j<9;j++)
		{
			for(k=0;k<=4;k++)
			{
				A[i][j][k]=0;
			}
		}
	}
	scanf("%d%d",&m,&t);
	A[4][4][0]=m;
	for(i=1;i<=t;i++)
	{
		for(j=0;j<9;j++)
		{
			for(k=0;k<9;k++)
			{
				A[j][k][i]=A[j][k][i-1]*2;
				for(number1=-1;number1<2;number1++)
				{
					for(number2=-1;number2<2;number2++)
					{

						if(j+number1>=0&&j+number1<9&&k+number2>=0&&k+number2<9)
						{
							if(number1!=0||number2!=0)
								A[j][k][i]=A[j][k][i]+A[j+number1][k+number2][i-1];
						}
					}
				}
			}
		}
	}
	for(k=0;k<9;k++)
	{
		for(j=0;j<9;j++)
		{
			if(j==0)
				printf("%d",A[k][j][i-1]);
			else
				printf(" %d",A[k][j][i-1]);
		}
		if(i<8)
			printf("\n");
	}
	return 0;
}
int main()
{
	int a[11][11]={0},b[11][11]={0},m,n,i,j,k;
	cin>>m>>n;
	a[5][5]=m;
	for(i=0;i<n;i++)
	{
		for(j=1;j<10;j++)
			for(k=1;k<10;k++)
			{
				b[j][k+1]=a[j][k]+b[j][k+1];b[j][k-1]=a[j][k]+b[j][k-1];b[j-1][k+1]=a[j][k]+b[j-1][k+1];b[j+1][k+1]=a[j][k]+b[j+1][k+1];
				b[j-1][k]=a[j][k]+b[j-1][k];b[j+1][k]=a[j][k]+b[j+1][k];b[j+1][k-1]=a[j][k]+b[j+1][k-1];b[j-1][k-1]=a[j][k]+b[j-1][k-1];
				a[j][k]=2*a[j][k];
			}
		for(j=1;j<10;j++)
			for(k=1;k<10;k++)
				a[j][k]=a[j][k]+b[j][k];
		for(j=0;j<11;j++)
			for(k=0;k<11;k++)
				b[j][k]=0;
	}
	for(i=1;i<10;i++)
		for(j=1;j<10;j++)
		{
			if(j==1)
				cout<<a[i][j];
			else 
				cout<<' '<<a[i][j];
			if(j==9)
				cout<<endl;
		}
	return 0;
}
int a[9][9],b[9][9];
int main ()
{void F(int x, int y);
    int p,q,i,j,t,m,n;
    for (i=0;i<9;i++)
    for (j=0;j<9;j++)
    {a[i][j]=0;b[i][j]=0;}
    scanf("%d %d",&m,&n);
    a[4][4]=m;
    for (t=1;t<=n;t++)
    {   for (p=0;p<9;p++)
        for (q=0;q<9;q++)
        b[p][q]=0;
     
        for (i=0;i<9;i++)
        for (j=0;j<9;j++)
        F (i,j);   
        for (p=0;p<9;p++)
        for (q=0;q<9;q++)
        a[p][q]+=b[p][q];
    } 
    for (i=0;i<9;i++)
    {for (j=0;j<8;j++)
    printf("%d ",a[i][j]);
    printf("%d\n",a[i][8]);
    }
}
void F(int x, int y)
{   int i,j,m;
    if   (a[x][y]>0)
     {m=a[x][y];
     for (i=-1;i<2;i++)
     for (j=-1;j<2;j++)
     b[x+i][y+j]+=m;}
}
int main()
{
	int m,n,i,j,k,a[9][9],b[9][9];
	cin>>m>>n;
	for(i=0;i<9;i++)
	{
		for(j=0;j<9;j++)
		{
			a[i][j]=0;
		}
	}
	a[4][4]=m;
	for(k=1;k<=n;k++)
	{
		for(i=1;i<8;i++)
		{
			for(j=1;j<8;j++)
			{
				b[i][j]=a[i-1][j]+a[i+1][j]+a[i][j-1]+a[i][j+1]+a[i+1][j+1]+a[i-1][j+1]+a[i+1][j-1]+a[i-1][j-1]+2*a[i][j];
			}
		}
		b[0][0]=a[1][1];
		b[8][8]=a[7][7];
		b[0][8]=a[1][7];
		b[8][0]=a[7][1];
	    for(i=1;i<8;i++)
		{
			b[i][0]=a[i][1]+a[i-1][1]+a[i+1][1];
			b[i][8]=a[i][7]+a[i-1][7]+a[i+1][7];
		}
	    for(j=1;j<8;j++)
		{
			b[0][j]=a[1][j]+a[1][j-1]+a[1][j+1];
			b[8][j]=a[7][j]+a[7][j-1]+a[7][j+1];
		}	
		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++)
		{
			cout<<b[i][j]<<' ';
		}
		cout<<b[i][8]<<endl;
	}
	return 0;
}
int main()
{
	int a[9][9] = {0}, b[9][9] = {0};
	int n, m;
	cin >> n >> m;
	a[4][4] = n;
	b[4][4] = n;
	for(m; m > 0; m--)
	{
		int c[9][9] = {0};
		for(int i = 0; i < 9; i++)
		{
			for(int 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(int x = 0; x < 9; x++)
		{
			for(int y = 0; y < 9; y++)
			{
				a[x][y] = b[x][y];
			}
		}
	}
	for(int x = 0; x < 9; x++)
	{
		for(int y = 0; y < 9; y++)
		{
			cout << a[x][y];
			if(y < 8) cout << " ";
		}
		cout << endl << endl;
	}
	return 0;
}
main()
{
    int a[11][11][5]={0},i,j,nd,k,ii,jj;
    scanf("%d %d",&a[5][5][0],&nd);
    for(k=1;k<=nd;k++)
    {
        for(i=1;i<=9;i++)
        {
            for(j=1;j<=9;j++)
            {
                a[i][j][k]+=a[i][j][k-1];
                for(ii=-1;ii<=1;ii++)
                {
                    for(jj=-1;jj<=1;jj++)
                    {a[i+ii][j+jj][k]+=a[i][j][k-1];}
                }
            }
        }

    }
    for(i=1;i<=9;i++)
    {
        for(j=1;j<=8;j++)
        {printf("%d ",a[i][j][nd]);}
        printf("%d\n",a[i][j][nd]);
    }
}
int a[11][11];
int temp[11][11];
void f(int x,int y)
{
	int v = a[x][y];
	for(int i = -1;i<=1;i++){
		for(int j = -1;j<=1;j++){
			if(i==0&&j==0) temp[x+i][y+j]+=v*2;
			else temp[x+i][y+j]+=v;
			}
		}
	return;
}
int main()
{
	int m,n;
	cin>>m>>n;
	memset(a,0,sizeof(a));
	a[5][5]=m;
	for(int k=0;k<n;k++)
	{
		memset(temp,0,sizeof(temp));
		for(int i=1;i<=9;i++)
		{
			for(int j=1;j<=9;j++)
			{
				if(a[i][j]>0) f(i,j);	
			}	
		}
		for(int i=1;i<=9;i++)
		{
			for(int j=1;j<=9;j++)
			{
				a[i][j]=temp[i][j];	
			}	
		}	
	}
		for(int i=1;i<=9;i++)
		{
			for(int j=1;j<=8;j++)
			{
				cout<<a[i][j]<<" ";	
			}	
			cout<<a[i][9]<<endl;
		}
		return 0;
}
int b[11][11],d[11][11];
void breed();
int main()
{
	int days,i,j;
	for(i=0;i<11;i++)
	{
		for(j=0;j<11;j++)
		{
			b[i][j]=d[i][j]=0;
		}
	}
	cin>>b[5][5]>>days;
	for(i=1;i<=days;i++)
	{
		breed();
	}
	for(i=1;i<=9;i++)
	{
		for(j=1;j<=9;j++)
		{
			if(j==9)
			{
				cout<<b[i][j]<<endl;
			}
			else
			{
				cout<<b[i][j]<<" ";
			}
		}
	}
	return 0;
}


void breed()
{
	int i,j;
	for(i=1;i<=9;i++)
	{
		for(j=0;j<=10;j++)
		{
			d[i][j]=b[i][j];
		}
	}
	for(i=1;i<=9;i++)
	{
		for(j=1;j<=9;j++)
		{
			b[i][j]=d[i][j]*2+d[i-1][j-1]+d[i-1][j]+d[i-1][j+1]+d[i][j-1]+d[i][j+1]+d[i+1][j-1]+d[i+1][j]+d[i+1][j+1];
		}
	}
}
int main()
{
	int m,n;
	scanf("%d %d",&m,&n);
	int sz[9][9];
	for(int i=0;i<9;i++){
		for(int j=0;j<9;j++){
			sz[i][j]=0;
		}
	}
	sz[4][4]=m;
	int a[100],row[100],col[100],v=0;
	for(int k=0;k<n;k++){
		for(int l=0;l<9;l++){
			for(int u=0;u<9;u++){
				if(sz[l][u]!=0){
					a[v]=sz[l][u];
					row[v]=l;
					col[v]=u;
					v++;
				}
			}
		}
			for(int w=0;w<9;w++){
				for(int m=0;m<9;m++){
					sz[w][m]=0;
				}
			}
		for(int c=0;c<v;c++){
			sz[row[c]+1][col[c]+1]+=a[c];
            sz[row[c]+1][col[c]]+=a[c];
            sz[row[c]][col[c]+1]+=a[c];
            sz[row[c]-1][col[c]-1]+=a[c];
            sz[row[c]-1][col[c]]+=a[c];
            sz[row[c]][col[c]-1]+=a[c];
            sz[row[c]+1][col[c]-1]+=a[c];
			sz[row[c]-1][col[c]+1]+=a[c];
			sz[row[c]][col[c]]+=2*a[c];
		}
			int a[100]={0};
			int row[100]={0};
			int col[100]={0};
			v=0;
	}
	for(int p=0;p<9;p++){
		for(int q=0;q<8;q++){
			printf("%d ",sz[p][q]);
		}
		printf("%d\n",sz[p][8]);
	}
	return 0;
}