semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
	int num, d, a[9][9] = {0}, tmp[9][9] = {0};
	cin >> num >> d;
	a[4][4] = num;
	for (int i = 0; i < d; i++)
	{
		for (int x = 0; x < 9; x++)
			for (int y = 0; y < 9; y++)
				tmp[x][y] = 0;
		for (int x = 0; x < 9; x++)
			for (int y = 0; y < 9; y++)
			{
				if(x > 0)
				{
					tmp[x - 1][y] += a[x][y];
					if (y > 0)
					{
						tmp[x - 1][y - 1] += a[x][y];
						if (y < 9)
							tmp[x - 1][y + 1] += a[x][y];
					}
					if (x < 9)
					{
						tmp[x + 1][y] += a[x][y];
						if (y > 0)
						{
							tmp[x + 1][y - 1] += a[x][y];
							if (y < 9)
								tmp[x + 1][y + 1] += a[x][y];
						}
					}
				}
				if(y > 0)
					tmp[x][y - 1] += a[x][y];
				if (y < 9)
					tmp[x][y + 1] += a[x][y];
				tmp[x][y] += a[x][y] * 2;
			}
			for (int x = 0; x < 9; x++)
				for (int y = 0; y < 9; y++)
					a[x][y] = tmp[x][y];
	}
	for (int x = 0; x < 9; x++)
		for (int y = 0; y < 9; y++)
		{
			cout << a[x][y];
			if (y == 8)
				cout << endl;
			else
				cout << " ";
		}
			




	
	return 0;
}
int m, n;

int main()
{
	int produce(int x, int y, int n);
	cin >> m >> n;
	for(int i = 1; i <= 9; i ++)
	{
		cout << produce(i, 1, n);
		for (int j = 2; j <= 9; j ++)
			cout << " " << produce(i, j, n);
		cout << endl;
	}
	return 0;	
}

int produce(int x, int y, int day)
{
	if(x == 0 || y == 0 || x == 10|| y == 10) return 0;
	else if(day == 0)
	{
		if(x == 5 && y == 5) return m;
		else return 0;
	}
	else return
		(produce(x - 1, y, day - 1) + produce(x + 1, y, day - 1)
		+ produce(x, y - 1, day - 1) + produce(x, y + 1, day - 1)+
		produce(x, y , day - 1) * 2) + produce(x - 1, y - 1, day - 1)
		+ produce(x - 1, y + 1, day - 1) + produce(x + 1, y - 1, day - 1)
		+ produce(x + 1, y + 1, day - 1);
}
int a[9][9] = {0}, b[9][9] = {0};
int f(int x,int y)
{
	int v = a[x][y] * 2;
	if (x > 0)
	{
		v += a[x - 1][y];
		if (y > 0)
			v += a[x - 1][y - 1];
	}
	if (y > 0)
	{
		v += a[x][y - 1];
		if (x < 8)
			v += a[x + 1][y - 1];
	}
	if (x < 8)
	{
		v += a[x + 1][y];
		if (y < 8)
			v += a[x + 1][y + 1];
	}
	if (y < 8)
	{
		v += a[x][y + 1];
		if (x > 0)
			v += a[x - 1][y + 1];
	}
	return v;
}

int main()
{
	int m, n, i, j, k;
	cin >> m >> n;
	a[4][4] = m;
	for (i = 1; i <= n; i++)
	{
		for (j = 0; j <= 8; j++)
		{
			for (k = 0; k <= 8; k++)
				b[j][k] = f(j,k);
		}
		for (j = 0; j <= 8; j++)
		{
			for (k = 0; k <= 8; k++)
				a[j][k] = b[j][k];
		}
	}
	for (j = 0; j <= 8; j++)
	{
		for (k = 0; k < 8; k++)
			cout << a[j][k] << " ";
		cout << a[j][8] << endl;
	}
	return 0;
}
int a[9][9][2];
int temp;
void run()
{
    for(int i=0;i<9;i++)  for(int j=0;j<9;j++)
    if(a[i][j][0])  {for(int p=i-1;p<=i+1;p++)  for(int q=j-1;q<=j+1;q++)  a[p][q][1]+=a[i][j][0];}
    for(int i=0;i<9;i++)  for(int j=0;j<9;j++)  {a[i][j][0]+=a[i][j][1];a[i][j][1]=0;}
}
int main()
{
    int m,n;
    cin>>m>>n;
    for(int i=0;i<9;i++)  for(int j=0;j<9;j++)  a[i][j][0]=a[i][j][1]=0;
    a[4][4][0]=m;
    for(int s=1;s<=n;s++)  run();
    for(int i=0;i<9;i++)
    {
    cout<<a[i][0][0];
    for(int j=1;j<9;j++)  cout<<" "<<a[i][j][0];
    cout<<endl;
    }
}
int plate1[9][9] = {0}; // ??????
int plate[9][9] = {0}; 
void count(int k);

