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<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<iomanip>
using namespace std;
static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;
static const int MAX_N = 300;

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

class Point{
	public:
		double x, y;

		Point(double x = 0, double y = 0): x(x), y(y) {}

		Point operator + (Point p){ return Point(x + p.x, y + p.y);}
		Point operator - (Point p){ return Point(x - p.x, y - p.y);}
		Point operator * (double a){ return Point(a * x, a * y);}
		Point operator / (double a){ return Point(x / a, y / a);}

		double abs(){ return sqrt(norm());}
		double norm(){ return x * x + y * y;}

		bool operator < (const Point &p) const{
			return x != p.x ? x < p.x : y < p.y;
		}

		bool operator == (const Point &p) const{
			return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
		}
};

struct Segment {
	Point p1, p2;
};
typedef Segment Line;

class Circle{
	public:
		Point c;
		double r;
		Circle(Point c = Point(), double r = 0.0): c(c), r(r) {}
};

typedef Point Vector;
typedef vector<Point> Polygon;

double dot(Vector a, Vector b){
	return a.x * b.x + a.y * b.y;
}
double cross(Vector a, Vector b){
	return a.x * b.y - a.y * b.x;
}

Point project(Segment s, Point p){
	Vector base = s.p2 - s.p1;
	double r = dot(p - s.p1, base) / base.norm();
	return s.p1 + base * r;
}
Point reflect(Segment s, Point p){
	return p + (project(s, p) - p) * 2.0;
}
int ccw(Point p0, Point p1, Point p2){
	Vector a = p1 - p0;
	Vector b = p2 - p0;
	if(cross(a, b) > EPS) return COUNTER_CLOCKWISE;
	if(cross(a, b) < -EPS) return CLOCKWISE;
	if(dot(a, b) < -EPS) return ONLINE_BACK;
	if(a.norm() < b.norm()) return ONLINE_FRONT;

	return ON_SEGMENT;
}

Point getCrossPoint(Segment s1, Segment s2){
	Vector base = s2.p2 - s2.p1;
	double d1 = abs(cross(base, s1.p1 - s2.p1));
	double d2 = abs(cross(base, s1.p2 - s2.p1));
	double t = d1 / (d1 + d2);
	return s1.p1 + (s1.p2 - s1.p1) * t;
}

double getDistance(Point a, Point b){
	return (a - b).abs();
}

double arg(Vector p){return atan2(p.y, p.x);}
Vector polar(double a, double r){return Point(cos(r) * a, sin(r) * a);}

pair<Point, Point> getCrossPoints(Circle c1, Circle c2){
	double d = (c1.c - c2.c).abs();
	double a = acos((c1.r * c1.r + d * d - c2.r * c2.r) / (2 * c1.r * d));
	double t = arg(c2.c - c1.c);
	return make_pair(c1.c + polar(c1.r, t + a), c1.c + polar(c1.r, t - a));
}

