Problem p03014 (C++)

Buggy submission (status: Runtime Error):
// i ll be the king
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define sync                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL)
#define input(arr, n)                                                          \
  for (ll i1 = 0; i1 < n; i1++)                                                \
  cin >> arr[i1]
#define rep(n) for (ll i2 = 0; i2 < n; i2++)
#define vmp(v, a, b) v.push_back(make_pair(a, b))
#define si(a) scanf("%lld", &a)
#define pi(a) printf("%lld", a)
#define aset(a, n, k)                                                          \
  for (ll i3 = 0; i3 < n; i3++)                                                \
    a[i3] = k;
#define mod 1000000007
#define mp(a, b) make_pair(a, b)
#define f first
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set                                                            \
  tree<ll, null_type, greater_equal<ll>, rb_tree_tag,                          \
       tree_order_statistics_node_update> // s.order_of_key(val)
                                          // *s.find_by_orde(ind)
using namespace std;
ll vis[1003][1003];
string s[1003];
int main() {
  sync;
  ll n, m;
  cin >> n >> m;
  input(s, n);
  for (ll i = 0; i < n; i++) {
    ll cnt = 0;
    for (ll j = 0; j < m; j++) {
      if (s[i][j] == '#')
        cnt = 0;
      else {
        cnt++;
        vis[i][j] = cnt;
      }
    }
    cnt = 0;
    for (ll j = m - 1; j >= 0; j--) {
      if (s[i][j] == '#')
        cnt = 0;
      else {
        vis[i][j] += cnt;
        cnt++;
      }
    }
  }
  // col
  for (ll i = 0; i < m; i++) {
    ll cnt = 0;
    for (ll j = 0; j < n; j++) {
      if (s[j][i] == '#')
        cnt = 0;
      else {
        vis[j][i] += cnt;
        cnt++;
      }
    }
    cnt = 0;
    for (ll j = n - 1; j >= 0; j--) {
      if (s[j][i] == '#')
        cnt = 0;
      else {
        vis[j][i] += cnt;
        cnt++;
      }
    }
  }
  ll ans = 0;
  for (ll i = 0; i < n; i++)
    for (ll j = 0; j < m; j++)
      ans = max(ans, vis[i][j]);
  cout << ans;
}

Fixed submission:
// i ll be the king
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define sync                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL)
#define input(arr, n)                                                          \
  for (ll i1 = 0; i1 < n; i1++)                                                \
  cin >> arr[i1]
#define rep(n) for (ll i2 = 0; i2 < n; i2++)
#define vmp(v, a, b) v.push_back(make_pair(a, b))
#define si(a) scanf("%lld", &a)
#define pi(a) printf("%lld", a)
#define aset(a, n, k)                                                          \
  for (ll i3 = 0; i3 < n; i3++)                                                \
    a[i3] = k;
#define mod 1000000007
#define mp(a, b) make_pair(a, b)
#define f first
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set                                                            \
  tree<ll, null_type, greater_equal<ll>, rb_tree_tag,                          \
       tree_order_statistics_node_update> // s.order_of_key(val)
                                          // *s.find_by_orde(ind)
using namespace std;
ll vis[2003][2003];
string s[2003];
int main() {
  sync;
  ll n, m;
  cin >> n >> m;
  input(s, n);
  for (ll i = 0; i < n; i++) {
    ll cnt = 0;
    for (ll j = 0; j < m; j++) {
      if (s[i][j] == '#')
        cnt = 0;
      else {
        cnt++;
        vis[i][j] = cnt;
      }
    }
    cnt = 0;
    for (ll j = m - 1; j >= 0; j--) {
      if (s[i][j] == '#')
        cnt = 0;
      else {
        vis[i][j] += cnt;
        cnt++;
      }
    }
  }
  // col
  for (ll i = 0; i < m; i++) {
    ll cnt = 0;
    for (ll j = 0; j < n; j++) {
      if (s[j][i] == '#')
        cnt = 0;
      else {
        vis[j][i] += cnt;
        cnt++;
      }
    }
    cnt = 0;
    for (ll j = n - 1; j >= 0; j--) {
      if (s[j][i] == '#')
        cnt = 0;
      else {
        vis[j][i] += cnt;
        cnt++;
      }
    }
  }
  ll ans = 0;
  for (ll i = 0; i < n; i++)
    for (ll j = 0; j < m; j++)
      ans = max(ans, vis[i][j]);
  cout << ans;
}