int main ()
{
	int m, n;
	cin >> m >> n;
	plate[4][4] = m;
	count(n);
    return 0;
}
 
void count(int k)
{
	int i, j;
	if (k == 0)
	{
		for (i = 0; i < 9; i++)
		{
			for (j = 0; j < 8; j++)
			{
				cout << plate[i][j] << " ";
			}
			cout << plate[i][j] << endl;
		}
		return;
	}
	else 
	{
	    for (i = 0; i < 9; i++)
		{
			for (j = 0; j < 9; j++)
			{
				if (plate[i][j] != 0)
				{
					if (i > 0 && j > 0)
			    	{
		    			plate1[i - 1][j - 1] = plate1[i - 1][j - 1] + plate[i][j];
	    			}
					if (j > 0)
			    	{
		    			plate1[i][j - 1] = plate1[i][j - 1] + plate[i][j];
	    			}
					if (i > 0 && j < 8)
			    	{
		    			plate1[i - 1][j + 1] = plate1[i - 1][j + 1] + plate[i][j];
	    			}
					if (j < 8)
			    	{
		    			plate1[i][j + 1] = plate1[i][j + 1] + plate[i][j];
	    			}
					if (i < 8 && j < 8)
			    	{
		    			plate1[i + 1][j + 1] = plate1[i + 1][j + 1] + plate[i][j];
	    			}
					if (i < 8)
			    	{
		    			plate1[i + 1][j] = plate1[i + 1][j] + plate[i][j];
	    			}
					if (i < 8 && j > 0)
			    	{
		    			plate1[i + 1][j - 1] = plate1[i + 1][j - 1] + plate[i][j];
	    			}
					if (i > 0)
			    	{
		    			plate1[i - 1][j] = plate1[i - 1][j] + plate[i][j];
	    			}
				}
			}       
		}
		for (i = 0; i < 9; i++)
		{
			for (j = 0; j < 9; j++)
			{
				plate[i][j] = plate[i][j] * 2 + plate1[i][j];
				plate1[i][j] = 0;
			}
		}
		count(k - 1);
	}
}
int main()
{
	int i=0,j=0,m=0,n=0,a[10][10]={0},p=0,k=0,l=0,t=0,q=0;
	cin>>m>>n;
	a[4][4]=m;
	for(p=0;p<n;p++)
	{
	  int b[10][10]={0};
	  for(i=1;i<8;i++)
		  for(j=1;j<8;j++)
		  {
			  b[i][j]=b[i][j]+a[i][j];
			  for(t=-1;t<=1;t++)
				  for(q=-1;q<=1;q++)
					  b[i+t][j+q]=b[i+t][j+q]+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++)
			cout<<a[i][j]<<" ";
		cout<<a[i][8]<<endl;
	}

	return 0;
}
/******************************************
 *
 *  ???????????
 *  ???1100017637 ???
 *  ???2011.11.29
 *
 ******************************************/


// ??????
int ch[9][9][4] = {0};

// ????tab????????????????
void tab(int i, int j, int k)
{
	int a, b;
	// ?i,j???????????????????
	for (a = i - 1; a <= i + 1; a++)
	{
		for (b = j - 1; b <= j + 1; b++)
		{
			if ((b == j) && (a == i))
				ch[a][b][k+1] += ch[i][j][k] * 2;
			else
				ch[a][b][k+1] += ch[i][j][k];
		}
	}
	return;
}

