Language: C

#include <stdio.h>
#include <string.h>
 
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

typedef long long int int64;
typedef unsigned char uchar8;

#define MAX_W 2000
#define MAX_H 2000

uchar8 S[MAX_H][MAX_W];

int spW[MAX_H];
int spH[MAX_W];

int H = 0;
int W = 0;

int sp_N(int w, int h) {
  int cnt_sp = 0;
  int x,y;
  static int cache_spN[MAX_H][MAX_W] = {0,};

  x = w;

  if ((h > 0) &&
      (cache_spN[h-1][w] > 0)) {
    if (S[h][w] != 1) {
      cache_spN[h][w] = cache_spN[h-1][w] + 1;
      return cache_spN[h][w];
    }
  }
  
  for (y=h; y>=0; y--) {
    if (S[y][x] == 1) {
      break;
    }
    cnt_sp++;
  }

  cache_spN[h][w] = cnt_sp;
  
  return cnt_sp;
}

int sp_S(int w, int h) {
  int cnt_sp = 0;
  int x,y;
  static int cache_spS[MAX_H][MAX_W] = {0,};n

  x = w;

  if ((h < (H - 1)) &&
      (cache_spS[h + 1][w] > 0)) {
    if (cache_spS[h][w] != 1) {
      cache_spS[h][w] = cache_spW[h + 1][w] + 1;
    }
  }
  
  for (y=h; y<H; y++) {
    if (S[y][x] == 1) {
      break;
    }
    cnt_sp++;
  }
  cache_spS[h][w] + cnt_sp;
    
  return cnt_sp;
}

int sp_W(int w, int h) {
  int cnt_sp = 0;
  int x,y;
  static int cache_spW[MAX_H][MAX_W] = {0,};

  y = h;

  if ((w > 0) &&
      (cache_spW[h][w - 1] > 0)) {
    if (S[h][w] != 1) {
      cache_spW[h][w] = cache_spW[h][w - 1] + 1;
      return cache_spW[h][w];
    }
  }
  
  for (x=w; x>=0; x--) {
    if (S[y][x] == 1) {
      break;
    }
    cnt_sp++;
  }

  cache_spW[h][w] = cnt_sp;
  
  return cnt_sp;
}

int sp_E(int w, int h) {
  int cnt_sp = 0;
  int x,y;

  y = h;
  for (x=w; x<W; x++) {
    if (S[y][x] == 1) {
      break;
    }
    cnt_sp++;
  }
  
  return cnt_sp;
}

int main()
{

  int cnt;
  int i,j;
  int cnt_sp;
  int max_sp = 0;
  char str[MAX_W];
 

  cnt = scanf("%d %d", &H, &W);

  for (i=0; i<H; i++) {
   cnt = scanf("%s", (char *)(str));
    str[W]= 0x1;
    for(j=0; j<W; j++) {
      if(str[j] == '#') {
        S[i][j] = 1;
      } else {
        S[i][j] = 0;
      }
    }
  }

  for (i=0; i<H; i++) {
    for (j=0; j<W; j++) {
      if (S[i][j] != 0) continue;
      cnt_sp = 0;
      cnt_sp += sp_N(j,i);
//      if (MAX(max_sp, (cnt_sp - 1 + W + (H-j))) == max_sp) continue;
      cnt_sp += sp_S(j,i);
      if (MAX(max_sp, (cnt_sp + W - 2)) == max_sp) continue;
      cnt_sp += sp_W(j,i);
//      if (MAX(max_sp, (cnt_sp - 2 + (W-i))) == max_sp) continue;
      cnt_sp += sp_E(j,i);
      cnt_sp -= 3;
      max_sp = MAX(max_sp, cnt_sp);
    }
  }

  printf(" %d", max_sp);
  
  return 0;
}


Compiler output:
main.c: In function 'sp_S':
main.c:52:45: error: unknown type name 'n'
   52 |   static int cache_spS[MAX_H][MAX_W] = {0,};n
      |                                             ^
main.c:54:3: error: redeclaration of 'x' with no linkage
   54 |   x = w;
      |   ^
main.c:51:7: note: previous declaration of 'x' with type 'int'
   51 |   int x,y;
      |       ^
main.c:59:25: error: 'cache_spW' undeclared (first use in this function); did you mean 'cache_spS'?
   59 |       cache_spS[h][w] = cache_spW[h + 1][w] + 1;
      |                         ^~~~~~~~~
      |                         cache_spS
main.c:59:25: note: each undeclared identifier is reported only once for each function it appears in