Problem:
Get Many Persimmon Trees
Seiji Hayashi had been a professor of the Nisshinkan Samurai School
in the domain of Aizu for a long time in the 18th century.
In order to reward him for his meritorious career in education,
Katanobu Matsudaira, the lord of the domain of Aizu, had decided to
grant him a rectangular estate within a large field in the Aizu Basin.
Although the size (width and height) of the estate was strictly specified
by the lord, he was allowed to choose any location for the estate
in the field.
Inside the field which had also a rectangular shape,
many Japanese persimmon trees,
whose fruit was one of the famous products of the Aizu region
known as 'Mishirazu Persimmon', were planted.
Since persimmon was Hayashi's favorite fruit, he wanted to have
as many persimmon trees as possible in the estate given by the lord.
For example, in Figure 1, the entire field is a rectangular grid whose
width and height are 10 and 8 respectively.  Each asterisk (*)
represents a place of a persimmon tree.  If the specified width and
height of the estate are 4 and 3 respectively, the area surrounded by
the solid line contains the most persimmon trees.  Similarly, if the
estate's width is 6 and its height is 4, the area surrounded by the
dashed line has the most, and if the estate's width and height are 3
and 4 respectively, the area surrounded by the dotted line contains
the most persimmon trees.  Note that the width and height cannot be
swapped; the sizes 4 by 3 and 3 by 4 are different, as shown in Figure
1.
Figure 1: Examples of Rectangular Estates
Your task is to find the estate of a given size (width and height)
that contains the largest number of persimmon trees.
Input
The input consists of multiple data sets.
Each data set is given in the following format.
N
W
H
x
1
y
1
x
2
y
2
...
x
N
y
N
S
T
N
is the number of persimmon trees,
which is a positive integer less than 500.
W
and
H
are the width and the height of the entire field
respectively.
You can assume that both
W
and
H
are positive integers
whose values are less than 100.
For each
i
(1 <=
i
<=
N
),
x
i
and
y
i
are
coordinates of the
i
-th persimmon tree in the grid.
Note that the origin of each coordinate is 1.
You can assume that 1 <=
x
i
<=
W
and 1 <=
y
i
<=
H
,
and no two trees have the same positions.
But you should not assume that the persimmon trees are sorted in some order
according to their positions.
Lastly,
S
and
T
are positive integers of
the width and height respectively of the estate given by the lord.
You can also assume that 1 <=
S
<=
W
and 1 <=
T
<=
H
.
The end of the input is indicated by a line that solely contains a zero.
Output
For each data set, you are requested to print one line containing the
maximum possible number of persimmon trees that can be included in an
estate of the given size.
Sample Input
16
10 8
2 2
2 5
2 7
3 3
3 8
4 2
4 5
4 8
6 4
6 7
7 5
7 8
8 1
8 4
9 6
10 3
4 3
8
6 4
1 2
2 1
2 4
3 4
4 2
5 3
6 1
6 2
3 2
0
Output for the Sample Input
4
3

Submitted solutions:

code_snippet: #include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int x[520],y[520];

int main(){
	int i,j,n,w,h,s,t,k,res,q;
	while(scanf("%d",&n)>0&&n){
		scanf("%d%d",&w,&h);
		//for(i=1;i<=h;i++) for(j=1;j<=w;j++) a[i][j]=0;
		for(i=0;i<n;i++) scanf("%d%d",&x[i],&y[i]);
		scanf("%d%d",&s,&t);
		
		res=0;
		for(i=1;i+t-1<=h;i++){
			for(j=1;j+s-1<=w;j++){
				//if(!a[i][j]) continue;
				q=0;
				for(k=0;k<n;k++){
					if(x[k]>=j&&x[k]<j+s&&y[k]>=i&&y[k]<i+t) ++q;
				}
				if(res<q) res=q;
			}
		}
		
		printf("%d\n",res);
	}
	
	return 0;
}
accuracy: 1
time_ms: 50
memory_kb: 3492
final_rank: 16

code_snippet: #include <iostream>

