alexjercan/bugnet huggingface dataset:
Problem p00116 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <vector>

using namespace std;

int H, W;

void solve() {
  vector<string> map(H);
  vector<vector<int>> sum(H, vector<int>(W + 1, 0));
  int ans = 0;

  for (int i = 0; i < H; i++)
    cin >> map[i];

  for (int i = 0; i < H; i++) {
    for (int j = W - 1; j >= 0; j--) {
      if (map[i][j] == '*')
        sum[i][j] = 0;
      else
        sum[i][j] = sum[i][j + 1] + 1;
    }
  }

  for (int i = 0; i < H; i++)
    for (int j = 0; j < W; j++) {
      if (map[i][j] == '.') {
        int w = sum[i][j], h = 1;
        int area = w * h;

        while (h + i < H && map[h + i][j] == '.') {
          w = min(w, sum[h + i][j]);
          h++;
          area = max(area, h * w);
        }
        ans = max(ans, area);
      }
    }
  cout << ans << endl;
}

int main() {
  while (cin >> H >> W, H || W) {
    solve();
  }

  return 0;
}

Error: 0
...*....**
..........
**....**..
........*.
..*.......
**........
.*........
..........
....*..***
.*....*...
..*....*..
.*.*...*..
*****..*..
*...*..*..
*...*..*..
..........
****.*...*
..*..*...*
.*...*...*
****..***.
...
...


Fixed submission:

#include <iostream>
#include <vector>

using namespace std;

int H, W;

void solve() {
  vector<string> map(H);
  int ans = 1;

  for (int i = 0; i < H; i++)
    cin >> map[i];
  for (int i = 0; i < map.size(); i++)
    cerr << map[i] << endl;

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (map[i][j] == '.') {
        map[i][j] = '*';
        int tw = 1, th = 1;
        bool flag = true;

        while (map[i][tw + j] == '.') {
          map[i][tw + j] = '*';
          tw++;
        }

        while (i + th < H && flag) {
          for (int k = 0; k < tw; k++)
            if (map[i + th][j + k] != '.') {
              flag = false;
              break;
            }
          if (flag)
            th++;
        }

        if (th * tw > ans)
          ans = th * tw;
      }
    }
  }
  cout << ans << endl;
}

int main() {
  while (cin >> H >> W, H || W) {
    solve();
  }

  return 0;
}
Problem p00116 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int h, w;

  while (1) {
    cin >> h >> w;
    if (!h && !w)
      break;

    vector<string> grid;
    for (int i = 0; i < h; i++) {
      string tmp;
      cin >> tmp;
      grid.push_back(tmp);
    }

    int ans = 0;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (grid[i][j] == '.') {
          int x = w;
          int tmp = 0;
          for (int k = i; k < h; k++) {
            if (grid[k][j] == '*')
              break;
            int l;
            for (l = j; l < x; l++) {
              if (grid[k][l] == '*') {
                x = min(x, l);
                break;
              }
            }
            tmp = max(tmp, (x - j) * (k - i + 1));
          }
          ans = max(ans, tmp);
        }
      }
    }
    cout << ans << endl;
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int h, w;

  while (1) {
    cin >> h >> w;
    if (!h && !w)
      break;

    vector<string> grid;
    for (int i = 0; i < h; i++) {
      string tmp;
      cin >> tmp;
      grid.push_back(tmp);
    }

    int ans = 0;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (grid[i][j] == '.') {
          int x = w;
          int tmp = 0;
          for (int k = i; k < h; k++) {
            if (grid[k][j] == '*')
              break;
            int l;
            for (l = j; l < w; l++) {
              if (grid[k][l] == '*') {
                x = min(x, l);
                break;
              }
            }
            tmp = max(tmp, (x - j) * (k - i + 1));
          }
          ans = max(ans, tmp);
        }
      }
    }
    cout << ans << endl;
  }
}
Problem p00116 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define int long long

int getS(vector<int> &H) {
  int N = H.size();
  vector<int> L(N), R(N);
  stack<int> S;
  for (int i = 0; i < N; i++) {
    while (!S.empty() && H[i] <= H[S.top()])
      S.pop();
    L[i] = S.empty() ? 0 : (S.top() + 1);
    S.push(i);
  }
  S = stack<int>();
  for (int i = N - 1; i >= 0; i--) {
    while (!S.empty() && H[i] <= H[S.top()])
      S.pop();
    R[i] = S.empty() ? N : S.top();
    S.push(i);
  }
  int ma = 0;
  for (int i = 0; i < N; i++)
    ma = max(ma, (R[i] - L[i]) * H[i]);
  return ma;
}