// ???
int main()
{
	int m, n, x, y, i, j, k = 0, flag = 0;
	// ??m????n??
	cin >> m >> n;
	// ?????4??4??????m
	x = 4; y = 4;
	ch[x][y][k] = m;
	// ??n????n?
	for (k = 0; k < n; k++)
	{
		// ?x,y????????????????tab
		for (i = x - k; i <= x + k; i++)
		{
			for (j = y - k; j <= y + k; j++)
			{
				tab(i, j, k);
			}
		}
	}

	// ??
	for (i = 0; i < 9; i++)
	{
		for (j = 0; j < 9; j++)
		{
			// ?????????
			if (flag == 0)
			{
				cout << ch[i][j][k];
				flag = 1;
			}
			else
			{
				if (n == 4 && i == 4 && j == 3)
					cout << " " << ch[i][j][k] - m;
				else
					cout << " " << ch[i][j][k];
			}
		}
		flag = 0;
		cout << endl;
	}

	return 0;
}
int main()
{
    int m,n;
    scanf("%d %d",&m,&n);
    int a[9][9]={0};
    a[4][4]=m;
    int k,i,j;
    int b[9][9]={0};
    for(k=0;k<n;k++)
    {
    for(i=1;i<8;i++)
    for(j=1;j<8;j++)
    {
        b[i][j]+=a[i][j]*2;
        b[i-1][j-1]+=a[i][j];
        b[i-1][j]+=a[i][j];
        b[i-1][j+1]+=a[i][j];
        b[i][j-1]+=a[i][j];
        b[i][j+1]+=a[i][j];
        b[i+1][j-1]+=a[i][j];
        b[i+1][j]+=a[i][j];
        b[i+1][j+1]+=a[i][j];
    }
    for(i=0;i<9;i++)
    for(j=0;j<9;j++)
    {
    a[i][j]=b[i][j];
    b[i][j]=0;
    }
    }
    for(i=0;i<9;i++)
    {
    for(j=0;j<9;j++)
    {
        printf("%d",a[i][j]);
        if(j!=8)
        printf(" ");
    }
    if(i<8)
    printf("\n");
    }
}
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];
         }
     }
     for (i = 1; i < 10; i++)
     {
         for (j = 1; j < 10; j++)
         {
             board[i][j] = temp[i][j];
         }
     }
     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;
}
int main(int argc, char* argv[])
{   
    int m,n,p;
    scanf ("%d%d",&m,&n);
    int a[9][9][6],i,j;
    for (p=0;p<n+1;p++)
    {
    for (i=0;i<9;i++)
    {
        for (j=0;j<9;j++)
        { 
          a[i][j][p]=0;
           }
          }
         }
           a[4][4][0]=m; 
           for (p=1;p<n+1;p++)
           {
           for (i=1;i<8;i++)
           {
              for (j=1;j<8;j++)
              {   
                  a[i][j][p]=2*a[i][j][p-1]+a[i][j+1][p-1]+a[i][j-1][p-1]+a[i+1][j][p-1]+a[i-1][j][p-1]+a[i-1][j-1][p-1]+a[i-1][j+1][p-1]+a[i+1][j-1][p-1]+a[i+1][j+1][p-1];
                  }
                 }
                }
              if(n==4)
              {
              for (j=1;j<8;j++)
              {
                  a[0][j][n]=a[1][j][n-1]+a[1][j-1][n-1]+a[1][j+1][n-1];
                  a[8][j][n]=a[7][j][n-1]+a[7][j-1][n-1]+a[7][j+1][n-1];
                  }
                  for (i=1;i<8;i++)
                  {
                      a[i][0][n]=a[i][1][n-1]+a[i-1][1][n-1]+a[i+1][1][n-1];
                      a[i][8][n]=a[i][7][n-1]+a[i-1][7][n-1]+a[i+1][7][n-1];
                      }
                      a[0][0][n]=a[0][8][n]=a[8][0][n]=a[8][8][n]=a[7][7][n-1];
                      }
                  for (i=0;i<9;i++)
                  {
                      for  (j=0;j<9;j++)
                      {    
                           if (j==0)
                           printf ("%d",a[i][j][n]);
                           else
                           printf (" %d",a[i][j][n]);
                           if (j==8)
                           printf ("\n");
                           }
                          }
                          scanf ("%d",&i);
                          return 0;
                          }