int main() {
    while (1) {
        int N;
        std::cin >> N;
        if (N == 0)
            break;

        int W, H;
        std::cin >> W >> H;        
        int grid[H+1][W+1];
        for (int i = 1; i <= H; i++)
            for (int j = 1; j <= W; j++)
                grid[i][j] = 0;

        for (int i = 0; i < N; i++) {
            int x, y;
            std::cin >> x >> y;
            grid[y][x] = 1;
        }

        int S, T;
        std::cin >> S >> T;

        int res = 0;
        for (int i = 1; i <= H; i++) {
            for (int j = 1; j <= W; j++) {
                int count = 0;
                for (int k = 0; k < T; k++) {
                    for (int l = 0; l < S; l++) {
                        if (H < i+k || W < j+l)
                            break;

                        if (grid[i+k][j+l] == 1) 
                            count++;                
                    }
                }
    
                if (res < count)
                    res = count;
            }
        }

        std::cout << res << std::endl;
    }
}
accuracy: 1
time_ms: 10
memory_kb: 3292
final_rank: 11

code_snippet: #include <iostream>

int main() {
    while (1) {
        int N;
        std::cin >> N;
        if (N == 0)
            break;

        int W, H;
        std::cin >> W >> H;        
        int grid[H+1][W+1];
        for (int i = 1; i <= H; i++)
            for (int j = 1; j <= W; j++)
                grid[i][j] = 0;

        for (int i = 0; i < N; i++) {
            int x, y;
            std::cin >> x >> y;
            grid[y][x] = 1;
        }

        int S, T;
        std::cin >> S >> T;

        int res = 0;
        for (int i = 1; i <= H; i++) {
            for (int j = 1; j <= W; j++) {
                int count = 0;
                for (int k = 0; k < T; k++) {
                    for (int l = 0; l < S; l++) {
                        if (H < i+k || W < j+l)
                            continue;

                        if (grid[i+k][j+l] == 1) 
                            count++;                
                    }
                }
    
                if (res < count)
                    res = count;
            }
        }

        std::cout << res << std::endl;
    }
}
accuracy: 1
time_ms: 10
memory_kb: 3336
final_rank: 12

code_snippet: #include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, j, n) for (ll i = j; i < (n); ++i)
#define rrep(i, j, n) for (ll i = (n)-1; j <= i; --i)
#define all(a) a.begin(), a.end()
template <typename T>
std::ostream &operator<<(std::ostream &os, std::vector<T> &a) {
  for (size_t i = 0; i < a.size(); ++i) os << (i > 0 ? " " : "") << a[i];
  return os << '\n';
}
template <typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &a) {
  for (T &x : a) { is >> x; }
  return is;
}

[[maybe_unused]] static constexpr long long MOD = 998244353;
[[maybe_unused]] static constexpr int INF = 0x3f3f3f3f;
[[maybe_unused]] static constexpr long long INFL = 0x3f3f3f3f3f3f3f3fLL;

int main() {
  cin.tie(0)->sync_with_stdio(0);
  int n, q, m, a;
  while (true) {
    cin >> n;
    if (n == 0) break;
    int w, h, s, t;
    cin >> w >> h;
    vector<int> x(n), y(n);
    rep(i, 0, n) { cin >> x[i] >> y[i]; }
    cin >> s >> t;

    int ans = 0;
    rep(lx, 1, w - s + 2) {
      rep(ly, 1, h - t + 2) {
        int rx = lx + s, ry = ly + t;
        int c = 0;
        rep(k, 0, n) {
          if (lx <= x[k] && x[k] < rx && ly <= y[k] && y[k] < ry) ++c;
        }
        ans = max(ans, c);
      }
    }
    cout << ans << '\n';
  }
}
accuracy: 1
time_ms: 30
memory_kb: 3372
final_rank: 13

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(A) A.begin(),A.end()
using vll = vector<ll>;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)


int main() {
    while(1){
        ll N;
        cin>>N;
        if(N==0)return 0;
        ll W,H;
        cin>>W>>H;
        set<pair<ll,ll>> P;
        rep(n,N){
            ll Y,X;
            cin>>Y>>X;
            P.insert(make_pair(Y,X));
        }
        ll S,T;
        cin>>S>>T;
        ll an=0;
        for(ll y=1;y<=W-S+1;y++){
            for(ll x=1;x<=H-T+1;x++){
                ll p=0;
   
                for(ll d=y;d<y+S;d++){
                    for(ll e=x;e<x+T;e++){
                        if(P.count(make_pair(d,e)))p++;
                    }
                }
                an=max(an,p);
            }
        }
        cout<<an<<endl;
    }
}
accuracy: 1
time_ms: 70
memory_kb: 3160
final_rank: 10

code_snippet: #include<iostream>

using namespace std;

