Go: package main

import (
	"fmt"
	"math"
	"math/cmplx"
)

func main() {
	for {
		var n int
		fmt.Scan(&n)

		if n == 0 {
			return
		}

		arr := make([]complex128, n)

		for i := 0; i < n; i++ {
			var x, y float64

			fmt.Scanf("%f%f", &x, &y)

			arr[i] = complex(x, y)
		}

		max := 1
		for i := 0; i < n; i++ {
			for j := i + 1; j < n; j++ {
				sub := arr[j] - arr[i]

				if cmplx.Abs(sub) >= 2 {
					continue
				}
				sum := arr[j] + arr[i]

				v := 1
				{
					halfd := cmplx.Abs(sub / 2)

					center := sum/2 + sub*cmplx.Rect(math.Sqrt(1-halfd*halfd)/cmplx.Abs(sub), float64(v)*math.Pi/2)

					counter := 0
					for k := 0; k < n; k++ {
						if i == k || j == k || cmplx.Abs(arr[k]-center) <= 1 {
							counter++
						}
					}
					if max < counter {
						max = counter
					}
				}

				v = -1
				{
					halfd := cmplx.Abs(sub / 2)

					center := sum/2 + sub*cmplx.Rect(math.Sqrt(1-halfd*halfd)/cmplx.Abs(sub), float64(v)*math.Pi/2)

					counter := 0
					for k := 0; k < n; k++ {
						if i == k || j == k || cmplx.Abs(arr[k]-center) <= 1 {
							counter++
						}
					}
					if max < counter {
						max = counter
					}
				}

			}
		}

		fmt.Println(max)
	}
}

C++: #include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	while (cin >> n, n) {
		vector<double> x(n), y(n);
		int ans = -1;
		REP(i, n)cin >> x[i] >> y[i];
		REP(i, n) {
			REP(j, n) {
				if (i == j)continue;
				double ax = x[j] - x[i], ay = y[j] - y[i];
				if (ax*ax + ay*ay > 4)continue;
				double px = x[i] + ax / 2 + sqrt((4 - (ax*ax + ay*ay)) / (4 * (ax*ax + ay*ay)))*ay,
				py = y[i] + ay / 2 - sqrt((4 - (ax*ax + ay*ay)) / (4 * (ax*ax + ay*ay)))*ax;
				int cnt = 0;
				REP(k, n) {
					if ((x[k] - px)*(x[k] - px) + (y[k] - py)*(y[k] - py) < 1+EPS)cnt++;
				}
				ans = max(ans, cnt);
			}
		}
		REP(i, n) {
			REP(j, n) {
				if (i == j)continue;
				double ax = x[j] - x[i], ay = y[j] - y[i];
				if (ax*ax + ay*ay > 4)continue;
				double px = x[i] + ax / 2 - sqrt((4 - (ax*ax + ay*ay)) / (4 * (ax*ax + ay*ay)))*ay,
					py = y[i] + ay / 2 + sqrt((4 - (ax*ax + ay*ay)) / (4 * (ax*ax + ay*ay)))*ax;
				int cnt = 0;
				REP(k, n) {
					if ((x[k] - px)*(x[k] - px) + (y[k] - py)*(y[k] - py) < 1+EPS)cnt++;
				}
			
				ans = max(ans, cnt);
			}
		}
		cout <<ans << endl;
	}
}

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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
constexpr int DX[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int sgn(int x) { return (x > 0) - (x < 0); }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

signed main() {
    while (true) {
        int N;
        cin >> N;
        if (N == 0) { break; }
        vector<complex<double>> points;
        rep(i, N) {
            double X, Y;
            cin >> X >> Y;
            points.push_back({X, Y});
        }
        int ans = 1;
        rep(i, N) {
            rep(j, i) {
                if (abs(points[i] - points[j]) > 2) { continue; }
                complex<double> d = (points[i] - points[j]) / 2.0;
                complex<double> v = d * sqrt(1 - norm(d)) / abs(d) * polar(1.0, PI / 2);
                auto count = [&](complex<double> center) {
                    double eps = 1e-8;
                    int ret = 0;
                    rep(k, N) { if (abs(points[k] - center) < 1 + eps) { ret++; }}
                    return ret;
                };
                chmax(ans, count(points[j] + d + v));
                chmax(ans, count(points[j] + d - v));
            }
        }
        cout << ans << endl;

    }
}