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<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))

struct makehtml{
	vector<string> ss;
	
	makehtml(){}
	/*
	ctx.beginPath()
	ctx.moveTo(50.000000,100.000000);
	ctx.lineTo(150.000000,100.000000);
	ctx.stroke();
	
	ctx.fillStyle = "rgb(0,0,0)";
	
	ctx.beginPath();
	ctx.arc(168,59,3,0,360);
	ctx.fill();

	*/
	
	void out(const char* name,double mag){
		char fname[100];
		sprintf(fname,"%s.html",name);
		FILE* fp = fopen(fname,"w");
		if(fp==NULL){
			eprintf("can't open %s\b",fname);
			exit(-1);
		}
		fprintf(fp,"<html>\n<head>\n<title>");
		fprintf(fp,"%s",name);
		fprintf(fp,"</title>\n</head>\n<body>\n");
		fprintf(fp,"<p>name: %s</p>",name);
		fprintf(fp,"<canvas id=\"vis\" width=\"%d\" height=\"%d\"></canvas>",2000,2000);
		fprintf(fp,"<script>\n");
		fprintf(fp,"var vis = document.getElementById('vis');\nvar ctx = vis.getContext('2d');\n");
		
		rep(i,ss.size()){
			fprintf(fp,"%s\n",ss[i].c_str());
		}
		
		fprintf(fp,"</script>\n");
		fprintf(fp,"</body>\n</html>\n");
		fclose(fp);
	}

} makehtml_instance;


void addhtml(string s){
	makehtml_instance.ss.push_back(s);
}

void outhtml(string s,double mag){
	makehtml_instance.out(s.c_str(),mag);
}

void randcolhtml(){
	char ns[100];
	sprintf(ns,"ctx.fillStyle = \"rgb(%d,%d,%d)\";",rand()%128,rand()%128,rand()%128);
	addhtml(ns);
	sprintf(ns,"ctx.strokeStyle = \"rgb(%d,%d,%d)\";",rand()%128,rand()%128,rand()%128);
	addhtml(ns);
}

void inithtml(){
	makehtml_instance.ss.clear();
}


const double pi=3.14159265358979;

