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

Solution (Python):



s = [[0 for x in range(105)] for y in range(105)]
while True:
	N = int(input())
	if N == 0: break
	a = [[0 for x in range(105)] for y in range(105)]
	W, H = map(int, input().split())
	for i in range(N):
		x, y = map(int, input().split())
		a[y][x] = 1
	for y in range(1, H+1):
		for x in range(1, W+1):	s[y][x] = s[y][x-1] + a[y][x]
	S, T = map(int, input().split())
	ans = 0
	for y in range(H-T+1):
		for x in range(W-S+1):
			k = 0
			for i in range(1, T+1):	k += s[y+i][x+S]-s[y+i][x];
			ans = max(ans, k)
	print(ans)

Solution (Python):
while True:
    N = int(input())
    if N == 0:
        break
    W, H = map(int, input().split())
    field = [[0 for _ in range(W)] for _ in range(H)]
    for _ in range(N):
        x, y = map(int, input().split())
        field[y - 1][x - 1] = 1
    S, T = map(int, input().split())
    c_list = []
    for tate in range(H - T + 1):
        for yoko in range(W - S + 1):
            c = 0
            for i in range(tate, T + tate):
                for j in range(yoko, S + yoko):
                    if field[i][j] == 1:
                        
                        c += 1
            c_list.append(c)

    
    print(max(c_list))

Solution (Python):
while(True):
    N=int(input())
    if N==0:
        quit()
    W,H=map(int,input().split())
    d=[[0]*W for i in range(H)]
    for i in range(N):
        x,y=map(int,input().split())
        d[y-1][x-1]=1

    dp=[[0]*(W+1) for i in range(H+1)]
    for i in range(H):
        for j in range(W):
            dp[i+1][j+1]=dp[i][j+1]+dp[i+1][j]-dp[i][j]+d[i][j]
    ans=0
    S,T=map(int,input().split())
    for i in range(H):
        for j in range(W):
            if i+T>H or j+S>W:
                continue
            a=dp[T+i][S+j]-dp[i][S+j]-dp[T+i][j]+dp[i][j]
            ans=max(a,ans)
    print(ans)

Solution (Python):
def main():
    while True:
        N = int(input())
        if N==0:
            exit()

        (W, H) = [int(x) for x in input().split()]
        persimmon = [[0 for j in range(100)] for i in range(100)]
        for _ in range(N):
            (x, y) = [int(x) for x in input().split()]
            persimmon[x][y] = 1

        cumsum = [[0 for j in range(100)] for i in range(100)]
        for x in range(1, 100):
            for y in range(1,100):
                cumsum[x][y] = cumsum[x-1][y] + cumsum[x][y-1] - cumsum[x-1][y-1] + persimmon[x][y]

        (S, T) = [int(x) for x in input().split()]
        max_persimmon = 0
        for x in range(S, W+1):
            for y in range(T, H+1):
                max_persimmon = max(max_persimmon, cumsum[x][y]+cumsum[x-S][y-T]-cumsum[x][y-T]-cumsum[x-S][y])
        print(max_persimmon)

if __name__ == '__main__':
    main()

Solution (Python):



import os
import sys
import itertools
import math
from collections import Counter, defaultdict

class Main(object):
    
    def __init__(self):
        pass

    def solve(self):
        '''
        insert your code
        '''
        while True:
            n = input()
            if n == 0:
                break
            w, h = map(int, raw_input().split())
            m = [[None for j in range(w+1)] for i in range(h+1)]
            for i in range(n):
                x, y = map(int, raw_input().split())
                m[y][x] = '*'
            s, t = map(int, raw_input().split())
            ans = -1
            for i in range(1, h+1):
                for j in range(1, w+1):
                    count = 0
                    for k in range(t):
                        for l in range(s):
                            if i + k <= h and j + l <= w and m[i+k][j+l] == '*':
                                count += 1
                    if ans < count:
                        ans = count            
            print ans
        return None

if __name__ == '__main__':
    m = Main()
    m.solve()

Solution (Python):



