Problem p00706 (C++)

Buggy submission (status: Runtime Error):
#include <cstdio>
#include <iomanip>
#include <iostream>

#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>

#include <algorithm>
#include <functional>
#include <numeric>

#include <cctype>

#include <complex>
#include <sstream>
#include <string>

using namespace std;

#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define rep(i, n) for (unsigned int i = 0; i < (n); i++)
#define tr(it, container)                                                      \
  for (typeof(container.begin()) it = container.begin();                       \
       it != container.end(); ++it)
#define mp(a, b) make_pair((a), (b))

typedef long long ll;
typedef complex<double> P;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
const double EPS = 1e-9;
const int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int daysleap[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main() {
  while (true) {
    int N;
    cin >> N;
    if (N == 0)
      break;
    int W, H;
    cin >> W >> H;
    vector<vector<char>> F(H, vector<char>(W, '.'));
    rep(i, N) {
      int x, y;
      cin >> x >> y;
      x--;
      y--;
      F[y][x] = '*';
    }
    int S, T;
    cin >> S >> T;
    int ret = 0;
    rep(i, H) {
      rep(j, W) cerr << F[i][j];
      cerr << endl;
    }
    for (int i = 0; i < H - T + 1; i++) {
      for (int j = 0; j < W - S + 1; j++) {
        int c = 0;
        for (int k = i; k < i + T; k++) {
          for (int l = j; l < j + S; l++) {
            if (F[k][l] == '*') {
              c++;
            }
          }
        }
        ret = max(ret, c);
      }
    }
    cout << ret << endl;
  }
  return 0;
}

Fixed submission:
#include <cstdio>
#include <iomanip>
#include <iostream>

#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>

#include <algorithm>
#include <functional>
#include <numeric>

#include <cctype>

#include <complex>
#include <sstream>
#include <string>

using namespace std;

#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define rep(i, n) for (unsigned int i = 0; i < (n); i++)
#define tr(it, container)                                                      \
  for (typeof(container.begin()) it = container.begin();                       \
       it != container.end(); ++it)
#define mp(a, b) make_pair((a), (b))

typedef long long ll;
typedef complex<double> P;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
const double EPS = 1e-9;
const int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int daysleap[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main() {
  while (true) {
    int N;
    cin >> N;
    if (N == 0)
      break;
    int W, H;
    cin >> W >> H;
    vector<vector<char>> F(H, vector<char>(W, '.'));
    rep(i, N) {
      int x, y;
      cin >> x >> y;
      x--;
      y--;
      F[y][x] = '*';
    }
    int S, T;
    cin >> S >> T;
    int ret = 0;

    for (int i = 0; i < H - T + 1; i++) {
      for (int j = 0; j < W - S + 1; j++) {
        int c = 0;
        for (int k = i; k < i + T; k++) {
          for (int l = j; l < j + S; l++) {
            if (F[k][l] == '*') {
              c++;
            }
          }
        }
        ret = max(ret, c);
      }
    }
    cout << ret << endl;
  }
  return 0;
}