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>
#include <cmath>
#include <vector>
#include <map>
using namespace std;

typedef complex<double> P;
const double PI = 3.14159265;
const double eps = 1e-7;

inline double dist(const P &p,const P &q) {
    double dx = (p-q).real(),dy = (p-q).imag();
    return sqrt(dx*dx+dy*dy);
}

double inner(const P &p,const P &q) {
    return (conj(p)*q).real();
}

double outer(const P &p,const P &q) {
    return (conj(p)*q).imag();
}

struct Line {
    P pos,dir;
    Line(const P &p,const P &q) : pos(p), dir(q) {;}
};

// rotate to right , radian
P rotate(const P &p,double degree) {
    return P(p.real()*cos(degree)+p.imag()*(-sin(degree)),
             p.real()*sin(degree)+p.imag()*cos(degree));
}

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

// p in C?
inline bool inC(const Circle &c,const P &p) {
    return dist(c.c,p) < c.r + eps;
}

// p1,p2©ç£dÌ2ÂÌ_ðÔ·
// dist(p1-p2) > 2*dÌÆ«nanªÔéÌÉÓ
pair<P,P> findCenter(P &p1,P &p2,double d) {
    P cp = p1+p2;
    cp /= 2;

//    cout<<"cp = "<<cp<<endl;
    P od = p2-cp;

//    cout<<"original od = "<<od<<endl;
    od = rotate(od,PI/2);
//    cout<<"rotated od = "<<od<<endl;

    double abod = abs(od),abcp = norm(cp-p1);
    double len = sqrt(d-abcp);

    // cout<<"abod = "<<abod<<" abcp = "<<abcp<<endl;
    // cout<<"len = "<<len<<endl;
    P rep1 = cp + (od/abod)*len;
    P rep2 = cp - (od/abod)*len;
    return make_pair(rep1,rep2);
}

int main() {
    int n;
    while(cin>>n, n) {
        vector<P> pv;
        double x,y;
        for(int i=0; i<n; ++i) {
            cin>>x>>y;
            pv.push_back(P(x,y));
        }

        int ans = 1;
        for(int i=0; i<n; ++i) {
            for(int j=i+1; j<n; ++j) {
                if(dist(pv[i],pv[j]) > 2.0) continue;
                pair<P,P> p = findCenter(pv[i],pv[j],1.0);
                int t1 = 0,t2 = 0;
//                cout<<pv[i]<<" "<<pv[j]<<" "<<p.first<<" "<<p.second<<endl;
                Circle c1(p.first,1.0);
                Circle c2(p.second,1.0);
                for(int k=0; k<n; ++k) {
                    if(inC(c1,pv[k])) t1++;
                    if(inC(c2,pv[k])) t2++;
                }
                ans = max(ans, max(t1,t2));
            }
        }

        cout<<ans<<endl;
    }
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

const double eps=1e-8;
typedef pair<double,double> p;

double dist(p a, p b)
{
    return sqrt((a.fi-b.fi)*(a.fi-b.fi)+(a.se-b.se)*(a.se-b.se));
}

double size(p a)
{
    return sqrt(a.fi*a.fi+a.se*a.se);
}

int main()
{
    int n;
    while(cin >>n,n)
    {
        vector<p> v(n);
        rep(i,n) scanf(" %lf %lf", &v[i].fi, &v[i].se);

        int ans=0;
        //select 2 points
        rep(i,n)rep(j,i)
        {
            double d=dist(v[i],v[j]);
            if(d>2.0) continue;

            double r=sqrt(1.0 - (d*d/4.0));

            double X=v[j].fi-v[i].fi, Y=v[j].se-v[i].se;

            p v1=p(X,Y);
            double v1size=size(v1);
            v1.fi/=v1size; v1.se/=v1size;
            v1.fi*=d/2; v1.se*=d/2;

            p v2;
            double v2size;
            p c;

            //2 candidate for center of circle
            int ct=0;
            v2=p(-Y,X);

            v2size=size(v2);
            v2.fi/=v2size; v2.se/=v2size;
            v2.fi*=r; v2.se*=r;
            c.fi=v[i].fi+v1.fi+v2.fi; c.se=v[i].se+v1.se+v2.se;
            //printf("c =%lf,%lf\n",c.fi,c.se);
            rep(k,n)
            {
                if(k==i || k==j) ++ct;
                else
                {
                    if(dist(c,v[k])<1.0) ++ct;
                }
            }
            ans=max(ans,ct);

            ct=0;
            v2=p(Y,-X);
            v2size=size(v2);
            v2.fi/=v2size; v2.se/=v2size;
            v2.fi*=r; v2.se*=r;

            c.fi=v[i].fi+v1.fi+v2.fi; c.se=v[i].se+v1.se+v2.se;
            rep(k,n)
            {
                if(k==i || k==j) ++ct;
                else
                {
                    if(dist(c,v[k])<1.0) ++ct;
                }
            }
            ans=max(ans,ct);
        }

        cout << ans << endl;
    }
    return 0;
}

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

int cnt(P c){
  int res=0;
  for(int i=0;i<n;i++)
    if(1-abs(c-p[i])>-EPS) res++;
  return res;
}

P get_C(P a,P b){
  double x=abs(b-a);
  if(x>2) return a;
  P c=P(x/2,sqrt(1-x*x/4))*(b-a)/abs(b-a)+a;

  return c;  
}


int main(){
  while(1){
  cin>>n;
  if(!n)break;
  double a,b;
  for(int i=0;i<n;i++)cin>>a>>b,p[i]=P(a,b);
  
  int ans=0;
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++){
      P c=get_C(p[i],p[j]);
      ans=max(ans,cnt(c));
    }
  cout <<ans<<endl;  
  }
  return 0;
}