while True:
    N = int(input())
    if N == 0:
        break
    W,H = map(int,input().split(" "))
    Map = [[-1 for i in range(W)] for j in range(H)]
    for i in range(N):
        x,y = map(lambda x:int(x)-1,input().split(" "))
        Map[y][x] = 1
    S,T = map(int,input().split(" "))
    count = 0
    for i in range(0,H-T+1):
        for j in range(0,W-S+1):
            count = max(count,sum([1 if Map[k][l] == 1 else 0 for k in range(i,i+T) for l in range(j,j+S)]))
    print(count)

Solution (Python):
while 1:
    N = int(raw_input())
    if N == 0: break
    W,H = map(int,raw_input().split())
    A = [[0]*W for _ in range(H)]
    for i in range(N):
        w,h = map(int,raw_input().split())
        A[h-1][w-1] = 1
    S,T = map(int,raw_input().split())
    S,T = S,T
    
    ans = 0
    for h in range(H-T+1):
        for w in range(W-S+1):
            ans = max(ans, sum(sum(A[h+i][w:w+S]) for i in range(T)))
    print ans

Solution (Python):
while 1:
	n = int(raw_input())
	if n == 0:
		break
	w,h = map(int,raw_input().split(" "))
	field = [[0 for i in range(0,w+1)] for j in range(0,h+1)]
	for i in range(n):
		x,y = map(int,raw_input().split(" "))
		field[y][x] = 1
	s,t = map(int,raw_input().split(" "))
	tree_max = 0
	for i in range(1,w-s+2):
		for j in range(1,h-t+2):
			tmp_sum = 0
			for k in range(i,i+s):
				for l in range(j,j+t):
					tmp_sum += field[l][k]	
			tree_max = max(tree_max, tmp_sum)

	print tree_max

Solution (Python):
while 1:
	n = int(raw_input())
	if n == 0:
		break
	w,h = map(int,raw_input().split(" "))
	tree_loc = [map(int,raw_input().split(" ")) for i in range(n)]
	s,t = map(int,raw_input().split(" "))
	get_field = [[0 for i in range(0,w-s+2)] for j in range(0,h-t+2)] 
	for x,y in tree_loc:
		get_field[max(y-t+1,1)][max(x-s+1,1)] += 1
		if y + 1 <= h - t + 1:
			get_field[y+1][max(x-s+1,1)] -= 1
		if x + 1 <= w - s + 1:
			get_field[max(y-t+1,1)][x+1] -= 1
		if y + 1 <= h - t + 1 and x + 1 <= w - s + 1:
			get_field[y+1][x+1] += 1

	for i in range(1,w-s+1):
		for j in range(1,h-t+2):
			get_field[j][i+1] += get_field[j][i]	
	for j in range(1,h-t+1):
		for i in range(1,w-s+2):
			get_field[j+1][i] += get_field[j][i]

	tree_max = max([max(get_field[j]) for j in range(1,h-t+2)])
	print tree_max

Solution (Python):



N = int(raw_input())
while N!=0:
    (W, H) = map(int, raw_input().split())
    E = [[0]*H for i in range(W)]
    for i in range(N):
        (x, y) = map(int, raw_input().split())
        E[x-1][y-1] = 1
    (S, T) = map(int, raw_input().split())

    Max = 0
    for i in range(W-S+1):
        for j in range(H-T+1):
            Sum = 0
            for k in range(S):
                for l in range(T):
                    Sum += E[i+k][j+l]
            if Sum > Max:
                Max = Sum
    print Max
    N = int(raw_input())

Solution (Python):
while True:
    n = int(input())
    if n == 0: break
    w, h = map(int, input().split())
    trees = [[0 for i in range(h+1)] for j in range(w+1)]
    dis = [[0 for i in range(h+1)] for j in range(w+1)]
    for i in range(n):
        x, y = map(int, input().split())
        trees[x][y] = 1

    for i in range(1, w+1):
        for j in range(1, h+1):
            dis[i][j] = trees[i][j] + dis[i-1][j] \
                    + dis[i][j-1] - dis[i-1][j-1]

    s, t = map(int, input().split())

    ans = 0
    for i in range(1, w - s + 2):
        for j in range(1, h - t + 2):
            num = dis[i+s-1][j+t-1] - dis[i+s-1][j-1] \
                    - dis[i-1][j+t-1] + dis[i-1][j-1]
            ans = max(ans, num)

    print(ans)

