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 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;
        for(int k = 0 ; k < 2 ; k++){
          int cnt = 2;
          np *= (-1);
          Point center = cp + v;
          for(int l = 0 ; l < N ; l++){
            if(i == l || j == l) continue;
            Point diff = center-p[l];
            if(norm(diff) < 1.0 + EPS){
              cnt++;
            }
          }
          res = max(res,cnt);
        }
      }
    }
    cout << res << endl;
  }
  return 0;
}

C++: //#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
void chmax(int &a,int b){	a=max(a,b);	return;	}

#define EPS 1e-8
#define EQ(x, y) (abs((x)-(y))<EPS)
#define GE(x, y) ((x)>(y)||EQ(x, y))
#define LE(x, y) ((x)<(y)||EQ(x, y))

typedef complex<double> point;//changed
typedef point vec;//changed
typedef array<point, 2> line;//changed
typedef vector<point> poly;//changed

struct circle {//changed
	point c;
	double r;
};

vector<point> CrosspointCC(circle c1, circle c2) {
	vector<point> ret;
	double d = abs(c1.c - c2.c);
	double rc = (d*d + c1.r*c1.r - c2.r*c2.r) / (2*d);
	double dfr = c1.r*c1.r - rc*rc;

	if (EQ(dfr, 0.0)) dfr = 0.0;
	else if(dfr < 0.0) return ret;

	double rs = sqrt(dfr);
	vec sgn = (c2.c - c1.c) / d;
	ret.emplace_back(c1.c + sgn*point(rc, rs));
	if (dfr > 0.0) ret.emplace_back(c1.c + sgn*point(rc, -rs));
	return ret;
}

#define MAX_N 300
int n;
point p[MAX_N];

void solve(){
	int ans=1;
	for(int i=0;i<n;++i) for(int j=i+1;j<n;++j){
		circle c1=(circle){p[i],1.0},c2=(circle){p[j],1.0};
		vector<point> v=CrosspointCC(c1,c2);
		for(int l=0;l<v.size();++l){
			point q=v[l];
			int b=2;
			for(int k=0;k<n;++k) if(k!=i&&k!=j) if(abs(p[k]-q)<=1.0) ++b;
			chmax(ans,b);
		}
	}
	printf("%d\n",ans);
}

int main(){
	while(true){
		scanf("%d",&n);
		if(n==0) break;
		for(int i=0;i<n;++i){
			double a,b;
			scanf("%lf %lf",&a,&b);
			p[i]=complex<double>(a,b);
		}
		solve();
	}
}

C++: #include <bits/stdc++.h>

using namespace std;

const double r = 1.0;
const double PI = acos(-1.0);

struct Point {
    double x, y;
    Point() {}
    Point(double x, double y) : x(x), y(y) {}
};
inline double Distance2(const Point &a, const Point &b) {
    return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    std::random_device rnd;
    std::mt19937 mt(rnd());
    std::uniform_real_distribution<> rand100(0.0, 10.0);

    while (cin >> n, n) {
        // Input
        vector<Point> p(n);
        for (int i = 0; i < n; ++i)
            cin >> p[i].x >> p[i].y;

        // Solve
        int ans = 1;
        auto start = std::chrono::high_resolution_clock::now();
        auto end = std::chrono::high_resolution_clock::now();
        auto take_time = std::chrono::duration_cast<std::chrono::milliseconds>(end - start);

        while (true) {
            end = std::chrono::high_resolution_clock::now();
            take_time = std::chrono::duration_cast<std::chrono::milliseconds>(end - start);
            if (350 < take_time.count())
                break;

            for (int i = 0; i < 10; ++i) {
                Point c(rand100(mt), rand100(mt));
                int num = 0;
                for (int j = 0; j < n; ++j) {
                    double d = Distance2(p[j], c);
                    if (d <= 1.0)
                        ++num;
                }
                ans = max(ans, num);
            }
        }

        // Output
        cout << ans << endl;
    }

    return 0;
}

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-4;
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;
}