Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
	)

var scanner = bufio.NewScanner(os.Stdin)

const INF = 0x7FFFFFFF

var (
	direction1 = [][]int{ // 奇数段目の移動方向
		{-1, 0}, {1, 0}, {0, -1}, {0, 1}, {1, -1}, {1, 1},
	}
	direction2 = [][]int{ // 偶数段目の移動方向
		{-1, -1}, {0, -1}, {1, 0}, {0, 1}, {-1, 1}, {-1, 0},
	}
)

func main() {
	for scanner.Scan() {
		buf := strings.Split(scanner.Text(), " ")
		m, _ := strconv.Atoi(buf[0])
		n, _ := strconv.Atoi(buf[1])
		if m == 0 && n == 0 {
			break
		}
		// initialize district_map
		/*
			district_map = [
				[-1, -1,  -1,  -1,  -1]
				[-1, INF, INF, INF, -1]
				[-1, INF, INF, INF, -1]
				[-1, INF, INF, INF, -1]
				[-1, INF, INF, INF, -1]
				[-1, -1,  -1,  -1,  -1]
			]
		*/
		district_map := make([][]int, n+2)
		for i := range district_map {
			district_map[i] = make([]int, m+2)
		}
		tmp1 := make([]int, m+2)
		for i := range tmp1 {
			tmp1[i] = -1
		}
		district_map[0] = tmp1
		district_map[n+1] = tmp1
		for i := 1; i < n+1; i++ {
			district_map[i] = make([]int, m+2)
			district_map[i][0] = -1
			district_map[i][m+1] = -1
			for j := 1; j < m+1; j++ {
				district_map[i][j] = INF
			}
		}

		scanner.Scan()
		s, _ := strconv.Atoi(scanner.Text())
		for i := 0; i < s; i++ {
			scanner.Scan()
			buf_ := strings.Split(scanner.Text(), " ")
			x, _ := strconv.Atoi(buf_[0])
			y, _ := strconv.Atoi(buf_[1])
			Search(Point{x, y}, district_map, m, n)
		}
		ans := 0
		scanner.Scan()
		t, _ := strconv.Atoi(scanner.Text())
		for i := 0; i < t; i++ {
			scanner.Scan()
			buf__ := strings.Split(scanner.Text(), " ")
			x, _ := strconv.Atoi(buf__[0])
			y, _ := strconv.Atoi(buf__[1])
			z := Count(Point{x, y}, district_map, m, n)
			ans = max(ans, z)
		}
		fmt.Println(ans)
	}
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

type Point struct {
	x, y int
}

type Entry struct {
	hop   int
	point Point
}

func Search(p Point, mp [][]int, m, n int) {
	que := make([]Entry, 0)
	que = append(que, Entry{0, p})
	check := make([][]bool, n+2)
	for i := range check {
		check[i] = make([]bool, m+2)
	}
	check[p.y][p.x] = true
	mp[p.y][p.x] = 0
	var direction [][]int
	for len(que) > 0 {
		tmp := que[0]
		que = que[1:]
		dist, point := tmp.hop, tmp.point
		if point.y%2 == 0 {
			direction = direction1
		} else {
			direction = direction2
		}
		for _, d := range direction {
			nx, ny := point.x+d[0], point.y+d[1]
			if !check[ny][nx] && mp[ny][nx] != -1 {
				check[ny][nx] = true
				if mp[ny][nx] > dist+1 {
					mp[ny][nx] = dist + 1
				}
				que = append(que, Entry{dist + 1, Point{nx, ny}})
			}
		}
	}
}

func Count(p Point, mp [][]int, m, n int) int {
	que := make([]Entry, 0)
	que = append(que, Entry{0, p})
	check := make([][]bool, n+2)
	for i := range check {
		check[i] = make([]bool, m+2)
	}
	check[p.y][p.x] = true
	ans := 1
	var direction [][]int
	for len(que) > 0 {
		tmp := que[0]
		que = que[1:]
		dist, point := tmp.hop, tmp.point
		if point.y%2 == 0 {
			direction = direction1
		} else {
			direction = direction2
		}
		for _, d := range direction {
			nx, ny := point.x+d[0], point.y+d[1]
			if !check[ny][nx] && mp[ny][nx] != -1 {
				check[ny][nx] = true
				if mp[ny][nx] > dist+1 {
					ans++
				}
				que = append(que, Entry{dist + 1, Point{nx, ny}})
			}
		}
	}
	return ans
}

C++: #include <iostream>
#include <utility>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
using namespace std;

typedef pair<int,int> pii;
#define x first
#define y second

int main() {
	int m, n;
	while(cin >> m >> n, m || n) {
		int s, t;
		vector<pii> v0, v1;
		cin >> s;
		for(int i = 0; i < s; i++) {
			pii a;
			cin >> a.x >> a.y;
			a.x--; a.y--;
			v0.push_back(a);
		}
		cin >> t;
		for(int i = 0; i < t; i++) {
			pii a;
			cin >> a.x >> a.y;
			a.x--; a.y--;
			v1.push_back(a);
		}

		int ans = 0;
		for(int i = 0; i < v1.size(); i++) {
			v0.push_back(v1[i]);
			int tmp = 0;
			for(int j = 0; j < n; j++) {
				for(int k = 0; k < m; k++) {
					bool valid = true;
					int val = -1;
					int mn = 10000;
					for(int l = 0; l < v0.size(); l++) {
						int h;
						int w;
						h = abs(v0[l].y - j);
						w = fabs((v0[l].x + (v0[l].y % 2) / 2.0) - (k + (j % 2) / 2.0)) - h / 2.0 + 1e-6;
						if(w < 0)
							w = 0;
						if(mn == h + w)
							valid = false;
						else if(mn > h + w) {
							val = l;
							mn = h + w;
							valid = true;
						}
					}
					if(valid && val == v0.size() - 1)
						tmp++;
				}
			}

			ans = max(ans, tmp);
			v0.pop_back();
		}
		cout << ans << endl;
	}
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

struct Point {
	int x, y, s;
	Point(int x_, int y_, int s_) : x(x_), y(y_), s(s_) {}
};

int dx[2][6] = {
		{1, 1, 1, 0, -1, 0}, 
		{0, 1, 0, -1, -1, -1}
	},
	dy[6] = {-1, 0, 1, 1, 0, -1},
	W, H, S, T;

bool vis[110][110], grid[110][110];

vector< Point > search(int sx, int sy) {
	memset(vis, 0, sizeof(vis));
	
	queue< Point > que;
	que.push(Point(sx, sy, 0));
	vis[sy][sx] = 1;
	
	vector< Point > res;
	int mns = int(1e9);
	
	while (!que.empty()) {
		Point p = que.front(); que.pop();
		
		if (mns < p.s) break;
		
		if (grid[p.y][p.x]) {
			mns = p.s;
			res.push_back(p);
			continue;
		}
		
		for_(d,0,6) {
			int nx = p.x + dx[p.y % 2][d], ny = p.y + dy[d];
			if (nx <= 0 || W < nx || ny <= 0 || H < ny) continue;
			if (vis[ny][nx]) continue;
			vis[ny][nx] = 1;
			que.push(Point(nx, ny, p.s + 1));
		}
	}
	
	return res;
}

int main() {	
	while (cin >> W >> H, W) {
		memset(grid, 0, sizeof(grid));
		
		cin >> S;		
		for_(i,0,S) {
			int x, y;
			cin >> x >> y;
			grid[y][x] = 1;
		}
		
		int ans = 0;
		
		cin >> T;
		for_(i,0,T) {
			int x, y;
			cin >> x >> y;
			grid[y][x] = 1;
			
			int cnt = 0;
			for_(yy,1,H+1) for_(xx,1,W+1) {
				vector< Point > vp = search(xx, yy);
				if (vp.size() > 1) continue;				
				if (vp[0].x == x && vp[0].y == y) ++cnt;
			}
			
			grid[y][x] = 0;
			ans = max(ans, cnt);
		}
		
		cout << ans << endl;
	}
}

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

int getdis(const pair<int, int>l, const pair<int, int>r) {

	int dy =r.second - l.second;
	int dx =r.first - l.first;
	if (l.second % 2 == r.second % 2) {
		assert(abs(dy) % 2 == 0);
		if (abs(dx) <= abs(dy) / 2)return abs(dy);
		else {
			return  abs(dy) + (abs(dx) - abs(dy) / 2);
		}
	}
	else if (l.second % 2==0 && r.second % 2 == 1) {
		{
			int amin = 1e8;
			int y = l.second > r.second ? -1 : 1;
			for (int x = -1; x <= 0; ++x) {
				amin = min(amin, 1 + getdis(make_pair(l.first + x, l.second + y), r));
			}
			
			return amin;
		}
	}
	else {
		{
			int amin = 1e8;
			int y = l.second > r.second ? -1 : 1;
			for (int x = 0; x <= 1; ++x) {
				amin = min(amin, 1 + getdis(make_pair(l.first + x, l.second + y), r));
			
			}
			return amin;
		}
	}
}

int main() {
	while (1) {
		int W, H; cin >> W >> H;
		if (!W)break;
		vector<vector<int>>field(H, vector<int>(W, 100000));
		int S; cin >> S;
		for (int i = 0; i < S; ++i) {
			int x, y; cin >> x >> y; x--; y--;
			for (int j = 0; j < H; ++j) {
				for (int k = 0; k < W; ++k) {
					field[j][k] = min(field[j][k], getdis(make_pair(x, y), make_pair(k, j)));
				}
			}
		}
		int T; cin >> T;
		int ans = 0;
		for (int i = 0; i < T; ++i) {
			int p, q; cin >> p >> q; p--; q--;
			int sum = 0;
			for (int j = 0; j < H; ++j) {
				for (int k = 0; k < W; ++k) {
					if (field[j][k] > getdis(make_pair(p,q), make_pair(k, j)))sum++;

				}
			}
			ans = max(ans, sum);
		}
		cout << ans << endl;
	}
	return 0;
}