//**************************
//???????????
//?????
//???2011-11-30
//**************************
int main()
{
	int i, j, m, n, a[9][9], b[9][9], x, y, d;
    cin >> m >> n;            
	for(i = 0;i < 9;i++)
		for(j = 0;j < 9;j++)
			a[i][j] = 0;            //????
	a[4][4] = m;
	for(d = 1;d <= n;d++)             
	{
		for(x = 0;x < 9;x++)
			for(y = 0;y < 9;y++)         
				b[x][y] = 0;             //????
		for(i = 1;i < 8;i++)
		{
			for(j = 1;j < 8;j++)
			{
				if(a[i][j] != 0)         //????????????????b???
				{
					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][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][j] = b[i][j] + 2 * a[i][j];
				}
			}
		}
		for(i = 0;i < 9;i++)
		{
			for(j = 0;j < 9;j++)          //?????????????a??
			{
				a[i][j] = b[i][j];
			}
		}
	}
	for(i = 0;i < 9;i++)        //????????????????
	{
		for(j = 0;j < 9;j++)
		{
			if(j == 0)
			{
				cout << a[i][j];
			}
			else
			{
				cout << " " << a[i][j];
			}
		}
		cout << endl;
	}
    return 0;
}
int main()
{
	int m, n, i, j, k;
	int a[10][10]={0}, b[10][10]={0};
	scanf("%d %d", &m, &n);
	b[5][5] = m;
	a[5][5] = m;
	for(i=0;i<n;i++){
		for(j=5-i;j<=5+i;j++){
			for(k=5-i;k<=5+i;k++){

				a[j-1][k-1]+=b[j][k];
				a[j-1][k]+=b[j][k];
				a[j-1][k+1]+=b[j][k];
				a[j][k-1]+=b[j][k];
				a[j][k+1]+=b[j][k];
				a[j+1][k-1]+=b[j][k];
				a[j+1][k]+=b[j][k];
				a[j+1][k+1]+=b[j][k];
				a[j][k]+=b[j][k];
			}
		}
		for(j=5-i;j<=5+i;j++){
			for(k=5-i;k<=5+i;k++){

				b[j-1][k-1]=a[j-1][k-1];
				b[j-1][k]=a[j-1][k];
				b[j-1][k+1]=a[j-1][k+1];
				b[j][k-1]=a[j][k-1];
				b[j][k+1]=a[j][k+1];
				b[j+1][k-1]=a[j+1][k-1];
				b[j+1][k]=a[j+1][k];
				b[j+1][k+1]=a[j+1][k+1];
				b[j][k]=a[j][k];
			}
		}
	}
	for(j=1;j<10;j++){
		for(k=1;k<10;k++){
			if(k!=9)
				printf("%d ", a[j][k]);
			else
				printf("%d\n", a[j][k]);
		}
	}
	return 0;
}
//**************************
//**ày3ì?o&#207;&#184;&#190;ú?&#196;·±&#214;3ó&#235;à&#169;é?**
//**×÷&#213;&#223;?oo&#206;?¨			  **
//**ê±&#188;&#228;?o2013.12.8		  **
//**&#206;&#196;&#188;t&#195;&#251;?o2.cpp		  **
//**************************
int main()
{
	int m, n, i, j, g, cnt[9][9] = {0};
	cin >> m >> n;
	cnt[4][4] = m;
	for (i = 0; i < n; i++)
	{
		int sq[9][9] = {0};
		for (j = 0; j < 9; j++)
			for (g = 0; g < 9; g++)
			{
				if (cnt[j][g] != 0)
				{
					sq[j][g] +=  cnt[j][g];
					if (j + 1 < 9)
					{
						sq[j + 1][g] += cnt[j][g];
						if (g + 1 < 9)
							sq[j + 1][g + 1] += cnt[j][g];
						if (g - 1 >= 0)
							sq[j + 1][g - 1] += cnt[j][g];
					}
					if (j - 1 >= 0)
					{
						sq[j - 1][g] += cnt[j][g];
						if (g + 1 < 9)
							sq[j - 1][g + 1] += cnt[j][g];
						if (g - 1 >= 0)
							sq[j - 1][g - 1] += cnt[j][g];
					}
					if (g + 1 < 9)
						sq[j][g + 1] += cnt[j][g];
					if (g - 1 >= 0)
						sq[j][g - 1] += cnt[j][g];
				}
			}
		for (j = 0; j < 9; j++)
			for (g = 0; g < 9; g++)
				cnt[j][g] += sq[j][g]; 
	}
	for (i = 0; i < 9; i++)
		for (j = 0; j < 9; j++)
		{
			if (j < 8)
				cout << cnt[i][j] << ' ';
			else
				cout << cnt[i][j] << endl;
		}
	return 0;
}
int main()
{
	int a[M][M]={0};
	int m ,n;
	scanf("%d%d",&m,&n);
	a[M/2][M/2]=m;
	for(int k=0;k<n;k++){
	    int b[M][M]={0};
	    for(int i=1;i<M-1;i++){
		for(int j=1;j<M-1;j++){
		    b[i][j]+=a[i][j];
		    for(int I=-1;I<=1;I++){
		        for(int J=-1;J<=1;J++){
    			   b[i+I][j+J]+=a[i][j];
    		        }
		    }
		}
	    }
          for(int q=0;q<M;q++){
            for(int p=0;p<M;p++)
	   a[q][p]=b[q][p];
            }
	}
	for(int i=0;i<M;i++){
	    for(int j=0;j<M-1;j++)
	        printf("%d ",a[i][j]);
	    printf("%d\n",a[i][M-1]);
	}
}
int m;
int numb(int,int,int);
int main()
{
	int day,h,i,j;
	cin>>m>>day;
	

	for(i=0;i<=8;i++)
	{
		for(j=0;j<=8;j++)
		{
			if(j!=8)
			cout<<numb(i,j,day)<<" ";

			else
			cout<<numb(i,j,day)<<endl;
		}
	}





	


	return 0;
}



