Language: C++

// #include <iostream>
// #include <algorithm>
// using namespace std;
// int res[2000*2000];
// int main () {
//     int n, m, index = 0, temp, sum;
//     cin >> n >> m;
//     char a[n][m];
//     for (int i = 0; i < n; i++) {
//         for (int j = 0; j < m; j++) cin >> a[i][j];
//     }
//     for (int i = 0; i < n; i++) {
//         for (int j = 0; j < m; j++) {
//             sum = 0;
//             if (a[i][j] != '#') {
//                 temp = j;
//                 while (a[i][temp] != '#' && temp >= 0) {sum++; temp--;}
//                 temp = j;
//                 while (a[i][temp] != '#' && temp < m) {sum++; temp++;}
//                 temp = i;
//                 while (a[temp][j] != '#' && temp < n) {sum++; temp++;}
//                 temp = i;
//                 while (a[temp][j] != '#' && temp >= 0) {sum++; temp--;}
//                 sum -= 3;
//                 res[index] = sum;
//                 index++;
//             }
//         }
//     }
//     sort(res, res+index+1);
//     cout << res[index] << endl;
//     return 0;
// }

#include <iostream>
using namespace std;

int l[2000][2000], r[2000][2000], up[2000][2000], down[2000][2000];
char data[2000][2000];

int main () {
    int h, w, temp = 0, res = 0;
    cin >> h >> w;
    for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) cin >> data[i][j];
    for (int i = 0; i < h; i++) {
        temp = 0;
        for (int j = 0; j < w; j++) l[i][j] = (data[i][j] == '#') ? temp = 0 : ++temp;
    }
    for (int i = 0; i < h; i++) {
        temp = 0;
        for (int j = w-1; j >= 0; j--) r[i][j] = (data[i][j] == '#') ? temp = 0 : ++temp;
    }
    for (int i = 0; i < w; i++) {
        temp = 0;
        for (int j = 0; j < h; j++) up[j][i] = (data[j][i] == '#') ? temp = 0 : ++temp;
    }
    for (int i = 0; i < w; i++) {
        temp = 0;
        for (int j = h-1; j >= 0; j--) down[j][i] = (data[j][i] == '#') ? temp = 0 : ++temp;
    }
    for (int i = 0; i < h; i++) {
        temp = 0;
        for (int j = 0; j < w; j++) if (data[i][j] != '#') res = max(res, l[i][j] + r[i][j] + up[i][j] + down[i][j] - 3);
    }
    cout << res << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:68: error: reference to 'data' is ambiguous
   44 |     for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) cin >> data[i][j];
      |                                                                    ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:35:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:39:6: note:                 'char data [2000][2000]'
   39 | char data[2000][2000];
      |      ^~~~
a.cc:47:48: error: reference to 'data' is ambiguous
   47 |         for (int j = 0; j < w; j++) l[i][j] = (data[i][j] == '#') ? temp = 0 : ++temp;
      |                                                ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:39:6: note:                 'char data [2000][2000]'
   39 | char data[2000][2000];
      |      ^~~~
a.cc:51:51: error: reference to 'data' is ambiguous
   51 |         for (int j = w-1; j >= 0; j--) r[i][j] = (data[i][j] == '#') ? temp = 0 : ++temp;
      |                                                   ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:39:6: note:                 'char data [2000][2000]'
   39 | char data[2000][2000];
      |      ^~~~
a.cc:55:49: error: reference to 'data' is ambiguous
   55 |         for (int j = 0; j < h; j++) up[j][i] = (data[j][i] == '#') ? temp = 0 : ++temp;
      |                                                 ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:39:6: note:                 'char data [2000][2000]'
   39 | char data[2000][2000];
      |      ^~~~
a.cc:59:54: error: reference to 'data' is ambiguous
   59 |         for (int j = h-1; j >= 0; j--) down[j][i] = (data[j][i] == '#') ? temp = 0 : ++temp;
      |                                                      ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:39:6: note:                 'char data [2000][2000]'
   39 | char data[2000][2000];
      |      ^~~~
a.cc:63:41: error: reference to 'data' is ambiguous
   63 |         for (int j = 0; j < w; j++) if (data[i][j] != '#') res = max(res, l[i][j] + r[i][j] + up[i][j] + down[i][j] - 3);
      |                                         ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:39:6: note:                 'char data [2000][2000]'
   39 | char data[2000][2000];
      |      ^~~~