int H, W;
vector<int> V[500];
void solve() {
  fill_n(V, H, vector<int>(W, 0));
  int ma = 0;
  for (int i = 0; i < H; i++) {
    char fld[510];
    cin >> fld;
    for (int j = 0; j < W; j++) {
      if (fld[j] == '*')
        continue;
      V[i][j] = (i ? V[i - 1][j] : 0) + 1;
    }
    ma = max(ma, getS(V[i]));
  }
  cout << ma << endl;
}
signed main() {
  while (cin >> H >> W, H || W)
    solve();
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define int long long

int getS(vector<int> &H) {
  int N = H.size();
  vector<int> L(N), R(N);
  stack<int> S;
  for (int i = 0; i < N; i++) {
    while (!S.empty() && H[i] <= H[S.top()])
      S.pop();
    L[i] = S.empty() ? 0 : (S.top() + 1);
    S.push(i);
  }
  S = stack<int>();
  for (int i = N - 1; i >= 0; i--) {
    while (!S.empty() && H[i] <= H[S.top()])
      S.pop();
    R[i] = S.empty() ? N : S.top();
    S.push(i);
  }
  int ma = 0;
  for (int i = 0; i < N; i++)
    ma = max(ma, (R[i] - L[i]) * H[i]);
  return ma;
}

int H, W;
vector<int> V[300];
void solve() {
  fill_n(V, H, vector<int>(W, 0));
  int ma = 0;
  for (int i = 0; i < H; i++) {
    char fld[510];
    cin >> fld;
    for (int j = 0; j < W; j++) {
      if (fld[j] == '*')
        continue;
      V[i][j] = (i ? V[i - 1][j] : 0) + 1;
    }
    ma = max(ma, getS(V[i]));
  }
  cout << ma << endl;
}
signed main() {
  while (cin >> H >> W, H || W)
    solve();
  return 0;
}
Problem p00116 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  char in;
  int w, h, x, y, i;
  int myt[500][500], mdk;
  int obk_n;
  int obk_w[500], obk_h[500], obk_d[500];
  int max;

  while (1) {
    cin >> w >> h;
    if (w == 0 && h == 0) {
      break;
    }

    //-----
    for (y = 0; y < h; y++) {
      for (x = 0; x < w; x++) {
        cin >> in;
        if (in == '.') {
          if (y == 0) {
            myt[x][y] = 1;
          } else {
            myt[x][y] = myt[x][y - 1] + 1;
          }
        } else {
          myt[x][y] = 0;
        }
      }
    }
    //-----
    max = 0;
    for (y = h - 1; 0 <= y; y--) {
      obk_n = 0;
      for (x = 0; x < w; x++) {
        mdk = myt[x][y];
        for (i = obk_n - 1; 0 <= i; i--) {
          if (mdk < obk_h[i]) {
            if (max < obk_w[i] * obk_h[i]) {
              max = obk_w[i] * obk_h[i];
            }
            if (mdk <= obk_d[i]) {
              obk_n--;
              continue;
            } else {
              obk_h[i] = mdk;
            }
          }
          obk_w[i]++;
        }
        if (obk_n != 0 && obk_h[obk_n - 1] < mdk) {
          obk_w[obk_n] = 1;
          obk_h[obk_n] = mdk;
          obk_d[obk_n] = obk_h[obk_n - 1];
          obk_n++;
        }
        if (obk_n == 0 && mdk != 0) {
          obk_w[0] = 1;
          obk_h[0] = mdk;
          obk_d[0] = 0;
          obk_n = 1;
        }
      }
      for (i = obk_n - 1; 0 <= i; i--) {
        if (max < obk_w[i] * obk_h[i]) {
          max = obk_w[i] * obk_h[i];
        }
      }
    }
    cout << max << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int check(int, int);

int main() {
  int w, h;

  while (1) {
    cin >> w >> h;
    if (w == 0 && h == 0) {
      break;
    }
    cout << check(w, h) << endl;
  }
  return 0;
}

int check(int w, int h) {
  char miyata[500][500];
  int x, y, cw, ch;
  int work, i;
  int max = 0;
  bool exit = false;

  for (y = 0; y < h; y++) {
    for (x = 0; x < w; x++) {
      cin >> miyata[x][y];
    }
  }

  for (y = 0; y < h; y++) {
    if (w * (h - y) <= max) {
      continue;
    }
    for (x = 0; x < w; x++) {
      if ((w - x) * (h - y) <= max) {
        continue;
      }
      ch = 0;
      work = y;
      while (work != h && miyata[x][work] == '.') {
        ch++;
        work = y + ch;
      }
      while (ch != 0) {
        cw = 0;
        while (1) {
          for (i = 0; i < ch; i++) {
            if (miyata[x + cw][y + i] == '*') {
              break;
            }
          }
          if (x + cw != w && i == ch) {
            cw++;
          } else {
            break;
          }
        }
        work = cw * ch;
        if (max < work) {
          max = work;
        }
        if (w * h / 2 < max) {
          exit = true;
          break;
        }
        ch--;
      }
      if (exit) {
        break;
      }
    }
    if (exit) {
      break;
    }
  }

  return max;
}
Problem p00116 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bitset>
#include <cfloat>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int main() {
  for (;;) {
    int h, w;
    cin >> h >> w;
    if (h == 0)
      return 0;

    vector<string> s(h);
    for (int i = 0; i < h; ++i)
      cin >> s[i];

    vector<int> height(w + 1, 0);
    int ret = 0;
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        if (s[i][j] == '.')
          ++height[j];
        else
          height[j] = 0;
      }
      stack<pair<int, int>> stk;
      stk.push(make_pair(0, w));
      for (int j = 0; j < w + 1; ++j) {
        int k = j;
        while (height[j] < stk.top().first) {
          k = stk.top().second;
          ret = max(ret, stk.top().first * (j - k));
          stk.pop();
        }
        if (height[j] > stk.top().first)
          stk.push(make_pair(height[j], k));
      }
    }
    cout << ret << endl;
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cfloat>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int main() {
  for (;;) {
    int h, w;
    cin >> h >> w;
    if (h == 0)
      return 0;

    vector<string> s(h);
    for (int i = 0; i < h; ++i)
      cin >> s[i];

    vector<vector<int>> num(w + 1, vector<int>(w + 1, 0));
    int ret = 0;
    for (int i = 1; i <= h; ++i) {
      vector<vector<int>> next(w + 1, vector<int>(w + 1, 0));
      for (int j = 1; j <= w; ++j) {
        if (s[i - 1][j - 1] == '*')
          continue;
        next[j][1] = num[j][1] + 1;
        ret = max(ret, next[j][1]);
        for (int k = 2; k <= j; ++k) {
          next[j][k] = min(num[j][k] + 1, next[j - 1][k - 1]);
          ret = max(ret, k * next[j][k]);
        }
      }
      num.swap(next);
    }
    cout << ret << endl;
  }
}
Problem p00116 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i, j) for (int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for (int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef pair<int, int> P;
#define h first
#define p second

int H, W;
vector<string> field;
vector<vector<int>> cnt;

void init() {
  cnt = vector<vector<int>>(H, vector<int>(W, 0));
  REP(i, W) cnt[0][i] = (field[0][i] == '.' ? 1 : 0);
  FOR(y, 1, H)
  REP(x, W) cnt[y][x] = (field[y][x] == '*' ? 0 : cnt[y - 1][x] + 1);
}

int solve(vector<int> cnt) {
  cnt.push_back(0);
  vector<P> v;
  int res = 0;
  // for(int n : cnt) cout <<n <<", "; cout <<endl;
  REP(i, cnt.size()) {
    if (v.empty() || v.back().h < cnt[i])
      v.push_back(P(cnt[i], i));
    else if (v.back().h > cnt[i]) {
      int next_p = i;
      while (!v.empty() && v.back().h >= cnt[i]) {
        P now = v.back();
        v.pop_back();
        // cout <<"!  h = " <<now.h <<", w = " <<(i - now.p) <<endl;
        res = max(res, now.h * (i - now.p));
        next_p = now.p;
      }
      v.push_back(P(cnt[i], next_p));
    }
  }
  return res;
}

int main() {
  while (cin >> H >> W && H && W) {
    field = vector<string>(H);
    REP(i, H) cin >> field[i];
    init();
    int res = 0;
    REP(i, H) res = max(res, solve(cnt[i]));
    cout << res << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i, j) for (int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for (int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int H, W;
vector<string> v;

int solve(int x1, int y1, int x2, int y2) {
  int cnt = 0;
  bool f = 1;
  FOR(y, y1, y2) FOR(x, x1, x2) if (v[y][x] == '.') f = 0;
  if (f)
    return 0;
  FOR(y, y1, y2) {
    FOR(x, x1, x2) {
      if (v[y][x] == '.')
        ++cnt;
      else
        return max(max(solve(x1, y1, x, y2), solve(x + 1, y1, x2, y2)),
                   max(solve(x1, y1, x2, y), solve(x1, y + 1, x2, y2)));
    }
  }
  return cnt;
}

int main() {
  while (cin >> H >> W && H && W) {
    v = vector<string>(H);
    REP(i, H) cin >> v[i];
    cout << solve(0, 0, W, H) << endl;
  }
  return 0;
}
Problem p00116 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;

struct Rect {
  int height;
  int pos;
  Rect(int height = 0, int pos = 0) : height(height), pos(pos) {}
};

int main() {
  int h, w;
  while (scanf("%d %d", &h, &w), h) {
    vector<vector<int>> grid(h + 1, vector<int>(w + 1));
    for (int i = 1; i <= h; i++) {
      for (int j = 0; j < w; j++) {
        char c;
        scanf(" %c", &c);
        if (c == '.') {
          grid[i][j] += grid[i - 1][j] + 1;
        }
      }
    }

    int res = 0;
    for (int i = 1; i <= h; i++) {
      stack<Rect> sta;
      for (int j = 0; j <= w; j++) {
        Rect rect(grid[i][j], j);
        if (sta.empty()) {
          sta.push(rect);
        } else if (sta.top().height < rect.height) {
          sta.push(rect);
        } else if (sta.top().height == rect.height) {
          continue;
        } else if (sta.top().height > rect.height) {
          Rect t;
          while (sta.size() && sta.top().height >= rect.height) {
            t = sta.top();
            sta.pop();
            int width = j - t.pos;
            res = max(res, width * t.height);
            // printf("%d %d\\n", width, t.height);
          }
          rect.pos = t.pos;
          sta.push(rect);
        }
      }
    }
    printf("%d\\n", res);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <iostream>
#include <string.h>

using namespace std;

char str[512][512];
int H, W;

int size(int si, int sj) {
  int max = 0;
  for (int ei = si; ei < H; ei++) {
    for (int ej = sj; ej < W; ej++) {
      int f = 1;
      for (int i = si; i <= ei; i++) {
        for (int j = sj; j <= ej; j++) {
          if (str[i][j] != '.') {
            f = 0;
            break;
          }
          if (f == 0) {
            break;
          }
        }
      }

      if (f && max < (ei - si + 1) * (ej - sj + 1)) {
        max = (ei - si + 1) * (ej - sj + 1);
      }
    }
  }

  return (max);
}

int main() {
  while (1) {
    scanf("%d %d", &H, &W);

    if (!H && !W) {
      break;
    }

    for (int i = 0; i < 512; i++) {
      strcpy(str[i], "");
    }

    for (int i = 0; i < H; i++) {
      cin >> str[i];
    }

    int max = 0;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        int s = size(i, j);
        if (max < s) {
          max = s;
        }
      }
    }

    printf("%d\\n", max);
  }

  return 0;
}
Problem p00116 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef list<int> L;
typedef pair<int, int> P;
typedef vector<int> V;
typedef queue<int> Q;
typedef stack<int> S;
typedef map<string, int> M;

int main() {
  int H, W;

  while (cin >> H >> W, H) {
    char d[H][W];
    int ansW, ansH, ans = 0;
    for (int i = 0; i < H; i++)
      for (int j = 0; j < W; j++)
        cin >> d[i][j];

    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (d[i][j] == '.') {
          ansH = 0;
          ansW = 9999;
          while (d[i + ansH][j] == '.' && i + ansH < H) {
            int m = 0;
            while (d[i + ansH][j + m] == '.' && j + m < W)
              m++;
            ansW = min(ansW, m);
            ansH++;
            ans = max(ans, ansW * ansH);
          }
        }
      }
    }
    cout << ans << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef list<int> L;
typedef pair<int, int> P;
typedef vector<int> V;
typedef queue<int> Q;
typedef stack<int> S;
typedef map<string, int> M;

int main() {
  int H, W;

  while (cin >> H >> W, H) {
    char d[H][W];
    int ansW = 500, ansH = 500, ans = -1;
    for (int i = 0; i < H; i++)
      for (int j = 0; j < W; j++)
        cin >> d[i][j];

    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (d[i][j] == '.') {
          int k = 0;
          while (d[i + k][j] == '.' && i + k < H) {
            k++;
            ansW = 999;
            for (int l = i; l < i + k; l++) {
              int m = 0;
              while (d[l][j + m] == '.' && j + m < W)
                m++;
              ansW = min(ansW, m);
            }
            ansH = k;
            ans = max(ans, ansW * ansH);
          }
        }
      }
    }
    cout << ans << endl;
  }

  return 0;
}
Problem p00116 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>

int h, w;
char map[501][501];
int data[502][502];

int main() {
  while (std::cin >> h >> w, h || w) {
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        std::cin >> map[i][j];
      }
    }

    for (int i = 0; i < h; i++) {
      data[i][w] = 0;
      for (int j = w - 1; j >= 0; j--) {
        data[i][j] = data[i][j + 1] + 1;
        if (map[i][j] == '*')
          data[i][j] = 0;
      }
    }

    int max = 0;

    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        int width = data[i][j];
        for (int k = 1; k <= h - i; k++) {
          max = std::max(max, k * width);
          width = std::min(width, data[i + k][j]);
        }
      }
    }

    std::cout << max << std::endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>

int h, w;
char map[501][501];
int data[502][502];

int main() {
  while (std::cin >> h >> w, h || w) {
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        std::cin >> map[i][j];
      }
    }

    for (int i = 0; i < h; i++) {
      data[i][w] = 0;
      for (int j = w - 1; j >= 0; j--) {
        data[i][j] = data[i][j + 1] + 1;
        if (map[i][j] == '*')
          data[i][j] = 0;
      }
    }

    int max = 0;

    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        for (int k = 1; k <= h - i; k++) {
          int width = data[i][j];
          for (int l = 1; l < k; l++)
            width = std::min(width, data[i + l][j]);
          max = std::max(max, k * width);
        }
      }
    }

    std::cout << max << std::endl;
  }

  return 0;
}
Problem p00116 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#define MAX 500
using namespace std;
int h, w;
char m[MAX][MAX];