bool comp(const Point &p1, const Point &p2){
	return equals(p1.x, p2.x) ? (p1.y < p2.y) : (p1.x < p2.x);
}
int main(){
	int N;
	for(;;){
		cin >> N;
		if(N == 0) break;
		Point xy[MAX_N];
		for(int i = 0; i < N; i++){
			cin >> xy[i].x >> xy[i].y;
		}
		sort(xy, xy + N, comp);
		int ans = 1;
		for(int i = 0; i < N; i++){
			for(int j = i + 1; j < N; j++){
				if(fabs(xy[i].x - xy[j].x) > 2.0) break;
				if(getDistance(xy[i], xy[j]) < 2.0) ans = max(ans, 2);
				pair<Point, Point> pp = getCrossPoints((Circle){xy[i], 20.0}, (Circle){xy[j], 20.0});
				for(int k = j + 1; k < N; k++){
					pair<Point, Point> pp2 = getCrossPoints((Circle){xy[i], 20.0}, (Circle){xy[k], 20.0});
					Point c = getCrossPoint((Line){pp.first, pp.second}, (Line){pp2.first, pp2.second});
					double r = getDistance(c, xy[i]);
					if(r > 1.0) continue;
					int cnt = 3;
					for(int l = 0; l < N; l++){
						if(l == i || l == j || l == k) continue;
						if(xy[l].x > c.x && getDistance(xy[l], c) > r) break;
						if(getDistance(c, xy[l]) < r) cnt++;
					}
					ans = max(ans, cnt);
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#include<time.h>
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-7
#define REP(i,m) for(long long i=0; i<(ll)m; i++)
#define FOR(i,n,m) for(long long i=n; i<(ll)m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

struct Po {
	ld x;
	ld y;
};

ld dist(Po p, Po q) {
	return sqrt(pow(p.x-q.x,2)+pow(p.y-q.y,2));
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	while(1) {
		ll n;
		cin>>n;
		if(n==0) break;
		vector<Po> p(n);
		REP(i,n) cin>>p[i].x>>p[i].y;
		ll ans=1;
		REP(i,n) {
			FOR(j,i+1,n) {
				ld d=dist(p[i],p[j]);
				//cout<<i<<" "<<j<<":"<<d<<endl;
				if(d>2) continue;
				Po diff; diff.x=p[j].x-p[i].x; diff.y=p[j].y-p[i].y;
				diff.x/=d; diff.y/=d;
				ld th=acos(d/2);
				//cout<<th<<endl;
				Po c1=p[i],c2=p[i];
				c1.x+=cos(th)*diff.x-sin(th)*diff.y;
				c1.y+=sin(th)*diff.x+cos(th)*diff.y;
				c2.x+=cos(-th)*diff.x-sin(-th)*diff.y;
				c2.y+=sin(-th)*diff.x+cos(-th)*diff.y;
				//cout<<c1.x<<" "<<c1.y<<" "<<dist(p[i],c1)<<" "<<dist(p[j],c1)<<endl;
				//cout<<c2.x<<" "<<c2.y<<" "<<dist(p[i],c2)<<" "<<dist(p[j],c2)<<endl;
				ll cnt1=0,cnt2=0;
				REP(k,n) {
					if(dist(p[k],c1)<=1+EPS) cnt1++;
					if(dist(p[k],c2)<=1+EPS) cnt2++;
				}
				ans=max({ans,cnt1,cnt2});
			}
		}
		cout<<ans<<endl;
	}
}

C++: #include <stdio.h>
#include <algorithm>
#include <iostream>
#include <stack>
#include <vector>
#include <math.h>
#include <queue>

using namespace std;

struct Point{
    double x,y;
};

void func(int N){

    Point point[N];
    double x_min = 100,y_min = 100,x_max = -1,y_max = -1;

    for(int i = 0; i < N; i++){
        scanf("%lf %lf",&point[i].x,&point[i].y);
        x_min = min(point[i].x,x_min);
        y_min = min(point[i].y,y_min);
        x_max = max(point[i].x,x_max);
        y_max = max(point[i].y,y_max);
    }

    if(x_min > 1)x_min -= 0.0475;
    if(y_min > 1)y_min -= 0.0475;
    if(x_max < 9)x_max += 0.0475;
    if(y_max < 9)y_max += 0.0475;

    int count,max_count = 0;

    for(double y = y_min; y <= y_max; y += 0.01){
        for(double x = x_min; x <= x_max; x += 0.01){
            count = 0;
            for(int i = 0; i < N; i++){
                if(sqrt((x-point[i].x)*(x-point[i].x)+(y-point[i].y)*(y-point[i].y)) <= 1.0)count++;
            }
            max_count = max(max_count,count);
        }
    }

    printf("%d\n",max_count);
}


int main(){

    int N;

    while(true){
        scanf("%d",&N);
        if(N == 0)break;

        func(N);
    }


    return 0;
}