Language: C++

/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> table(H, vector<char>(W));

    for (int i = 0; i < H; i++) {
        string line;
        cin >> line;
        for (int j = 0; j < W; j++) {
            table[i][j] = line[j];
        }
    }

    vector<set<P>> row_ranges(H);
    vector<set<P>> col_ranges(W);

    for (int i = 0; i < H; i++) {
        bool valid = false;
        int start;

        for (int j = 0; j < W; j++) {
            if (table[i][j] == '#') {
                if (valid) {
                    row_ranges[i].insert(P(j - 1, start));
                }
                valid = false;
            } else {
                if (!valid) {
                    valid = true;
                    start = j;
                }
            }
        }

        if (valid) row_ranges[i].insert(P(W - 1, start));
    }

    for (int j = 0; j < W; j++) {
        bool valid = false;
        int start;

        for (int i = 0; i < H; i++) {
            if (table[i][j] == '#') {
                if (valid) {
                    col_ranges[j].insert(P(i - 1, start));
                }
                valid = false;
            } else {
                if (!valid) {
                    valid = true;
                    start = i;
                }
            }
        }
    }

    int ret = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            P p1 = row_ranges[i].lower_bound(j);
            P p2 = col_ranges[j].lower_bound(i);
            int num = (p1.first - p1.second + 1) + (p2.first - p2.second + 1) - 1;
            ret = max(ret, num);
        }
    }
    cout << ret << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:102:45: error: no matching function for call to 'std::set<std::pair<long long int, long long int> >::lower_bound(ll&)'
  102 |             P p1 = row_ranges[i].lower_bound(j);
      |                    ~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/14/set:63,
                 from a.cc:23:
/usr/include/c++/14/bits/stl_set.h:841:9: note: candidate: 'template<class _Kt> decltype ((std::set<_Key, _Compare, _Alloc>::iterator)(((std::set<_Key, _Compare, _Alloc>*)this)->std::set<_Key, _Compare, _Alloc>::_M_t._M_lower_bound_tr(__x))) std::set<_Key, _Compare, _Alloc>::lower_bound(const _Kt&) [with _Key = std::pair<long long int, long long int>; _Compare = std::less<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::pair<long long int, long long int> >]'
  841 |         lower_bound(const _Kt& __x)
      |         ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_set.h:841:9: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_set.h: In substitution of 'template<class _Kt> decltype ((std::set<std::pair<long long int, long long int> >::iterator)(((std::set<std::pair<long long int, long long int> >*)this)->std::set<std::pair<long long int, long long int> >::_M_t.std::_Rb_tree<std::pair<long long int, long long int>, std::pair<long long int, long long int>, std::_Identity<std::pair<long long int, long long int> >, std::less<std::pair<long long int, long long int> >, std::allocator<std::pair<long long int, long long int> > >::_M_lower_bound_tr(__x))) std::set<std::pair<long long int, long long int> >::lower_bound(const _Kt&) [with _Kt = long long int]':
a.cc:102:45:   required from here
  102 |             P p1 = row_ranges[i].lower_bound(j);
      |                    ~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_set.h:842:52: error: no matching function for call to 'std::_Rb_tree<std::pair<long long int, long long int>, std::pair<long long int, long long int>, std::_Identity<std::pair<long long int, long long int> >, std::less<std::pair<long long int, long long int> >, std::allocator<std::pair<long long int, long long int> > >::_M_lower_bound_tr(const long long int&)'
  842 |         -> decltype(iterator(_M_t._M_lower_bound_tr(__x)))
      |                              ~~~~~~~~~~~~~~~~~~~~~~^~~~~
In file included from /usr/include/c++/14/map:62,
                 from a.cc:20:
/usr/include/c++/14/bits/stl_tree.h:1320:9: note: candidate: 'template<class _Kt, class _Req> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_lower_bound_tr(const _Kt&) [with _Req = _Kt; _Key = std::pair<long long int, long long int>; _Val = std::pair<long long int, long long int>; _KeyOfValue = std::_Identity<std::pair<long long int, long long int> >; _Compare = std::less<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::pair<long long int, long long int> >]'
 1320 |         _M_lower_bound_tr(const _Kt& __k)
      |         ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:1320:9: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/14/string:49,
                 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/istream:40,
                 from /usr/include/c++/14/fstream:40,
                 from a.cc:4:
/usr/include/c++/14/bits/stl_function.h: In substitution of 'template<class _Func, class _SfinaeType> using std::__has_is_transparent_t = typename std::__has_is_transparent<_Func, _SfinaeType>::type [with _Func = std::less<std::pair<long long int, long long int> >; _SfinaeType = long long int]':
/usr/include/c++/14/bits/stl_tree.h:1318:9:   required by substitution of 'template<class _Kt> decltype ((std::set<std::pair<long long int, long long int> >::iterator)(((std::set<std::pair<long long int, long long int> >*)this)->std::set<std::pair<long long int, long long int> >::_M_t.std::_Rb_tree<std::pair<long long int, long long int>, std::pair<long long int, long long int>, std::_Identity<std::pair<long long int, long long int> >, std::less<std::pair<long long int, long long int> >, std::allocator<std::pair<long long int, long long int> > >::_M_lower_bound_tr(__x))) std::set<std::pair<long long int, long long int> >::lower_bound(const _Kt&) [with _Kt = long long int]'
 1318 |                typename _Req = __has_is_transparent_t<_Compare, _Kt>>
      |                ^~~~~~~~