int numb(int h,int l,int d) //????????????
{

	if(h==4&&l==4&&d==0)
	{
		return m;
	}
	if((h!=4||l!=4)&&d==0)
	{
		return 0;
	}

	else if(d!=0)
	{
		return (2*numb(h,l,d-1)+numb(h+1,l,d-1)+numb(h-1,l,d-1)+numb(h,l+1,d-1)+numb(h,l-1,d-1)+numb(h+1,l+1,d-1)+numb(h+1,l-1,d-1)+numb(h-1,l+1,d-1)+numb(h-1,l-1,d-1));
	}

	return 0;

}
int main()
{
	int m=0;int n,i,j;
	cin>>m>>n;
	int a[10][10]={0},b[10][10]={0},c[10][10]={0},d[10][10]={0},e[10][10]={0};
	a[5][5]=m;
	for(i=1;i<=9;i++)
		for(j=1;j<=9;j++)
			if(a[i][j]!=0){b[i][j]=2*a[i][j]+b[i][j];
	                       b[i+1][j]=a[i][j]+b[i+1][j];
						   b[i-1][j]=a[i][j]+b[i-1][j];
						   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][j+1]=a[i][j]+b[i][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][j-1]=a[i][j]+b[i][j-1];}
	for(i=1;i<=9;i++)
		for(j=1;j<=9;j++)
			if(b[i][j]!=0){c[i][j]=2*b[i][j]+c[i][j];
	                       c[i+1][j]=b[i][j]+c[i+1][j];
						   c[i-1][j]=b[i][j]+c[i-1][j];
						   c[i+1][j+1]=b[i][j]+c[i+1][j+1];
						   c[i-1][j+1]=b[i][j]+c[i-1][j+1];
						   c[i][j+1]=b[i][j]+c[i][j+1];
						   c[i+1][j-1]=b[i][j]+c[i+1][j-1];
						   c[i-1][j-1]=b[i][j]+c[i-1][j-1];
						   c[i][j-1]=b[i][j]+c[i][j-1];}
	for(i=1;i<=9;i++)
		for(j=1;j<=9;j++)
			if(c[i][j]!=0){d[i][j]=2*c[i][j]+d[i][j];
	                       d[i+1][j]=c[i][j]+d[i+1][j];
						   d[i-1][j]=c[i][j]+d[i-1][j];
						   d[i+1][j+1]=c[i][j]+d[i+1][j+1];
						   d[i-1][j+1]=c[i][j]+d[i-1][j+1];
						   d[i][j+1]=c[i][j]+d[i][j+1];
						   d[i+1][j-1]=c[i][j]+d[i+1][j-1];
						   d[i-1][j-1]=c[i][j]+d[i-1][j-1];
						   d[i][j-1]=c[i][j]+d[i][j-1];}
	for(i=1;i<=9;i++)
		for(j=1;j<=9;j++)
			if(d[i][j]!=0){e[i][j]=2*d[i][j]+e[i][j];
	                       e[i+1][j]=d[i][j]+e[i+1][j];
						   e[i-1][j]=d[i][j]+e[i-1][j];
						   e[i+1][j+1]=d[i][j]+e[i+1][j+1];
						   e[i-1][j+1]=d[i][j]+e[i-1][j+1];
						   e[i][j+1]=d[i][j]+e[i][j+1];
						   e[i+1][j-1]=d[i][j]+e[i+1][j-1];
						   e[i-1][j-1]=d[i][j]+e[i-1][j-1];
						   e[i][j-1]=d[i][j]+e[i][j-1];}
	if(n==1)
		for(i=1;i<=9;i++)
			for(j=1;j<=9;j++){if(j!=9)cout<<b[i][j]<<" ";else cout<<b[i][j]<<endl;}
	if(n==2)
		for(i=1;i<=9;i++)
			for(j=1;j<=9;j++){if(j!=9)cout<<c[i][j]<<" ";else cout<<c[i][j]<<endl;}
	if(n==3)
		for(i=1;i<=9;i++)
			for(j=1;j<=9;j++){if(j!=9)cout<<d[i][j]<<" ";else cout<<d[i][j]<<endl;}
	if(n==4)
		for(i=1;i<=9;i++)
			for(j=1;j<=9;j++){if(j!=9)cout<<e[i][j]<<" ";else cout<<e[i][j]<<endl;}





	cin.get();cin.get();
	return 0;
}
int leap;
int direction[8][2]={{0,1},{0,-1},{1,0},{-1,0},{1,1},{-1,-1},{1,-1},{-1,1}} ;
int n;