Solution (Python):
while True:
    N = input()
    if N == 0:
        break
    W, H = map(int, raw_input().split())
    field = [[False] * W for _ in xrange(H)]
    for _ in xrange(N):
        x, y = map(int, raw_input().split())
        field[y-1][x-1] = True
    table = [[0] * (W+1) for _ in xrange(H+1)]
    for y in xrange(1,H+1):
        for x in xrange(1,W+1):
            table[y][x] = table[y-1][x] + table[y][x-1] - table[y-1][x-1]
            if field[y-1][x-1]:
                table[y][x] += 1    
    S, T = map(int, raw_input().split())
    ans = 0
    for y in xrange(T, H+1):
        for x in xrange(S, W+1):
            tmp = table[y][x] + table[y-T][x-S] - table[y-T][x] - table[y][x-S]
            ans = max(ans, tmp)
    print ans

Solution (Python):
while True:
    N = int(input())
    if N == 0: break
    W, H = map(int, input().split())
    board = [[0]*W for _ in range(H)]
    for i in range(N):
        x, y = map(lambda x:int(x)-1, input().split())
        board[y][x] = 1
    w, h = map(int, input().split())
    ans = 0
    rowSums = []
    for row in board:
        rowSum = [sum(row[:w])]
        for i in range(W-w):
            rowSum.append(rowSum[i]-row[i]+row[i+w])
        rowSums.append(rowSum)
    areaSums = [[0]*(W-w+1) for _ in range(H-h+1)]
    for i in range(len(rowSums[0])):
        areaSums[0][i] = sum(rowSums[j][i] for j in range(h))
        for j in range(H-h):
            areaSums[j+1][i] = areaSums[j][i] - rowSums[j][i] + rowSums[j+h][i]
    print(max([max(row) for row in areaSums]))

Solution (Python):

while True:
	n = int(input())
	if n == 0:
		break
	w, h = map(int, input().split())
	count = 0
	table = [[False]*h for i in range(w)]
	for i in range(n):
		x, y = map(int, input().split())
		table[x-1][y-1] = True
	s, t = map(int, input().split())

	for i in range(w-s+1):
		for j in range(h-t+1):
			rc = ([row[j:j+t] for row in table[i:i+s]])
			count = max(count, (sum(rc, []).count(True)))
	print(count)

Solution (Python):
while True:
    n = input()
    if n == 0:
        break
    W, H = map(int, raw_input().split())
    p = set()

    for _ in range(n):
        x, y = map(int, raw_input().split())
        p.add((x, y))

    S, T = map(int, raw_input().split())

    mcnt = 0
    for col in range(W - S + 1):
        for row in range(H - T + 1):
            cnt = 0
            pp = set()
            for i in range(col, col + S):
                for j in range(row, row + T):
                    if (i + 1, j + 1) in p:
                        cnt += 1
                        pp.add((i, j))
            mcnt = max(mcnt, cnt)
    print mcnt

Solution (Python):
while True:
  N = int(raw_input())
  if N == 0: break
  W,H = map(int, raw_input().split())
  matrix = [[0]*H for _ in xrange(W)]
  for _ in xrange(N):
    x,y = map(int, raw_input().split())
    matrix[x-1][y-1] = 1
  S,T = map(int, raw_input().split())
  maxcount = 0
  for i in xrange(W-S+1):
    for j in xrange(H-T+1):
      count = 0
      for a in xrange(S):
        for b in xrange(T):
          count += matrix[i+a][j+b]
      maxcount = max(maxcount, count)
  print maxcount