int solve() {
  int data[MAX][MAX];
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (m[i][j] == '*')
        data[i][j] = 0;
      else if (i == 0)
        data[i][j] = 1;
      else
        data[i][j] = data[i - 1][j] + 1;
    }
  }

  int ans = 0;
  for (int i = 0; i < h; i++) {
    for (int l = 0; l < w; l++) {
      if (data[i][l] == 0)
        continue;
      int mini = data[i][l];
      for (int r = l; r < w; r++) {
        if (data[i][r] == 0)
          break;
        mini = min(mini, data[i][r]);
        ans = max(ans, mini * (r - l + 1));
      }
    }
  }

  return ans;
}

int main() {
  while (1) {
    cin >> h >> w;
    if (h == 0 && w == 0)
      break;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        cin >> m[i][j];
      }
    }
    cout << solve() << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#define MAX 500
using namespace std;
int h, w;
char m[MAX][MAX];

int solve() {
  int data[MAX][MAX];
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (m[i][j] == '*')
        data[i][j] = 0;
      else if (i == 0)
        data[i][j] = 1;
      else
        data[i][j] = data[i - 1][j] + 1;
    }
  }

  int ans = 0;
  for (int i = 0; i < h; i++) {
    for (int l = 0; l < w; l++) {
      if (data[i][l] == 0)
        continue;
      for (int r = l; r < w; r++) {
        if (data[i][r] == 0) {
          break;
        }
        int mini = MAX * MAX + 1;
        for (int j = l; j <= r; j++) {
          mini = min(mini, data[i][j]);
        }
        ans = max(ans, mini * (r - l + 1));
      }
    }
  }

  return ans;
}

int main() {
  while (1) {
    cin >> h >> w;
    if (h == 0 && w == 0)
      break;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        cin >> m[i][j];
      }
    }
    cout << solve() << endl;
  }
  return 0;
}