Language: C++

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
 
using namespace std;
char Map[1005][1005]={0};
int con1[1005][1005]={0};
int con2[1005][1005]={0};
int main()
{
    int N,M,ans=0,i,j,k,x1,y1,x2,y2;
    scanf("%d %d\n",&N,&M);
    for(i=301;i<N;i++)
    {
        fgets(Map[i]+301,1000,stdin);
    }
    for(i=301;i-301<N;i++)
    {
    	for(j=301;j-301<M;j++)
    	{
    		con1[i][j]=(Map[i][j]=='#');
    		con2[i][j]=(Map[i][j]=='#');
    		con1[i][j]+=con1[i-1][j-1];
    		con1[i][j]+=con2[i-1][j+1];
		}
	}
    for(i=301;i-301<N;i++)
    {
    	for(j=301;j-301<M;j++)
    	{
    		if(Map[i][j]=='.') continue;
    		for(k=1;i+k<N+301||j-k>=301;k++)
    		{
    			ans+=con2[i+2*k][j]-[i+k][j+k]+(Map[i+2*k][j]=='#');
    			ans+=con2[i][j-2*k]-[i-k][j-k]+(Map[i][j-2*k]=='#');
			}
			
			for(k=2;i+k<N+301||j+k<M+301;k++)
    		{
    			ans+=con1[i+k-1][j+k-1]-[i-k+1][j-k+1]+(Map[i+k-1][j-k+1]=='#');
    			ans+=con2[i+2*k-1][j-1]-[i+k+1][j-k+1]+(Map[i+2*k][j]=='#');
			}
			
		}
	}
 	printf("%d\n",ans);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:47: error: expected ',' before '+' token
   34 |                         ans+=con2[i+2*k][j]-[i+k][j+k]+(Map[i+2*k][j]=='#');
      |                                               ^
      |                                               ,
a.cc:34:47: error: expected identifier before '+' token
a.cc: In lambda function:
a.cc:34:50: error: expected '{' before '[' token
   34 |                         ans+=con2[i+2*k][j]-[i+k][j+k]+(Map[i+2*k][j]=='#');
      |                                                  ^
a.cc: In function 'int main()':
a.cc:34:50: error: no match for 'operator[]' (operand types are 'main()::<lambda()>' and 'int')
a.cc:35:47: error: expected ',' before '-' token
   35 |                         ans+=con2[i][j-2*k]-[i-k][j-k]+(Map[i][j-2*k]=='#');
      |                                               ^
      |                                               ,
a.cc:35:47: error: expected identifier before '-' token
a.cc: In lambda function:
a.cc:35:50: error: expected '{' before '[' token
   35 |                         ans+=con2[i][j-2*k]-[i-k][j-k]+(Map[i][j-2*k]=='#');
      |                                                  ^
a.cc: In function 'int main()':
a.cc:35:50: error: no match for 'operator[]' (operand types are 'main()::<lambda()>' and 'int')
a.cc:40:51: error: expected ',' before '-' token
   40 |                         ans+=con1[i+k-1][j+k-1]-[i-k+1][j-k+1]+(Map[i+k-1][j-k+1]=='#');
      |                                                   ^
      |                                                   ,
a.cc:40:51: error: expected identifier before '-' token
a.cc: In lambda function:
a.cc:40:56: error: expected '{' before '[' token
   40 |                         ans+=con1[i+k-1][j+k-1]-[i-k+1][j-k+1]+(Map[i+k-1][j-k+1]=='#');
      |                                                        ^
a.cc: In function 'int main()':
a.cc:40:56: error: no match for 'operator[]' (operand types are 'main()::<lambda()>' and 'int')
a.cc:41:51: error: expected ',' before '+' token
   41 |                         ans+=con2[i+2*k-1][j-1]-[i+k+1][j-k+1]+(Map[i+2*k][j]=='#');
      |                                                   ^
      |                                                   ,
a.cc:41:51: error: expected identifier before '+' token
a.cc: In lambda function:
a.cc:41:56: error: expected '{' before '[' token
   41 |                         ans+=con2[i+2*k-1][j-1]-[i+k+1][j-k+1]+(Map[i+2*k][j]=='#');
      |                                                        ^
a.cc: In function 'int main()':
a.cc:41:56: error: no match for 'operator[]' (operand types are 'main()::<lambda()>' and 'int')