Solution (Python):
while 1:
    n = input()
    if n==0:
        break
    w, h = map(int, raw_input().split())
    m = [[0]*w for i in range(h)]
    l = [[0]*(w+1) for i in range(h+1)]
    for i in xrange(n):
        x, y = map(int, raw_input().split())
        m[y-1][x-1] = 1
    for i in xrange(h):
        temp = 0
        for j in xrange(w):
            temp += m[i][j]
            l[i+1][j+1] = l[i][j+1] + temp

    s, t = map(int, raw_input().split())
    ans = 0
    for i in xrange(h-t+1):
        for j in xrange(w-s+1):
            ans = max(ans, l[i+t][j+s] - l[i][j+s] - l[i+t][j] + l[i][j])
    print ans

Solution (Python):
while True:
	n=int(raw_input())
	if n==0:break
	h,w=map(int,raw_input().split())
	fi=[[0 for _ in range(w)] for _ in range(h)]
	for _ in range(n):
		a,b=map(int,raw_input().split())
		fi[a-1][b-1]=1
	s,t=map(int,raw_input().split())
	out=0
	for i in range(h-s+1):
		for j in range(w-t+1):
			co=0
			for k in range(s):
				for l in range(t):
					co+=fi[i+k][j+l]
			out=max(out,co)
	print(out)

Solution (Python):
while True:
    N = int(input())
    if N == 0: break
    W,H = map(int,input().split())
    fld = [[0 for w in range(W)] for h in range(H)]
    for i in range(N):
        x,y = map(lambda s:int(s)-1,input().split())
        fld[y][x] = 1
    cums = [[0 for w in range(W+1)] for h in range(H+1)]
    for y in range(H):
        for x in range(W):
            cums[y+1][x+1] = fld[y][x] + cums[y][x+1] + cums[y+1][x] - cums[y][x]
    S,T = map(int,input().split())
    ans = 0
    for y in range(H-T+1):
        for x in range(W-S+1):
            ans = max(ans, cums[y+T][x+S] - cums[y+T][x] - cums[y][x+S] + cums[y][x])
    print(ans)

Solution (Python):
while True:
    N = int(raw_input())

    if N == 0: break

    W, H = map(int, raw_input().split())
    table = [[0 for i in range(H)] for j in range(W)]

    for i in range(N):
        x, y = map(int, raw_input().split())
        x -= 1; y -= 1;

        table[x][y] = 1

    S, T = map(int, raw_input().split())
    ans = -1

    for x in range(W-S+1):
        for y in range(H-T+1):
            t = 0
            for i in range(S):
                for j in range(T):
                    if table[i+x][j+y] == 1:
                        t += 1

            ans = max(ans, t)

    print ans

Solution (Python):
while True:
    n = int(input())
    if n == 0:
        break

    w, h = map(int, input().split())
    field = [[False for y in range(h)] for x in range(w)]
    for i in range(n):
        x, y = map(int, input().split())
        field[x - 1][y - 1] = True

    s, t = map(int, input().split())
    ans = 0
    for x0 in range(w - s + 1):
        for y0 in range(h - t + 1):
            cnt = 0
            for dx in range(s):
                for dy in range(t):
                    if field[x0 + dx][y0 + dy]:
                        cnt += 1
            ans = max(ans, cnt)
    print(ans)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**3
eps = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

class Ruiwa():
    def __init__(self, a):
        self.H = h = len(a)
        self.W = w = len(a[0])
        self.R = r = a
        for i in range(h):
            for j in range(1,w):
                r[i][j] += r[i][j-1]

        for i in range(1,h):
            for j in range(w):
                r[i][j] += r[i-1][j]

    def search(self, x1, y1, x2, y2):
        if x1 > x2 or y1 > y2:
            return 0

        r = self.R
        rr = r[y2][x2]
        if x1 > 0 and y1 > 0:
            return rr - r[y1-1][x2] - r[y2][x1-1] + r[y1-1][x1-1]
        if x1 > 0:
            rr -= r[y2][x1-1]
        if y1 > 0:
            rr -= r[y1-1][x2]

        return rr