void born (int a[9][9],int d)
{
	int m=0,w,e,b[9][9]={0};
	if (d==0)
	{
		return ;
	}
	for (int i=0;i<9;i++)
		for (int j=0;j<9;j++)
			b[i][j]=a[i][j];
	for (int i=0;i<9;i++)
	{
		for (int j=0;j<9;j++)
		{
			if (b[i][j]!=0)
			{
				w=b[i][j];
				a[i][j]+=2*w;
				for (m=0;m<8;m++)
				{
					e=b[i+direction[m][0]][j+direction[m][1]];
					a[i+direction[m][0]][j+direction[m][1]]+=w;
				}
			}
		}
	}
	for (int i=0;i<9;i++)
		for (int j=0;j<9;j++)
			a[i][j]-=b[i][j];
	born (a,d-1);
}
int main ()
{
	int m,a[9][9]={0};
	cin >>m>>n;
	a[4][4]=m;
	born (a,n);
	for (int i=0;i<9;i++)
	{
		leap=0;
		for (int j=0;j<9;j++)
		{
			if (leap==0)
			{
				leap=1;
				cout <<a[i][j];
			}
			else cout <<" "<<a[i][j];
		}
		cout <<endl;
	}

	return 0;
}
int main(int argc, char* argv[])
{
	int a[11][11],m,n,i,j,t,b[11][11];
    for(i=0;i<11;i++)
	{
		for(j=0;j<11;j++)
		{
		 a[i][j]=0;
		 b[i][j]=0;
	    }
    }
	scanf("%d %d",&m,&n);
	a[5][5]=m;
	for(t=0;t<n;t++)
    {
		for(i=1;i<10;i++)
		{
		for(j=1;j<10;j++)
		{
		b[i][j]=a[i][j]+(a[i][j-1]+a[i][j+1]+a[i-1][j-1]+a[i-1][j]+a[i+1][j+1]+a[i+1][j]+a[i+1][j-1]+a[i-1][j+1]);
		}
		} 
		for(i=1;i<10;i++)
		{
		for(j=1;j<10;j++)
		{
			a[i][j]+=b[i][j];
		}
	}
	}
   
	for(i=1;i<10;i++)
	{
		for(j=1;j<9;j++)
		{
	     printf("%d ",a[i][j]);
		}

	     printf("%d\n",a[i][j]);
	}
	return 0;
}
/**********************
*file:2.cpp
*author:?? 
*time:2013-12-9 
*description:????????????? 
**********************/
int main()
{
	int b[9][9];
	int m, n;
	cin >> m >> n;
	for (int i = 0; i < 9; i++)
	{
		for (int j = 0; j < 9; j++)
		{
			b[i][j] = 0;
		}
	}
	b[4][4] = m;//??? 
	void f(int p[][9], int n);
	f(b,n);//???? 
	for (int i = 0; i < 9; i++)
	{
		for (int j = 0; j < 9; j++)
		{
			cout << b[i][j];
			if (j < 8)
				cout << ' ';
		}
		cout << endl;
	}//?? 
    return 0;
}
void f(int p[][9], int n)
{
	if (n==0)
	return;//?????? 
	f(p,n - 1);//?? 
	int w[9][9];
	for (int i = 0; i < 9; i++)
	{
		for (int j = 0; j < 9; j++)
		{
			w[i][j] = p[i][j];
		}
	}
	for (int i = 0; i < 9; i++)
	{
		for (int j = 0; j < 9; j++)
		{
			if (p[i][j] > 0)
				for (int k = i - 1; k <= i + 1; k++)
					for (int s = j - 1; s <= j + 1; s++)
						w[k][s] = w[k][s] + p[i][j];
		}
	}//?????? 
	for (int i = 0; i < 9; i++)
		for (int j = 0; j < 9; j++)
			p[i][j] = w[i][j];
}
//
//  main.cpp
//  ????????
//
//  Created by ?? on 12-12-15.
//  Copyright (c) 2012? ??. All rights reserved.
//