a.cc:102:45:   required from here
  102 |             P p1 = row_ranges[i].lower_bound(j);
      |                    ~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_function.h:1427:11: error: no type named 'type' in 'struct std::__has_is_transparent<std::less<std::pair<long long int, long long int> >, long long int, void>'
 1427 |     using __has_is_transparent_t
      |           ^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_set.h: In substitution of 'template<class _Kt> decltype ((std::set<std::pair<long long int, long long int> >::iterator)(((std::set<std::pair<long long int, long long int> >*)this)->std::set<std::pair<long long int, long long int> >::_M_t.std::_Rb_tree<std::pair<long long int, long long int>, std::pair<long long int, long long int>, std::_Identity<std::pair<long long int, long long int> >, std::less<std::pair<long long int, long long int> >, std::allocator<std::pair<long long int, long long int> > >::_M_lower_bound_tr(__x))) std::set<std::pair<long long int, long long int> >::lower_bound(const _Kt&) [with _Kt = long long int]':
a.cc:102:45:   required from here
  102 |             P p1 = row_ranges[i].lower_bound(j);
      |                    ~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_tree.h:1329:9: note: candidate: 'template<class _Kt, class _Req> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_lower_bound_tr(const _Kt&) const [with _Req = _Kt; _Key = std::pair<long long int, long long int>; _Val = std::pair<long long int, long long int>; _KeyOfValue = std::_Identity<std::pair<long long int, long long int> >; _Compare = std::less<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::pair<long long int, long long int> >]'
 1329 |         _M_lower_bound_tr(const _Kt& __k) const
      |         ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:1329:9: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_set.h:847:9: note: candidate: 'template<class _Kt> decltype ((std::set<_Key, _Compare, _Alloc>::const_iterator)(((const std::set<_Key, _Compare, _Alloc>*)this)->std::set<_Key, _Compare, _Alloc>::_M_t._M_lower_bound_tr(__x))) std::set<_Key, _Compare, _Alloc>::lower_bound(const _Kt&) const [with _Key = std::pair<long long int, long long int>; _Compare = std::less<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::pair<long long int, long long int> >]'
  847 |         lower_bound(const _Kt& __x) const
      |         ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_set.h:847:9: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_set.h: In substitution of 'template<class _Kt> decltype ((std::set<std::pair<long long int, long long int> >::const_iterator)(((const std::set<std::pair<long long int, long long int> >*)this)->std::set<std::pair<long long int, long long int> >::_M_t.std::_Rb_tree<std::pair<long long int, long long int>, std::pair<long long int, long long int>, std::_Identity<std::pair<long long int, long long int> >, std::less<std::pair<long long int, long long int> >, std::allocator<std::pair<long long int, long long int> > >::_M_lower_bound_tr(__x))) std::set<std::pair<long long int, long long int> >::lower_bound(const _Kt&) const [with _Kt = long long int]':
a.cc:102:45:   required from here
  102 |             P p1 = row_ranges[i].lower_bound(j);
      |                    ~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_set.h:848:58: error: no matching function for call to 'std::_Rb_tree<std::pair<long long int, long long int>, std::pair<long long int, long long int>, std::_Identity<std::pair<long long int, long long int> >, std::less<std::pair<long long int, long long int> >, std::allocator<std::pair<long long int, long long int> > >::_M_lower_bound_tr(const long long int&) const'
  848 |         -> decltype(const_iterator(_M_t._M_lower_bound_tr(__x)))
      |                                    ~~~~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/stl_tree.h:1320:9: note: candidate: 'template<class _Kt, class _Req> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_lower_bound_tr(const _Kt&) [with _Req = _Kt; _Key = std::pair<long long int, long long int>; _Val = std::pair<long long int, long long int>; _KeyOfValue = std::_Identity<std::pair<long long int, long long int> >; _Compare = std::less<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::pair<long long int, long long int> >]'
 1320 |         _M_lower_bound_tr(const _Kt& __k)
      |         ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:1320:9: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_tree.h:1329:9: note: candidate: 'template<class _Kt, class _Req> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_lower_bound_tr(const _Kt&) const [with _Req = _Kt; _Key = std::pair<long long int, long long int>; _Val = std::pair<long long int, long long int>; _KeyOfValue = std::_Identity<std::pair<long long int, long long int> >; _Compare = std::less<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::pair<long long int, long long int> >]'
 1329 |         _M_lower_bound_tr(const _Kt& __k) const
      |         ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:1329:9: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_set.