def main():
    rr = []

    while True:
        n = I()
        if n == 0:
            break
        w,h = LI()
        xy = [LI_() for _ in range(n)]
        s,t = LI()
        a = [[0]*w for _ in range(h)]
        for x,y in xy:
            a[y][x] = 1
        rui = Ruiwa(a)
        r = 0
        for i in range(h-t+1):
            for j in range(w-s+1):
                tr = rui.search(j,i,j+s-1,i+t-1)
                if r < tr:
                    r = tr
        rr.append(r)

    return '\n'.join(map(str, rr))


print(main())

Solution (Python):
while 1:
    n = int(raw_input())
    if n == 0: break
    w,h = map(int, raw_input().split())
    
    tree = [[0 for j in xrange(w)] for i in xrange(h)]
    for i in xrange(n):
        a,b = map(int, raw_input().split())
        tree[b-1][a-1] = 1
    s,t = map(int, raw_input().split())
    p = []
    for i in xrange(w-s+1):
        for j in xrange(h-t+1):
            temp = 0
            for k in xrange(i, s+i):
                for l in xrange(j, t+j):
                    temp += tree[l][k]
                p.append(temp)
    print max(p)

Solution (Python):
import sys
import collections

while True:
    N = int(raw_input())
    if N == 0:
        break
    W, H = map(int, sys.stdin.readline().split())
    area = [[0 for i in xrange(H)] for j in xrange(W)]
    for z in xrange(N):
        x, y = map(int, sys.stdin.readline().split())
        area[x - 1][y - 1] = 1
    S, T = map(int, sys.stdin.readline().split())


    max = -1
    for x in xrange(W - S + 1):
        for y in xrange(H - T + 1):
            sum = 0
            for s in xrange(S):
                for w in xrange(T):
                    sum += area[x + s][y + w]
            if sum > max:
                max = sum
    print max

Solution (Python):
while True:
    N=input()
    if N==0:break
    W,H=map(int,raw_input().split())
    L=[[0]*W for i in range(H)]
    for i in range(N):
        x,y=map(int,raw_input().split())
        L[y-1][x-1]=1
    S,T=map(int,raw_input().split())
    maxInt=0
    for i in range(H-T+1):
        for j in range(W-S+1):
            cnt=0
            for k in range(T):
                for l in range(S):
                    cnt+=L[i+k][j+l]
            maxInt=max(maxInt,cnt)
    print maxInt

Solution (Python):
def get_data():
    data = int(input())
    return data

def get_data_list():
    data_list = input().split()
    for i, v in enumerate(data_list):
        data_list[i] = int(v)
    return data_list

class MakePositionEasy:

    def __init__(self, data):
        self.w = data[0]
        self.h = data[1]

def get_all_persimmon_coordinate(persimmon_num):
    all_persimmon_coordinate = [None] * persimmon_num
    for i in range(persimmon_num):
        all_persimmon_coordinate[i] = tuple(get_data_list())
    all_persimmon_coordinate = set(all_persimmon_coordinate)
    return all_persimmon_coordinate

def make_persimmon_map(area_size, all_persimmon_coordinate):
    persimmon_map = [[0] * (area_size.w + 1) for i in range(area_size.h + 1)]
    for w in range(1, area_size.w+1):
        current_line_count = 0
        for h in range(1, area_size.h+1):
            if (w,h) in all_persimmon_coordinate:
                current_line_count += 1
            bef_num = persimmon_map[h][w-1]
            persimmon_map[h][w] = (bef_num + current_line_count)
    return persimmon_map

def get_max_num(persimmon_map,area_size, given_size):
    max_num = 0
    for w in range(given_size.w, area_size.w+1):
        for h in range(given_size.h, area_size.h+1):
            persimmon_num = calculate_persiommon_num(persimmon_map, given_size, w, h)
            if persimmon_num > max_num:
                max_num = persimmon_num
    return max_num

def calculate_persiommon_num(persimmon_map , given_size, w, h):
    persimmon_num = persimmon_map[h][w]
    persimmon_num -= persimmon_map[h-given_size.h][w]
    persimmon_num -= persimmon_map[h][w-given_size.w]
    persimmon_num += persimmon_map[h-given_size.h][w-given_size.w]
    return persimmon_num


