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 <cstdio>
#include <complex>
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;

typedef complex<double> coor;

#define EPS 1e-9

double in_cir(coor o, coor x)
{
  return abs(x - o);
}

int search(vector<coor> P)
{
  int mx = 0;
  /*for (int i = 0; i < P.size(); i++) {
    printf("%lf, %lf\n", P[i].real(), P[i].imag());
    }*/
  for (int i = 0; i < P.size(); i++) {
    for (int j = i + 1; j < P.size(); j++) {
      for (int k = 0; k < 2; k++) {
	if (abs(P[i] - P[j]) - 2.0 > -EPS) {continue;}
	coor d = coor(P[i].imag() - P[j].imag(),
		      -(P[i].real() - P[j].real()));
	if (k == 1) {d = -d;}
	d /= abs(d);
	d *= sqrt(1 - norm(P[i] - P[j]) / 4);
	//printf("abs(d) = %lf\n", abs(d));
	d += (P[i] + P[j]) / 2.0;
	//printf("%lf, %lf\n", d.real(), d.imag());
	int ctr = 2;
	for (int l = 0; l < P.size(); l++) {
	  //printf("%lf\n", in_cir(d, P[l]));
	  if (l == i || l == j) {continue;}
	  if (in_cir(d, P[l]) - 1.0 < -EPS) {
	    ctr++;
	  }
	}
	//printf("_%d\n", ctr);
	mx = max(ctr, mx);
	
      }
    }
  }
  return mx;
}

int main()
{
  int N;
  while (scanf("%d ", &N) == 1) {
    if (N == 0) {
      break;
    }
    vector<coor> P(N);
    for (int i = 0; i < N; i++) {
      double x, y;
      scanf("%lf %lf ", &x, &y);
      P[i] = coor(x, y);
    }
    printf("%d\n", search(P));
  }
  return 0;
}

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

#define fs first
#define sc second

const LL MOD = 1e9+7;
const double EPS = 1e-10;

template<class T>bool chmax(T &a, const T &b) {
    if (a < b) { a = b; return true; }
    return false;
}
template<class T>bool chmin(T &a, const T &b) {
    if (b < a) { a = b; return true; }
    return false;
}

// input
template<typename T>
void input(T& a) { cin >> a; }
template<typename T,typename... Ts>
void input(T& a,Ts&... ts) {
    input<T>(a);
    input<T>(ts...);
}

// std::vector Declaration
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// std::vector Declaration and Initialization
template<typename T>
vector<T> make_vector(size_t a, T x) { return vector<T>(a, x); }
template<typename T, typename U, typename... Ts>
auto make_vector(size_t a, U b, Ts... ts) {
    return vector<decltype(make_vector<T>(b,ts...))>(a,make_vector<T>(b,ts...));
}

// std::vector Input
template<typename T>
istream& operator>>(istream& is, vector<T>& v) {
    for (auto &e : v) {
        is >> e;
    }
    return is;
}

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    bool a = 1;
    for (auto e : v) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::array Debug
template<typename T, size_t n>
ostream& operator<<(ostream& os, const array<T, n>& v) {
    os << "[";
    bool a = 1;
    for (auto e : v) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::deque Debug
template<typename T>
ostream& operator<<(ostream& os, const deque<T>& d) {
    os << "[";
    bool a = 1;
    for (auto e : d) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << " " << p.second << ")";
    return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::multiset Debug
template<typename T>
ostream& operator<<(ostream& os, const multiset<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
    os << "{";
    bool a = 1;
    for (auto e : mp) {
        os << (a ? "" : " ");
        os << e.first << ":" << e.second;
        a = 0;
    }
    os << "}";
    return os;
}

// std::tuple Debug
template<int N, class Tuple>
void out(ostream& os, const Tuple& t){}
template<int N, class Tuple, class H, class ...Ts>
void out(ostream& os, const Tuple& t) {
    if (N) os << " ";
    os << get<N>(t);
    out<N+1,Tuple,Ts...>(os, t);
}
template<class ...Ts>
ostream& operator<<(ostream& os, const tuple<Ts...>& t) {
    os << "(";
    out<0,tuple<Ts...>,Ts...>(os, t);
    os << ")";
    return os;
}

// Debug
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl

// Weighted edge
template<typename T>
struct edge {
    int src, to;
    T cost;

    edge(int to, T cost) : src(-1), to(to), cost(cost) {}
    edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

    edge &operator=(const int &x) {
        to = x;
        return *this;
    }

    operator int() const { return to; }

    friend ostream& operator<<(ostream& os, const edge& e) {
        return os << "(" << e.src << "->" << e.to << ":" << e.cost << ")";
    }
};

template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using MatrixGraph = vector<vector<T>>;

int main()
{
    while (true) {
        int n; cin >> n;
        if (n == 0) {
            break;
        }

        vector<complex<double>> p(n);
        for (int i = 0; i < n; ++i) {
            double x, y; cin >> x >> y;
            p[i] = {x, y};
        }

        int ans = 1;
        for (int i = 0; i < n; ++i) {
            for (int j = i+1; j < n; ++j) {
                if (abs(p[i] - p[j]) > 2) {
                    continue;
                }
                complex<double> m = (p[i] + p[j]) / 2.,
                                d = (p[i] - p[j]) * polar(1.,M_PI/2.);
                d /= abs(d);
                d *= sqrt(1. - norm(p[i] - m));

                for (auto t : {-1., 1.}) {
                    complex<double> c = m + t * d;

                    int cnt = 0;
                    for (int k = 0; k < n; ++k) {
                        if (abs(p[k] - c) <= 1 + EPS) {
                            ++cnt;
                        }
                    }
                    chmax(ans, cnt);
                }
            }
        }
        cout << ans << endl;
    }

    return 0;
}