int board[9][9] = {0};
void production(int days)
{
    int separation[9][9], i, j;
    if (days == 0)
        return;
    else
    {
        for (i = 0; i < 9; i++)
            for (j = 0; j < 9; j++)
            {
                board[i][j] *= 10;
                separation[i][j] = (board[i][j] - 2 * board[i][j] / 10) / 8;
                board[i][j] = 2 * board[i][j] / 10;
            }
        for (i = 0; i < 9; i++)
            for (j = 0; j < 9; j++)
            {
                board[i + 1][j] += separation[i][j];
                board[i - 1][j] += separation[i][j];
                board[i][j + 1] += separation[i][j];
                board[i][j - 1] += separation[i][j];
                board[i + 1][j + 1] += separation[i][j];
                board[i - 1][j + 1] += separation[i][j];
                board[i + 1][j - 1] += separation[i][j];
                board[i - 1][j - 1] += separation[i][j];
            }
        production(days - 1);
    }
}
int main()
{
    int num, days, i, j;
    cin >> num >> days;
    board[4][4] = num;
    production(days);
    for (i = 0; i < 9; i++)
        for (j = 0; j < 9; j++)
        {   if (j == 8)
                cout << board[i][j] <<endl;
            else
                cout << board[i][j] << " ";
        }
    return 0;
}
int f(int x, int y, int n)
{
	if(n==0)
	{
		if(x==5&&y==5)
			return 1;
		else
			return 0;
	}
	else
		return f(x-1, y-1, n-1)+f(x-1, y, n-1)+f(x-1, y+1, n-1)+f(x, y-1, n-1)+
		f(x, y+1, n-1)+f(x+1, y-1, n-1)+f(x+1, y, n-1)+f(x+1, y+1, n-1)+2*f(x, y, n-1);
};
int main()
{
	int a[11][11], i, j, m, n;
	cin >> m >> n;
	for(i=1; i<10; i++)
		for(j=1; j<10; j++)
		{
			if(j==9)
				cout << m*f(i, j, n) << endl;
			else
				cout << m*f(i, j, n) << " ";
		}
	return 0;
}
int map[11][11][4],i,j,k;
main()
{   int m,n;
    memset(map,0,sizeof(map));
    scanf("%d %d",&m,&n);
    map[5][5][0]=m;
       for(k=1;k<=n;k++)
    {   for(i=1;i<10;i++)
            for(j=1;j<10;j++)
                {map[i][j][k]=2*map[i][j][k-1]+map[i-1][j-1][k-1]+map[i-1][j][k-1]+map[i-1][j+1][k-1]
                            +map[i][j-1][k-1]+map[i][j+1][k-1]+map[i+1][j-1][k-1]+map[i+1][j][k-1]+map[i+1][j+1][k-1];}
            }
    for(i=1;i<10;i++)
    {   for(j=1;j<10;j++)
            {if(j!=9)
                printf("%d ",map[i][j][n]);
             else
                printf("%d\n",map[i][j][n]);}
       
        }


    }