if __name__ == "__main__":
    while True:
        persimmon_num = get_data()
        if persimmon_num == 0:
            break
        area_size = MakePositionEasy(get_data_list())
        all_persimmon_coordinate = get_all_persimmon_coordinate(persimmon_num)
        given_size = MakePositionEasy(get_data_list())
        persimmon_map = make_persimmon_map(area_size, all_persimmon_coordinate)
        max_num = get_max_num(persimmon_map,area_size, given_size)
        print(max_num)

Solution (Python):
while(True):
	N = int(input())
	if N ==0 :break
	W, H = map(int, input().split())
	area = [ [ 0 for i in range(W)]for i in range(H)]
	ans_max = 0
	for i in range(N):
		w, h = map(int, input().split())
		area[h-1][w-1] = 1
	S, T = map(int, input().split())
	for i in range(H-T+1):
		for j in range(W-S+1):
			ans = 0
			for k in range(i,i+T):
				ans += sum(area[k][j:j+S])
			if ans_max<ans:
				ans_max = ans
	print(ans_max)

Solution (Python):
import sys
input = sys.stdin.readline

def main():
    while True:
        N = int(input())
        if N == 0:
            return
        W, H = map(int, input().split())
        board = [[0] * (W+1) for i in range(H+1)]
        for i in range(N):
            x, y = map(int, input().split())
            board[y][x] = 1
        for i in range(1, H+1):
            for j in range(W+1):
                board[i][j] += board[i-1][j]
        for j in range(1, W+1):
            for i in range(H+1):
                board[i][j] += board[i][j-1]
        S, T = map(int, input().split())
        ans = 0
        for y in range(1, H-T+2):
            for x in range(1, W-S+2):
                tx = x + S - 1
                ty = y + T - 1
                ans = max(ans, board[ty][tx] - board[ty][x-1] - board[y-1][tx] + board[y-1][x-1])
        print(ans)
        
        


if __name__ == "__main__":
    main()

Solution (Python):
def main(n):
    w, h = map(int, input().split())
    xy = [list(map(lambda x:int(x)-1, input().split())) for i in range(n)]
    s, t = map(int, input().split())
    field = [[0] * w for i in range(h)]
    for x, y in xy:
        field[y][x] = 1
    ans = 0
    for y in range(h - t + 1):
        for x in range(w - s + 1):
            b = 0
            for yi in range(t):
                for xi in range(s):
                    b += field[y + yi][x + xi]
            ans = max(ans, b)
    print(ans)
while 1:
    n = int(input())
    if n == 0:
        break
    main(n)

Solution (Python):


from collections import deque

while 1:
    N = int(input())
    if N == 0:
        break
    W,H = map(int,input().split())
    P = [list(map(int,input().split())) for _ in range(N)]
    S,T = map(int,input().split())
    M = [[0 for _ in range(W)] for _ in range(H)]
    for i in P:
        M[i[1]-1][i[0]-1] = 1
    count = [[0 for _ in range(W - S + 1)] for _ in range(H - T + 1)]
    for i in range(H-T+1):
        for j in range(W-S+1):
            for k in range(T):
                for l in range(S):
                    if M[i+k][j+l] == 1:
                        count[i][j] += 1
    m = 0
    for i in range(H - T + 1):
        s = max(count[i])
        if s > m:
            m = s
    print(m)

Solution (Python):
while True:
  N = int(input())
  if N==0:
    break
  W,H = map(int,input().split())
  data = [[0 for i in range(W)] for j in range(H)]
  for i in range(N):
    x,y = map(int,input().split())
    data[y-1][x-1] = 1
  S,T = map(int,input().split())
  ans = 0
  for h in range(H-T+1):
    for w in range(W-S+1):
      
      a = 0
      for x in range(T):
        for y in range(S):
          if data[h+x][w+y]==1:
            a+=1
      ans = max(ans,a)
  print(ans)