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 long double eps=1e-3;
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,2001){
            const long double y=10.*i/2000;
            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 <iostream>
#include <queue>
#include <cmath>

using namespace std;

const double sqrt2 = sqrt(2.0); 
const double eps = 1e-6;
char dx[] = {-1,1,-1,1};
char dy[] = {1,1,-1,-1};

class Square{
public:
	int bound; double x, y, size;
	Square(int bound, double x, double y, double size) : bound(bound), x(x), y(y), size(size) {}
	bool operator < (const Square &s) const { return bound < s.bound; }
};

inline double sqr(double x) { return x*x; }

int main(){
	int N;
	double x[300], y[300];
	while(cin >> N){
		if(!N) break;
		for(int i=0;i<N;i++) cin >> x[i] >> y[i];
		int ans = 1;
		priority_queue<Square> qu;
		qu.push(Square(N, 5.0, 5.0, 10.0));
		while(!qu.empty()){
			Square s = qu.top(); qu.pop();
			if(s.bound <= ans) break;
			for(int i=0;i<4;i++){
				double nx = s.x + dx[i]*s.size/2.0;
				double ny = s.y + dy[i]*s.size/2.0;
				int c = 0, upper = 0;
				for(int j=0;j<N;j++){
					double dist = sqr(x[j]-nx)+sqr(y[j]-ny);
					if(dist < 1.0+eps) c++;
					if(dist < sqr(1.0+sqrt2*s.size/2.0)+eps) upper++;
				}
				ans = max(ans, c);
				if(upper > ans) qu.push(Square(upper, nx, ny, s.size/2.0));
			}
		}
		cout << ans << endl;
	}
}

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

double Dis(double x1, double y1, double x2, double y2);
int main(void){
	while(1){
		int n;
		int ans = 1;
		vector< pair<double, double> > p;

		cin >> n;
		if(n == 0) break;

		for(int i=0; i<n; i++){
			pair<double, double> t;
			cin >> t.first >> t.second;
			p.push_back(t);
		}

		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				//中点
				double mpx = (p[i].first + p[j].first) / 2.0;
				double mpy = (p[i].second + p[j].second) / 2.0;
				//2点間の距離
				double d1 = Dis(p[i].first, p[i].second, p[j].first, p[j].second);
				//p[i]からp[j]へ向かうベクトル
				double v1x = (p[i].first - p[j].first) / d1;
				double v1y = (p[i].second - p[j].second) / d1;
				//中点から円の中心へ向かう単位ベクトル
				double v2x = -v1y;
				double v2y = v1x;
				//中心から円の中心へ向かうベクトルの長さ
				double d2 = sqrt(1.0 - (d1*d1/4.0)));

				//円の中心の座標
				double cx = mpx + v2x * d2;
				double cy = mpy + v2y * d2;

				int cnt = 0;
				for(int k=0; k<n; k++){
					if(k == i || k == j || Dis(cx, cy, p[k].first, p[k].second) <= 1.0)	cnt++;
				}
				if(cnt > ans){
					ans = cnt;
				}

				cx = mpx - v2x * d2;
				cy = mpy - v2y * d2;

				cnt = 0;
				for(int k=0; k<n; k++){
					if(Dis(cx, cy, p[k].first, p[k].second) <= 1.0)	cnt++;
				}
				if(cnt > ans){
					ans = cnt;
				}
			}
		}

		cout << ans << endl;


	}
	
	return 0;
}

double Dis(double x1, double y1, double x2, double y2){
	return sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));
}

C++: #include<cstdio>
#include<cmath>
#include<iostream>
using namespace std;
#define EPS 1.0e-6
#define F(I,J,N) for(int I=J;I<N;I++)

class point{
public:
	double x,y;
	point(){}
	point(double x,double y){
		this->x=x;
		this->y=y;
	}
	double len(point &p){
		return sqrt((x-p.x)*(x-p.x)+(y-p.y)*(y-p.y));
	}
	double len(){
		return sqrt(x*x+y*y);
	}
	point operator*(double d){
		point p(x*d,y*d);
		return p;
	}
	point operator/(double d){
		point p(x/d,y/d);
		return p;
	}
	point operator+(const point &o){
		point p(x+o.x,y+o.y);
		return p;
	}
	point operator-(const point &o){
		point p(x-o.x,y-o.y);
		return p;
	}
	point& operator=(const point &o){
		this->x=o.x;
		this->y=o.y;
		return *this;
	}
	bool operator==(const point &o){
		return (x==o.x && y==o.y);
	}
	bool operator!=(const point &o){
		return !(x==o.x && y==o.y);
	}
};

int main(){
	int n;
	point *p;
	int ans;
	point c,ce,h;
	while(cin>>n){
		c=ce;
		if(n==0) break;
		p=new point[n];
		ans=0;
		F(i,0,n) cin>>p[i].x>>p[i].y;
		F(i,0,n-1){
			F(j,i+1,n){
				if(p[i].len(p[j])<2+EPS){
					c=(p[i]+p[j])/2;
					h.x=-(p[i]-p[j]).y;
					h.y=(p[i]-p[j]).x;
					double len=p[i].len(p[j]);
					len=sqrt(1-len*len/4);
					h=h*(len/h.len());

					ce=c+h;
					int cnt=0;
					F(k,0,n) if(ce.len(p[k])<1+EPS) cnt++;
					ans=max(ans,cnt);

					ce=c-h;
					cnt=0;
					F(k,0,n) if(ce.len(p[k])<1+EPS) cnt++;
					ans=max(ans,cnt);
				}
			}
		}
		if(ans==0) ans=1;
		cout<<ans<<endl;
		delete []p;
	}
	return 0;
}

C++: #include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstdio>
#include<cstring>
using namespace std;
#define dis(p,q) ((p)*(p)+(q)*(q))
int main(){
  int i,j,k;
  int n;
  while(cin>>n,n){
    double x[300],y[300];
    for(i=0;i<n;++i)
      cin>>x[i]>>y[i];    
    int mx=1;
    for(i=0;i<n-1;++i){
      for(j=i+1;j<n;++j){
	double d=dis(x[i]-x[j],y[i]-y[j]);
	if(d<=4){
	  double cx,cy,a=atan2(y[i]-y[j],x[i]-x[j]);
	  int sm;
	  cx=(x[i]+x[j])/2+cos(a+M_PI/2)*sqrt(1-d/4);
	  cy=(y[i]+y[j])/2+sin(a+M_PI/2)*sqrt(1-d/4);
	  sm=2;
	  for(k=0;k<n;++k){
	    if(k!=i&&k!=j&&dis(x[k]-cx,y[k]-cy)<=1)
	      ++sm;
	  }
	  mx=max(mx,sm);
	  cx=(x[i]+x[j])/2+cos(a-M_PI/2)*sqrt(1-d/4);
	  cy=(y[i]+y[j])/2+sin(a-M_PI/2)*sqrt(1-d/4);
	  sm=2;
	  for(k=0;k<n;++k){
	    if(k!=i&&k!=j&&dis(x[k]-cx,y[k]-cy)<=1)
	      ++sm;
	  }
	  mx=max(mx,sm);
	}
      }
    }
    cout<<mx<<endl;
  }
  return 0;
}