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 <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

#define rep(i, n) for (int i = 0; i < n; ++i)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;

const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };



typedef pair<double, double> point;
const double EPS = 1e-6;
int main()
{
	int n;
	while (scanf("%d", &n), n)
	{
		point p[333];
		rep (i, n)
			scanf("%lf%lf", &p[i].first, &p[i].second);
		sort(p, p + n);

		queue<point> q;
		rep (i, n)
			q.push(p[i]);

		list<point> r;
		int res = 0;
		for (int i = -1000; i <= 10000; ++i)
		{
			double cx = i * 1e-3;
			while (!r.empty() && r.front().first < cx - 1 + EPS)
				r.pop_front();
			while (!q.empty() && q.front().first < cx + 1 + EPS)
				r.push_back(q.front()), q.pop();

			vector<double> cy;
			foreach (it, r)
			{
				double x = it->first, y = it->second;
				double d = sqrt(1 - (x - cx) * (x - cx));
				cy.push_back(y - d);
				cy.push_back(y + d);
			}

			for (int i = 0; i < cy.size(); ++i)
			{
				int c = 0;
				foreach (it, r)
				{
					double dx = cx - it->first;
					double dy = cy[i] - it->second;
					if (dx * dx + dy * dy < 1 + EPS)
						++c;
				}
				max_swap(res, c);
			}
		}
		printf("%d\n", res);
	}
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<limits>
#include<iomanip>
using namespace std;
typedef unsigned long long int ull;
typedef vector<char> vc;
typedef vector<vc> vvc;



typedef pair<double,double> Point;
#define F first
#define S second
#define MK make_pair

Point pls(Point a,Point b){
    return MK(a.F+b.F,a.S+b.S);
}

Point mns(Point a,Point b){
    return MK(a.F-b.F,a.S-b.S);
}

Point T(Point t){
    return MK(t.S,-1.0*t.F);
}

double abs(Point a){
    return sqrt(a.F*a.F+a.S*a.S);
}

Point mid(Point a,Point b){
    return MK(a.F/2+b.F/2,a.S/2+b.S/2);
}

bool in(Point c,Point t){
    if(abs(mns(t,c))<=1){return true;}
    return false;
}


int main(){
    while(1){
        int n;
        cin>>n;
        if(n==0){break;}
        vector<Point> vp;
        int mx=0;
        for(int i=0;i<n;i++){
            double a,b;
            cin>>a>>b;
            vp.push_back(MK(a,b));
        }
        sort(vp.begin(),vp.end());
        for(int i=0;i<vp.size();i++){
            for(int t=i+1;t<vp.size() && vp[t].F-vp[i].F<=2;t++){
                if(abs(mns(vp[t],vp[i]))>2){continue;}
                Point m=mid(vp[i],vp[t]);
                Point l=mns(vp[t],vp[i]);
                Point lt=T(l);
                double h=sqrt(1-abs(l)*abs(l)/4);
                lt.F=h*lt.F/abs(l);
                lt.S=h*lt.S/abs(l);
                Point c=pls(m,lt);
                int count=2;
                for(int k=0;k<vp.size();k++){
                    if(k!=i && k!=t && in(c,vp[k])){count++;}
                }
                mx=max(mx,count);
                c=mns(m,lt);
                count=2;
                for(int k=0;k<vp.size();k++){
                    if(k!=i && k!=t && in(c,vp[k])){count++;}
                }
                mx=max(mx,count);
            }
        }
        cout<<mx<<endl;
    }
    return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
#include <ctime>
#include <numeric>
#include <fstream>
#include <valarray>
using namespace std;
static const double EPS = 1e-6;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int(a.size()))
#define F first
#define S second
const long double pi=acos(-1.0);
int dx[]={0,1,0,-1,1,1,-1,-1,0},dy[]={1,0,-1,0,1,-1,1,-1,0};

int n;
pair<double,double> in[300];
int ans;

int getpointnum(double x,double y,double r){
  int ret=0;
  rep(i,n){
    double tx=in[i].F-x;
    double ty=in[i].S-y;
    if(r*r+EPS>=tx*tx+ty*ty)++ret;
  }
  return ret;
}

void square(double x,double y,double wh){
  int t=getpointnum(x+wh/2,y+wh/2,wh/sqrt(2)+1);
  if(t<=ans)return;
  ans=max(ans,getpointnum(x+wh/2,y+wh/2,1));

  square(x,y,wh/2);
  square(x+wh/2,y,wh/2);
  square(x,y+wh/2,wh/2);
  square(x+wh/2,y+wh/2,wh/2);    
}

void solve(){
  rep(i,n)cin>>in[i].F>>in[i].S;
  ans=0;

  square(-1,-1,11);
  cout<<ans<<endl;
}

main(){
  while(cin>>n,n)
    solve();
}