int main()
{
	int N;
	cin >> N;
	while (N != 0)
	{
		int W, H;
		cin >> W >> H;
		pair<int, int>* points = new pair<int, int>[N];
		for (int i = 0; i < N; i++)
			cin >> points[i].first >> points[i].second;
		int S, T;
		cin >> S >> T;
		int ans = 0;
		for (int x0 = 1; x0 <= W - S + 1; x0++)
		{
			for (int y0 = 1; y0 <= H - T + 1; y0++)
			{
				int x1 = x0 + S - 1;
				int y1 = y0 + T - 1;
				int counter = 0;
				for (int i = 0; i < N; i++)
					counter += (points[i].first >= x0 && points[i].first <= x1 && points[i].second >= y0
						&& points[i].second <= y1);
				ans = max(counter, ans);
			}
		}
		cout << ans << endl;

		cin >> N;
	}

	//system("pause");
}
accuracy: 1
time_ms: 20
memory_kb: 3528
final_rank: 19

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int, int>
#define us unordered_set
#define ud unordered_dict
#define Lower_bound(vec, n) distance((vec).begin(), lower_bound((vec).begin(), (vec).end(), (n)))
#define Upper_bound(vec, n) distance((vec).begin(), upper_bound((vec).begin(), (vec).end(), (n)))
#define Erase(vec) (vec).erase(unique((vec).begin(), (vec).end()), (vec).end())
//template <class T = int> in()(T x; cin >> x; return (x);)
//template <class T> print(T& x) (cout << x << endl;)
//using template <class T> vec = vector<T>;
using Graph = vector<vector<int>>;
const int INF = 1LL << 60;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

struct phash{
    inline size_t operator()(const pair<int, int> & p) const{
        const auto h1 = hash<int>()(p.first);
        const auto h2 = hash<int>()(p.second);
        return h1 ^ (h2 << 1);
    }
};

signed main() {
    int N, W, H, S, T;
    pii coordinate;
    while (true) {
        cin >> N;
        if (N == 0) break;
        cin >> W >> H;

        us<pair<int, int>, phash> trees;

        int intmp1, intmp2;
        REP(i, N) {
            cin >> intmp1 >> intmp2;
            trees.insert(make_pair(intmp2-1, intmp1-1));
        }

        cin >> S >> T;
        int row_max = H - T;
        int column_max = W - S;

        int ans = 0;
        int challenge;

        REP(head_r, row_max+1) {
            REP(head_c, column_max+1) {
                challenge = 0;
                REP(r, T) {
                    REP(c, S) {
                        if (trees.count(make_pair(head_r+r, head_c+c))) challenge++;
                    }
                }
                ans = max(ans, challenge);
            }
        }
        cout << ans << endl;
    }

}
accuracy: 1
time_ms: 170
memory_kb: 3372
final_rank: 17

code_snippet: #include <iostream>
#include <vector>
using namespace std;

bool solve(void) {
    int N;
    cin >> N;
    if (N == 0) return false;
    int W, H;
    cin >> W >> H;
    vector<pair<int, int>> kaki(N);
    for (auto &[x, y] : kaki) {
        cin >> x >> y;
        --x, --y;
    }
    int S, T;
    cin >> S >> T;

    auto count_kaki = [](const vector<pair<int, int>> &kaki, int w0, int h0,
                         int w1, int h1) {
        int cnt = 0;
        for (auto [x, y] : kaki)
            if (w0 <= x and x < w1 and h0 <= y and y < h1) ++cnt;
        return cnt;
    };

    int ans = 0;
    for (int h = 0; h <= H; ++h) {
        for (int w = 0; w <= W; ++w) {
            int w1 = w + S;
            int h1 = h + T;
            if (w1 <= W and h1 <= H)
                ans = max(ans, count_kaki(kaki, w, h, w1, h1));
        }
    }
    cout << ans << endl;
    return true;
}

int main(void) {
    while (solve())
        ;
}
accuracy: 1
time_ms: 30
memory_kb: 3456
final_rank: 15