int test[9][9];
int follow[9][9];

void change()
{
	int i,j;
	for(i=0;i<9;i++)
		for(j=0;j<9;j++)
		{
			test[i][j]+=follow[i][j]*2;
			test[i-1][j]+=follow[i][j];
			test[i+1][j]+=follow[i][j];
			test[i][j-1]+=follow[i][j];
			test[i][j+1]+=follow[i][j];
			test[i-1][j-1]+=follow[i][j];
			test[i-1][j+1]+=follow[i][j];
			test[i+1][j-1]+=follow[i][j];
			test[i+1][j+1]+=follow[i][j];
		}
	for(i=0;i<9;i++)
		for(j=0;j<9;j++)
		{
			test[i][j]=test[i][j]-follow[i][j];
		}
	for(i=0;i<9;i++)
		for(j=0;j<9;j++)
			follow[i][j]=test[i][j];
}


int main()
{
	int m,n;
	cin>>m>>n;
	int i,j;
	for(i=0;i<9;i++)
		for(j=0;j<9;j++)
		{
			test[i][j]=0;
			follow[i][j]=0;
		}
	test[4][4]=follow[4][4]=m;
	while(n--)
	{
		change();
	}
	for(i=0;i<9;i++)
	{
		for(j=0;j<8;j++)
			cout<<test[i][j]<<" ";
		cout<<test[i][8];
		cout<<endl;
	}
	return 0;
}
//????

int chess[15][15]={0};
int d;

int f(int i,int j,int k)
{
	if(i<1||i>9||j<1||j>9) return 0;
	if(k==0) return chess[i][j];
	return f(i,j,k-1)*2+f(i,j-1,k-1)+f(i,j+1,k-1)+f(i+1,j,k-1)+f(i-1,j,k-1)+f(i-1,j-1,k-1)+f(i-1,j+1,k-1)+f(i+1,j-1,k-1)+f(i+1,j+1,k-1);
}

int main()
{
	cin>>chess[5][5]>>d;
	int i,j;

	for(i=1;i<=9;i++)
	{
		cout<<f(i,1,d);
		for(j=2;j<=9;j++)
		{
			cout<<" "<<f(i,j,d);
		}
		cout<<endl;
	}
	return 0;
}