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>
using namespace std;

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<58;
const double eps=1e-6;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    while(true){
        int n;
        cin >> n;
        if(n==0) break;
        vector<long double> xs(n),ys(n);
        rep(i,0,n) cin >> xs[i] >> ys[i];

        auto count=[&](const long double x,const long double y){
            int res=0;
            rep(i,0,n) if((xs[i]-x)*(xs[i]-x)+(ys[i]-y)*(ys[i]-y)<=1+eps) ++res;
            return res;
        };

        int ans=0;
        rep(i,0,401){
            const long double y=10.*i/400;
            rep(j,0,n){
                const long double tmp=1-(ys[j]-y)*(ys[j]-y);
                if(tmp<0) continue;
                const long double x1=xs[j]-sqrtl(tmp),x2=xs[j]+sqrt(tmp);
                ans=max({ans,count(x1,y),count(x2,y)});
            }
        }
        cout << ans << endl;
    }
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    cout << fixed << setprecision(8);
    solve();
    return 0;
}

C++: #include <bits/stdc++.h>
 
using namespace std;
 
#define EPS 1e-8
typedef complex<double> Point;
 
int main(){
    int N;
    while(cin >> N,N){
	Point p[N];
	for(int i = 0 ; i < N ; i++){
	    cin >> p[i].real() >> p[i].imag();
	}
	int res = 1;
	for(int i = 0 ; i < N-1 ; i++){
	    for(int j = i+1 ; j < N ; j++){
		Point np = p[j]-p[i];
		double d = abs(np);
		if(d + EPS > 2.0){ continue; }
		np /= d;
		np *= Point(0,1);
		Point cp = (p[i]+p[j])/2.0;
		Point v = sqrt(1.0-d*d/4.0)*np;
		int cnt = 2;
		Point center = cp + v;
		for(int k = 0 ; k < N ; k++){
		    if(i == k || j == k) continue;
		    Point diff = center-p[k];
		    if(norm(diff) < 1.0 + EPS){
			cnt++;
		    }
		}
		res = max(res,cnt);
	    }
	}
	cout << res << endl;
    }
    return 0;
}

C++: #include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

class Point
{
private:

	double x_;
	double y_;

public:

	Point() : x_(0), y_(0) { }

	explicit Point(double x, double y) : x_(x), y_(y) { }

	explicit Point(double x1, double y1, double x2, double y2) : x_(x2 - x1), y_(y2 - y1) { }

	double x() { return x_; }
	double y() { return y_; }

	double x() const { return x_; }
	double y() const { return y_; }

	Point& operator+= (const Point& p) { x_ += p.x_; y_ += p.y_; return *this; }
	Point& operator-= (const Point& p) { x_ -= p.x_; y_ -= p.y_; return *this; }

	Point& operator*= (double s) { x_ *= s; y_ *= s; return *this; }
	Point& operator/= (double s) { x_ /= s; y_ /= s; return *this; }

	friend bool operator== (const Point& p1, const Point& p2) { return p1.x_ == p2.x_ && p1.y_ == p2.y_; }
	friend bool operator!= (const Point& p1, const Point& p2) { return !(p1 == p2); }

	friend Point operator+ (const Point& p1, const Point& p2) { return Point(p1.x_ + p2.x_, p1.y_ + p2.y_); }
	friend Point operator- (const Point& p1, const Point& p2) { return Point(p1.x_ - p2.x_, p1.y_ - p2.y_); }

	friend Point operator* (const Point& p, double s) { return Point(p.x_ * s, p.y_ * s); }
	friend Point operator/ (const Point& p, double s) { return Point(p.x_ / s, p.y_ / s); }

	friend Point operator* (double s, const Point& p) { return Point(p.x_ * s, p.y_ * s); }
};

double distance(const Point& p1, const Point& p2)
{
	return sqrt(pow(p2.x() - p1.x(), 2) + pow(p2.y() - p1.y(), 2));
}

int main()
{
	int N; double X, Y;

	vector<Point> Plane;

	while (true)
	{
		cin >> N;

		if (N == 0) { break; }

		Plane.clear();

		for (int i = 0; i < N; i++)
		{
			cin >> X >> Y;

			Plane.push_back(Point(X, Y));
		}

		int max_ = 1;

		int count_;

		for (int i = 0; i < N; i++)
		{
			for (int j = i + 1; j < N; j++)
			{
				count_ = 1;

				if (distance(Plane[i], Plane[j]) < 2)
				{
					double vx = (Plane[j].x() - Plane[i].x()) / 2;
					double vy = (Plane[j].y() - Plane[i].y()) / 2;

					double vd = sqrt(vx * vx + vy * vy);

					double dist = sqrt(1 - vd * vd) / vd;

					double rx = Plane[i].x() + vx + -vy * dist;
					double ry = Plane[i].y() + vy + vx * dist;

					Point R(rx, ry);

					count_ = 2;

					for (int k = 0; k < N; k++)
					{
						if (k != i && k != j)
						{
							if (distance(Plane[k], R) < 1)
							{
								count_++;
							}
						}
					}
				}

				max_ = max(count_, max_);

				count_ = 0;

				if (distance(Plane[i], Plane[j]) < 2)
				{
					double vx = (Plane[j].x() - Plane[i].x()) / 2;
					double vy = (Plane[j].y() - Plane[i].y()) / 2;

					double vd = sqrt(vx * vx + vy * vy);

					double dist = sqrt(1 - vd * vd) / vd;

					double rx = Plane[i].x() + vx + vy * dist;
					double ry = Plane[i].y() + vy + -vx * dist;

					Point R(rx, ry);

					count_ = 2;

					for (int k = 0; k < N; k++)
					{
						if (k != i && k != j)
						{
							if (distance(Plane[k], R) < 1)
							{
								count_++;
							}
						}
					}
				}

				max_ = max(count_, max_);
			}
		}

		cout << max_ << endl;
	}

	return 0;
}