code_snippet: #include<iostream>
using namespace std;
int main(){
  int N[100][100];
  int n,W,H,S,T,x,y,s,t,sum,max;
  cin >> n;
  while(n!=0){
    cin >> W >> H;
    sum=max=0; 
    for(int i=0;i<W;i++){
      for(int j=0;j<H;j++){
	N[i][j]=0;
      }
    }
    for(int i=0;i<n;i++){
      cin >> x >> y;
      N[x-1][y-1]=1;
    }
    cin >> S >> T;
    for(int s=0;s<W-(S-1);s++){
      for(int t=0;t<H-(T-1);t++){
	for(int i=s;i<s+S;i++){
	  for(int j=t;j<t+T;j++){
	    if(N[i][j]==1)sum++;
	  }
	}
	if(max<sum)max=sum;
	sum=0;
      }
    }
    cout << max << endl;
    cin >> n;
  }
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3400
final_rank: 14

code_snippet: #include <bits/stdc++.h>

/*
#include <atcoder/all>
using namespace atcoder;
*/
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;


using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007ll;
//const ll mod = 10000000000ll;
//const ll mod = 10000;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
#define rep(i, n)         for(ll i = 0; i < (ll)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define bbrep(n)           for(int bbit=0;bbit<(1<<n);bbit++)
#define erep(i,container) for (auto &i : container)
#define itrep(i,container) for (auto i : container)
#define irep(i, n)        for(ll i = n-1; i >= (ll)0ll; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
//#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vout(a) erep(qxqxqx,a)std::cout << qxqxqx << ' ';std::cout  << std::endl;
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
//#define vvector(name,typ,m,n)vector<vector<typ> > name(m,vector<typ> (n))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<":"
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j);
#define RESRES(a,i,j,k) a.resize(i);rep(ii,i)a[ii].resize(j);reprep(ii,jj,i,j){dp[ii][jj].resize(k)};
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define ppppri(a,b,c,d) std::cout << a<<" "<<b <<" "<< c<<' '<<d<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define SUM(a) accumulate(all(a),0ll) 
#define stirng string
#define gin(a,b) int a,b;std::cin >> a>>b;a--;b--;
#define popcount __builtin_popcount
#define permu(a) next_permutation(all(a))
//#define grid_input(a,type) int h,w;std::cin >> h>>w;vvector(a,type,h,w,0);reprep(i,j,h,w)std::cin >> a[i][j];

//typedef long long T;
ll ceil(ll a,ll b){
    return ((a+b-1)/b);
}
const int INF = 2000000000;
//const ll INF64 =3223372036854775807ll;
//const ll INF64 = 9223372036854775807ll;
const ll INF64 = 9223372036854775ll;
const ll MOD = 1000000007ll;
//const ll MOD = 1000003ll;
const ll OD = 1000000000000007ll;
const dou pi=3.141592653589793;
long long modpow(long long a, long long n,ll MOD) { //累乗の余剰
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}


//メモ
//ゲーム(Grundy数とか)の復習をする
//群論の勉強をする？
//ドツボにハマったら頑張って今までの思考をリセットする
//学会のスライドを作る(水曜日まで)
//周期性の実験をする
//リスニング力をどうにかする
//GT学会の会費を払う
/*
#include <atcoder/all>
using namespace atcoder;
*/
/*
#include <atcoder/all>
using namespace atcoder;
*/
int main(){
    ffor{
        int n;
        std::cin >> n;
        if(n==0)break;
        int h,w;
        std::cin >> h>>w;
        vvector(a,bool,h,w,0);
        rep(i,n){
            gin(d,b);a[d][b]=1;
        }
        int ans=0;
        int s,t;
        std::cin >> s>>t;
        rep(ii,h-s+1){
            rep(jj,w-t+1){
                int d=0;
                reprep(i,j,s,t){
                    if(a[ii+i][jj+j])d++;
                }
                chmax(ans,d);
            }
        }
        std::cout << ans << std::endl;
    }
}
accuracy: 1
time_ms: 10
memory_kb: 3184
final_rank: 8

code_snippet: #include <bits/stdc++.h>
using namespace std;
int main(){
  while (1){
    int N;
    cin >> N;
    if (N == 0){
      break;
    }
    int W, H;
    cin >> W >> H;
    vector<int> x(N), y(N);
    for (int i = 0; i < N; i++){
      cin >> x[i] >> y[i];
    }
    int S, T;
    cin >> S >> T;
    int ans = 0;
    for (int i = 1; i <= W - S + 1; i++){
      for (int j = 1; j <= H - T + 1; j++){
        int cnt = 0;
        for (int k = 0; k < N; k++){
          if (i <= x[k] && x[k] <= i + S - 1 && j <= y[k] && y[k] <= j + T - 1){
            cnt++;
          }
        }
        ans = max(ans, cnt);
      }
    }
    cout << ans << endl;
  }
}
accuracy: 1
time_ms: 60
memory_kb: 3004
final_rank: 3

