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 <complex>
using namespace std;
typedef complex<double> P;

int n;
double x[300], y[300];

int main() {
    while (cin >> n && n) {
        for (int i=0; i<n; ++i) {
            cin >> x[i] >> y[i];
        }
        int ret = 1;
        for (int i=0; i<n; ++i) {
            for (int j=0; j<n; ++j) {
                if (i == j) continue;
                P a = P(x[i], y[i]);
                P b = P(x[j], y[j]);
                P m = (a + b) / 2.0;
                double h = sqrt(1.0 - norm(a - m));
                P u = (a - b) / abs(a - b);
                u = P(-u.imag(), u.real());
                P c = (a + b) / 2.0 + u * h;
                int cnt = 0;
                for (int k=0; k<n; ++k) {
                    P t(x[k], y[k]);
                    if (norm(c - t) < 1.0 + 1e-8) {
                        cnt ++;
                    }
                }
                ret = max(ret, cnt);
            }
        }
        cout << ret << endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
#define EPS 1e-10
#define MOD 1000000007
using namespace std;
typedef pair<double,double> P;
typedef pair<int,P> PP;

int n;
int ans;
vector<double> x, y;
vector<PP> v;

void solve(){
	x.clear(); y.clear(); v.clear();
	x.resize(n); y.resize(n);
	ans = 1;
	rep(i,n) cin >> x[i] >> y[i];
	for(int i = 0; i <= 1000; i++) for(int j = 0; j <= 1000; j++){
		double I = i/100.0, J = j/100.0;
		int cnt = 0;
		rep(k,n){
			if((x[k]-I)*(x[k]-I)+(y[k]-J)*(y[k]-J) < 1) cnt++;
		}
		v.push_back(PP(cnt,P(I,J)));
	}
	sort(v.begin(),v.end(), greater<PP>());
	rep(u,100){
		P p = v[u].second;
		for(int i = 0; i <= 100; i++) for(int j = 0; j <= 100; j++){
			double I = p.first-0.005+i/10000.0, J = p.second-0.005+j/10000.0;
			int cnt = 0;
			rep(k,n){
				if((x[k]-I)*(x[k]-I)+(y[k]-J)*(y[k]-J) < 1) cnt++;
			}
			ans = max(ans,cnt);
		}
	}
	cout << ans << endl;
}

int main(){
	while(cin >> n){
		if(n == 0) break;
		solve();
	}
}

C++: #include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

//eÍÍÌë·
//1 * 10^(-5)
#define EPS (1e-8)

int n;
pair<double, double> p[301];

int main() {
	while (1) {
		cin >> n;
		if (n == 0) break;
		for (int i = 0; i < n; i++) {
			cin >> p[i].first >> p[i].second;
		}
		int maxPoints = 1;
		//2_ð~üãÉÂ~ðè
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				double d = hypot(p[i].first - p[j].first, p[i].second - p[j].second);
				if (d > 2.0 + EPS) continue;	//£ê·¬
				
				//_(»ê¼êÌÀWÌ½Ï)
				pair<double, double> m((p[i].first + p[j].first) / 2.0, (p[i].second + p[j].second) / 2.0);
				//PÊ@üxNg
				//	@üxNgÌX«Íüªp[i]p[j]Æ|¯Ä-1C·Èí¿
				//		v = (p[j].first - p[i].first, p[j].second - p[i].second)
				//	±êÌ·³Ívx^2 + vy^2 = d^2
				//	æÁÄPÊxNgÉ·éÉÍ
				//		(vx/d)^2 + (vy/d)^2 = 1
				pair<double, double> ve((p[j].first - p[i].first) / d, (p[j].second - p[i].second) / d);
				//_©çSÜÅÌ£
				double l = sqrt(1.0 - d * d / 4.0);
				
				//_2Â©çèÜé~Í2Â
				for (int s = -1; s < 2; s += 2) {//
					pair<double, double> c(m.first + s * l * ve.first, m.second - s * l * ve.second);
					int count = 2;
					for (int k = 0; k < n; k++) {
						if (k==i || k==j) continue;//¯êÌ_ÍÜßÈ¢
						if (hypot(c.first - p[k].first, c.second - p[k].second) < 1.0 + EPS) count++;
					}
					maxPoints = max(maxPoints, count);
				}
			}
		}
		cout << maxPoints << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
#define N 300
using namespace std;
typedef complex<double> P;
const double EPS = 1e-8;

struct Circle{
  P c;
  double r;
  Circle(P c=P(0,0),double r=0):c(c),r(r){}
};

vector<P> getIntersectCC(Circle c1, Circle c2){
  vector<P> res;
  double r1=c1.r,r2=c2.r,d;
  P p1=c1.c,p2=c2.c;
  d=abs(p1-p2);
  if(d<EPS&&abs(r1-r2)<EPS) return res;
  if(r1+r2<d-EPS||d+EPS<abs(r1-r2)) return res; 
  double a=(r1*r1-r2*r2+d*d)/(2*d);
  double h=sqrt(max(r1*r1-a*a,0.0));
  P tmp1=p1+a/d*(p2-p1);
  P tmp2=h/d*(p2-p1);
  if(abs(tmp2)<EPS)res.push_back(tmp1);
  else{
    res.push_back(P(real(tmp1)-imag(tmp2),imag(tmp1)+real(tmp2)));
    res.push_back(P(real(tmp1)+imag(tmp2),imag(tmp1)-real(tmp2)));
  }
  return res;
}

double getdistancepp(P a,P b){
  return sqrt((a.real()-b.real())*(a.real()-b.real())+(a.imag()-b.imag())*(a.imag()-b.imag()));
}

int main(){
  int n,ans=0;
  double a,b;
  P p[N];
  while(1){
    cin>>n;
    if(!n)break;
    for(int i=0;i<n;i++){
      cin>>a>>b;
      p[i]=P(a,b);
    }
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
	Circle c1,c2;
	c1.c=p[i];
	c2.c=p[j];
	c1.r=c2.r=1;
	vector<P> r=getIntersectCC(c1,c2);
	if(!r.size())continue;
	for(int k=0;k<r.size();k++){
	  int cnt=0;
	  for(int l=0;l<n;l++)
	    if(getdistancepp(r[k],p[l])<=1+EPS)cnt++;	    
	  ans=max(ans,cnt);
	}
      }
    }
    if(!ans&&n==1)ans=1;
    cout<<ans<<endl;
  }
  return 0;
}