struct pos{
	double x,y;
	double norm,norm2;
	pos tov(pos a){
		return (a-(*this));
	}
	pos operator+(pos a)const{
		pos res=a;
		res.x+=x; res.y+=y;
		res=pos(res.x,res.y);
		return res;
	}
	pos operator-(pos a)const{
		pos res=(*this);
		res.x-=a.x; res.y-=a.y;
		res=pos(res.x,res.y);
		return res;
	}
	pos scalar(double a){
		pos res=(*this);
		res.x*=a; res.y*=a;
		res=pos(res.x,res.y);
		return res;
	}
	double dot(pos a){
		return x*a.x + y*a.y;
	}
	double cross(pos a){
		return x*a.y - y*a.x;
	}
	double theta(pos a){
		double nt=dot(a)/(norm*a.norm);
		nt=acos(max(-1.0,min(1.0,nt)));
		double ns=(cross(a)/(norm*a.norm));
		if(ns<0)nt*=-1;
		return nt;
	}
	pos(double ix,double iy){
		x=ix; y=iy;
		norm2=x*x+y*y;
		norm=sqrt(norm2);
	}
	pos(){}
	string str(){
		char ns[50];
		sprintf(ns,"(%lf %lf)",x,y);
		return	string(ns);
	}
	void outh(double mag){
		char ns[50];
		addhtml("ctx.beginPath();"); 
		sprintf(ns,"ctx.arc(%lf,%lf,%lf,0,360);",x*mag,y*mag,5.0); addhtml(ns);
		addhtml("ctx.fill();");
	}
	static pos polar(double r,double t){
		return pos(r*cos(t),r*sin(t));
	}
	pos turn(double t){
		//t[rad]??????
		return pos(x*cos(t)-y*sin(t),x*sin(t)+y*cos(t));
	}
	pos tolen(double a){
		//?????????a?????????
		return this->scalar(a/norm);
	}
	bool  operator<(pos a) const{
		//if(x!=a.x)return (x<a.x);
		//return (y<a.y);
		if(y!=a.y)return (y<a.y);
		return (x<a.x);
	}	
	bool operator>(pos a)const{ return (a<(*this)); }	
};
struct line{
	pos p,q;
	pos vec;
	string str(){
		return ("("+p.str()+"-"+q.str()+")");
	}
	void outh(double mag){
		char ns[50];
		addhtml("ctx.beginPath();");
		sprintf(ns,"ctx.moveTo(%lf,%lf);",p.x*mag,p.y*mag); addhtml(ns);
		sprintf(ns,"ctx.lineTo(%lf,%lf);",q.x*mag,q.y*mag); addhtml(ns);
		addhtml("ctx.stroke();");
	}
	bool iscross(line a){
		double da,db;
		da=vec.cross( p.tov(a.p) );
		db=vec.cross( p.tov(a.q) );
		if(da*db>=0)return false;
		da=a.vec.cross( a.p.tov(p) );
		db=a.vec.cross( a.p.tov(q) );
		return (da*db<0);
	}
	line(pos ip,pos iq){
		p=ip; q=iq;
		vec=p.tov(q);
	}
	line(){}
	double dist(pos a){
		if(p.tov(a).dot( p.tov(q) )<0)return p.tov(a).norm;
		if(q.tov(a).dot( q.tov(p) )<0)return q.tov(a).norm;
		return abs(vec.cross(p.tov(a))/vec.norm);
	}
	double dist(line a){
		if(iscross(a))return 0;
		return min( min(dist(a.p),dist(a.q)) , min(a.dist(this->p),a.dist(this->q)));
	}
	pos crosspos(line a){
		/*
		double d1=a.vec.cross(a.p.tov(p))/a.vec.norm;
		double d2=a.vec.cross(a.p.tov(q))/a.vec.norm;
		bool isc=(d1*d2<0);
		d1=abs(d1); d2=abs(d2);
		double sc;
		if(!isc){
			if(d1>d2)sc = d1/(d1-d2);
			else sc=d1/(d2-d1);
		}
		else sc = d1/(d1+d2);
		return (p+vec.scalar(sc));*/
		
		double t = a.vec.cross(a.p-p)/a.vec.cross(vec);
		return (p+vec.scalar(t));
	}
	line bisection(){//?????´????????????
		//???????¨??????????90????????£???????????????
		pos fr=(p+q).scalar(0.5);
		pos to=fr+pos(-vec.y,vec.x);
		return line(fr,to);
	}
};


int n;
int main(void){
	for(;;){
		scanf("%d",&n);
		if(n==0)break;
		vector<pos> ps;
		rep(i,n){
			double x,y;
			scanf("%lf%lf",&x,&y);
			ps.push_back(pos(x,y));
		}
		
		vector<pos> cs;
		rep(i,n){
			rep(j,i){
				line nl(ps[i],ps[j]);
				double d = nl.vec.norm;
				if(d>2.0)continue;
				pos av = nl.bisection().vec.tolen(sqrt(1.0-(d/2.0)*(d/2.0)));
				pos m=(ps[i]+ps[j]).scalar(0.5);
				cs.push_back(m+av);
				cs.push_back(m-av);
			}
		}
		
		int ans=1;
		rep(i,cs.size()){
			int ns=0;
			rep(j,ps.size()){
				if((cs[i]-ps[j]).norm<=1.0+1e-6)ns++;
			}
			ans=max(ans,ns);
		}
		printf("%d\n",ans);
	}
				
	return 0;
}

C++: #include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
double x[300];
double y[300];
double X[90000];
double eps=0.000000001;
double Y[90000];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++)scanf("%lf%lf",x+i,y+i);
		
		int at=0;
		for(int i=0;i<a;i++){
			for(int j=i+1;j<a;j++){
				double d=sqrt(1.0-((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]))/4)/sqrt(((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])));
				X[at]=(x[i]+x[j])/2-d*(y[j]-y[i]);
				Y[at++]=(y[i]+y[j])/2+d*(x[j]-x[i]);
				X[at]=(x[i]+x[j])/2+d*(y[j]-y[i]);
				Y[at++]=(y[i]+y[j])/2-d*(x[j]-x[i]);
			}
		}
		int ret=1;
		for(int i=0;i<at;i++){
			int val=0;
			for(int j=0;j<a;j++){
				if((X[i]-x[j])*(X[i]-x[j])+(Y[i]-y[j])*(Y[i]-y[j])<1.0+eps)val++;
			}
			ret=max(ret,val);
		}
		printf("%d\n",ret);
	}
}