code_snippet: #include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    while(N != 0){
        int W,H;
        cin >> W >> H;
        vector<vector<int>> G(H,vector<int> (W,0));
        for(int i=0; i<N; i++){
            int x,y;
            cin >> x >> y;
            x--;
            y--;
            G[y][x]++;
        }
        int S,T;
        cin >> S >> T;
        int ans = 0;
        for(int i=T; i<=H; i++){
            for(int j=S; j<=W; j++){
                int sum = 0;
                for(int k=i-T; k<i; k++){
                    for(int l=j-S; l<j; l++){
                        sum += G[k][l];
                    }
                }
                chmax(ans,sum);
            }
        }
        cout << ans << endl;
        cin >> N;
    }
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3184
final_rank: 8

code_snippet: #include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;


int main(void){
    int n,w,h,s,t;
    while(true){
        cin>>n;
        if(n==0)break;
        cin>>w>>h;
        vector<int>x(n),y(n);
        for(int i=0;i<n;i++){
            cin>>y[i]>>x[i];
            x[i]--;
            y[i]--;
        }
        cin>>s>>t;
        int ans =0;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                int height = i+t;
                int width = j+s;
                int num = 0;
                if((height>h)||(width>w))break;
                for(int k=i;k<height;k++){
                    for(int l=j;l<width;l++){
                        for(int m=0;m<n;m++){
                            if(x[m]==k && y[m]==l)num++;
                        }
                    }
                }
                ans = max(ans,num);
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}
accuracy: 1
time_ms: 940
memory_kb: 3084
final_rank: 20

code_snippet: #include<queue>
#include<cstdio>
#include <stdio.h>
#include <iostream>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX_W 100
#define MAX_H 100
#define MAX_N 500
using namespace std;
const int INF = 100000000;
typedef pair<int, int> P;

int N,W,H,S,T,X,Y,x,y;
int iX[MAX_N];
int iY[MAX_N];
int M[MAX_H][MAX_W];
int count[MAX_H][MAX_W];
bool check[MAX_H][MAX_W];
int dx[2] = {1,0};
int dy[2] = {0,1};

int main(){
  while(true){
    cin >> N;
    if(N == 0){
      break;
    }
    cin >> W >> H;
    rep(i,N){
      cin >> X >> Y;
      iX[i] = X;
      iY[i] = Y;
    }
    cin >> S >> T;
    rep(i,H){
      rep(j,W){
        M[i][j] = 0;
        count[i][j] = 0;
      }
    }
    rep(i,N){
      M[iY[i] - 1][iX[i] -1] = 1;
    }

    rep(i,H-T+1){
      rep(j,W-S+1){
        rep(k,H){
          rep(l,W){
            check[k][l] = false;
          }
        }
        queue<P> que;
        que.push(P(j,i));
        if(M[i][j] == 1){
          count[i][j] = 1;
        }
        check[i][j] = true;
        while(que.size()){
          P q = que.front();que.pop();
          rep(k,2){
            int nx = q.first + dx[k], ny = q.second + dy[k];
            if(0 <= nx && nx < j + S && 0 <= ny && ny < i + T && check[ny][nx] == false){
              if(M[ny][nx] == 1)
                count[i][j] += 1;
              que.push(P(nx,ny));
              check[ny][nx] = true;
            }
          }
        }
      }
    }
    int m = 0;
    rep(i,H-T+1){
      rep(j,W-S+1){
        if(count[i][j] > m)
          m = count[i][j];
        }
      }
      printf("%d\n",m);
    }
  }
accuracy: 1
time_ms: 300
memory_kb: 3244
final_rank: 18

code_snippet: #include <bits/stdc++.h>

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  while(1) {
    int n; cin >> n;
    if(n == 0) break;
    int w, h; cin >> w >> h;
    vector<vector<bool>> g(h, vector<bool>(w));
    for(int i=0;i<n;++i) {
      int x, y; cin >> x >> y;
      x--; y--;
      g[y][x] = true;
    }
    int s, t; cin >> s >> t;

    int ans = 0;
    for(int i=0;i<h-t+1;++i) {
      for(int j=0;j<w-s+1;++j) {
        int su = 0;
        for(int k=0;k<t;++k) {
          for(int l=0;l<s;++l) {
            su += g[i+k][j+l];
          }
        }
        ans = max(ans, su);
      }
    }
    cout << ans << endl;
  }
}
accuracy: 1
time_ms: 10
memory_kb: 3124
final_rank: 6

