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 <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <complex>

using namespace std;
typedef long long ll;
typedef complex<double> Point;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define DEC(i, s) for (int i = (s); i >= 0; i--)

#define SIZE(v) (int)((v).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define FIND(m, w) ((m).find(w) != (m).end())

int n;
int ans;
double R;
Point points[3000];
pair<double, int> radian[30000];
bool used[3000];

int calc(int s) {
  int ret = 1;
  int m = 0;
  REP(i, n) {
    double d = abs(points[s] - points[i]) / 2.0;
    if (i == s || d * 2.0 > R * 2) { continue; }
    Point center = (points[s] + points[i]) / 2.0;
    Point vect = (points[i] - points[s]) * Point(0, -1);
    vect /= abs(vect);
    double l = sqrt(R * R - d * d);
    Point c1 = center + vect * l;
    Point c2 = center - vect * l;
    double arg1 = arg(c1 - points[s]) - EPS;
    double arg2 = arg(c2 - points[s]) + EPS;
    radian[m++] = pair<double, int>(arg1 + 0 * PI, (i + 1));
    radian[m++] = pair<double, int>(arg2 + 0 * PI, -(i + 1));
  }
  if (m / 2 < ans - 1) { return 0; }
  sort(radian, radian + m);
  MEMSET(used, false);
  int lsum = 1;
  REP(iter, 2) {
    REP(i, m) {
      int index = abs(radian[i].second) - 1;
      bool start = radian[i].second > 0 ? true : false;
      if (used[index] && !start) {
        used[index] = false;
        lsum--;
      } else if (!used[index] && start) {
        used[index] = true;
        lsum++;
      }
      ret = max(ret, lsum);
    }
  }
  return ret;
}

int main() {
  R = 1.0;
  while (scanf("%d", &n), n) {
    REP(i, n) {
      double x, y;
      scanf("%lf %lf", &x, &y);
      points[i] = Point(x, y);
    }
    ans = 0;
    REP(i, n) {
      ans = max(ans, calc(i));
    }
    printf("%d\n", ans);
  }
}