code_snippet: #include"bits/stdc++.h"
using namespace std;

int main(){
    int n;
    cin >> n;
    int w,h;
    int x,y;
    int s,t;
    int ans;
    int cnt;
    while (n!=0){
        cin >> w >> h;
        vector<vector<bool>> persimmon(h, vector<bool>(w));
        for (int i = 0; i<h; i++){
            for (int j = 0; j<w; j++) persimmon[i][j] = false;
        }
        for (int i = 0; i<n; i++){
            cin >> x >> y;
            persimmon[y-1][x-1] = true;
        }
        cin >> s >> t;
        ans = 0;
        for (int i = 0; i+t <= h; i++){
            for (int j = 0; j+s <= w; j++){
                cnt = 0;
                for (int k = 0; k<t; k++){
                    for (int l = 0; l<s; l++){
                        if (persimmon[i+k][j+l]) cnt++;
                    }
                }
                ans = max(ans, cnt);
            }
        }
        cout << ans << endl;
        cin >> n;
        
    }
}
accuracy: 1
time_ms: 10
memory_kb: 3100
final_rank: 4

code_snippet: #include<bits/stdc++.h>
using namespace std;
int main(){
    int n,w,h,x,y,s,t;
    while(cin>>n,n){
        cin>>w>>h;
        int ma[100][100]={};
        for(int i=0;i<n;i++){
            cin>>x>>y;
            ma[y-1][x-1]=1;
        }
        cin>>s>>t;
        int cnt,mx=0;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cnt=0;
                for(int k=i;k<i+t;k++){
                    for(int l=j;l<j+s;l++){
                        if(ma[k][l]==1) cnt++;
                    }
                }
                mx=max(mx,cnt);
            }
        }
        cout<<mx<<endl;
    }
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3036
final_rank: 2

code_snippet: #include<iostream>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)

int x[1000],y[1000];
int main() {
    while(true) {
        int n;
        cin >> n;
        if(n == 0)break;
        int w,h;
        cin >> w >> h;

        rep(i,n)cin >> x[i] >> y[i];
        int s,t;
        cin >> s >> t;

        int ans = 0;
        for(int i = 1;i <= w - s + 1;i++) {
            for(int j = 1;j <= h - t + 1;j++) {
                int sum = 0;
                rep(k,n) {
                    if(i <= x[k] && x[k] < i + s && j <= y[k] && y[k] < j + t) {
                        sum++;
                    }
                }
                ans = max(sum,ans);
            }
        }
        cout << ans << endl;
    }
    return 0;

}
accuracy: 1
time_ms: 70
memory_kb: 3060
final_rank: 5

code_snippet: #include <cstdio>
#include <algorithm>
using namespace std;

int main(){
    int N,W,H,c,x,y,i,j,k,l,m,S,T;
    while(1){
        scanf("%d",&N);
        if(!N){break;}
        scanf("%d %d",&W,&H);
        int ll[H+1][W+1];
        fill(ll[0],ll[H+1],0);
        for(i=0;i<N;i++){
            scanf("%d %d",&x,&y);
            ll[y][x]=1;
        }
        scanf("%d %d",&S,&T);
        m=0;
        for(i=1;i+T-1<=H;i++){
            for(j=1;j+S-1<=W;j++){
                c=0;
                for(k=i;k<=i+T-1;k++){
                    for(l=j;l<=j+S-1;l++){
                        if(ll[k][l]){c++;}
                    }
                }
                m=max(m,c);
            }
        }
        printf("%d\n",m);
    }
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 2596
final_rank: 1

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

int main(){
	int N, W, H, S, T, x, y;
	while(1){
		int temp[220][220] = {}, ans = 0, count;
		
		cin>>N;
		
		if(N == 0) break;
		
		cin>>W>>H;
		
		for(int i = 0; i < N; i++){
			cin>>x>>y;
			temp[y][x] = 1;
		}
		cin>>S>>T;
		
		for(int i = 1; i <= H; i++){
			for(int j = 1; j <= W; j++){
				count = 0;
				for(int k = 0; k < T; k++)
					for(int l = 0; l < S; l++) if(temp[i+k][j+l] == 1)count++;
				ans = max(count, ans);	
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3168
final_rank: 7