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 <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

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

int count(double x0, double y0, int p, int q){
	int ret = 2;
	REP(i,n){
		if(i==p||i==q)continue;
		double dx = x0-x[i];
		double dy = y0-y[i];
		if(pow(dx, 2.0)+pow(dy, 2.0)<1.0)ret++;
	}
	return ret;
}

int main(){
	while(1){
		int ret = 1;
		cin>>n;
		if(n==0)break;
		REP(i,n)scanf("%f %f", &x[i],&y[i]);
		REP(i,n){
			FOR(j, i+1,n){
				double dx = x[j]-x[i];
				double dy = y[j]-y[i];
				double d = sqrt(pow(dx, 2.0)+pow(dy, 2.0));
				if(d < 2.0){
					double mx = (x[j]+x[i])*0.5;
					double my = (y[j]+y[i])*0.5;
					{
						double x = mx-dy/d*sqrt(1.0-d*d/4.0);
						double y = my+dx/d*sqrt(1.0-d*d/4.0);
						ret = max(ret, count(x, y, i, j));
					}
					{
						double x = mx+dy/d*sqrt(1.0-d*d/4.0);
						double y = my-dx/d*sqrt(1.0-d*d/4.0);
						ret = max(ret, count(x, y, i, j));
					}
				}
			}
		}
		cout << ret << endl;
	}
	return 0;
}

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

double distance(pair<double,double> p1,pair<double,double> p2){
	return sqrt((p1.first-p2.first)*(p1.first-p2.first)+(p1.second-p2.second)*(p1.second-p2.second));
}

int main(){
	int n;
	while(cin>>n,n){
		vector<double> x(n);
		vector<double> y(n);
		int res=1;
		for(int i=0;i<n;i++) cin>>x[i]>>y[i];
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				pair<double,double> midp=make_pair((x[i]+x[j])/2,(y[i]+y[j])/2);
				double a=-(x[i]-x[j]),b=(y[i]-y[j]);
				if(a<0.000001) a=0;
				if(b<0.000001) b=0;
				//a(x-mid[i].first)+b(y-mid.second)=0
					for(int k=0;k<2;k++){
						pair<double,double> lef=midp;
						pair<double,double> rig;
						if(k==0) rig=make_pair(-b*1e8+midp.first,a*1e8+midp.second);
						if(k==1) rig=make_pair(b*1e8+midp.first,-a*1e8+midp.second);
						while(distance(lef,rig)>=0.0000000001){
								pair<double,double> mid=make_pair((lef.first+rig.first)/2,(lef.second+rig.second)/2);
								if(distance(mid,make_pair(x[i],y[i]))>1){
									rig=mid;
								}
								else{
									lef=mid;
								}

						}
						int count=2;
						if(distance(midp,lef)<0.000001) {
							continue;
						}

						for(int r=0;r<n;r++){
							if(distance(make_pair(x[r],y[r]),lef)<1+0.00005){
								if(r!=i && r!=j)count++;
							}
						}
						res=max(res,count);
					}
			}

		}
		cout<<res<<endl;

	}

	return 0;
}

C++: #include <iostream>
#include <vector>
#include <utility>
#include <cmath>

using namespace std;

typedef pair<double,double> pos;
const double r = 1;
const double eps = 0.0001;
int count(vector<pos> ps,double x,double y,int ban1,int ban2){
	int c=0;//2;
	for(int i=0;i<ps.size();i++){
		if(//i!=ban1&&i!=ban2&&
				pow(ps[i].first-x,2)+pow(ps[i].second-y,2)<=pow(1.0+eps,2)){
			c++;
		}
	}
	return c;
}

bool range(pos p1,pos p2,double r){
	return pow(p1.first-p2.first,2)+pow(p1.second-p2.second,2) <= (r+eps)*(r+eps);
}

double len(pos p){
	return sqrt(pow(p.first,2)+pow(p.second,2));
}

double len2(pos p){
	return (pow(p.first,2)+pow(p.second,2));
}

vector<pos> point2(pos p1,pos p2){
	pos m = make_pair((p1.first+p2.first)/2,(p1.second+p2.second)/2);
	pos vec = make_pair(p1.first-p2.first,p1.second-p2.second);
	pos q = m;//make_pair(p2.first+vec.first/2,p2.second+vec.second/2);
	double l = sqrt(1-pow(len(vec)/2.0,2));
	double ll = len(vec);
	pos vec2 = make_pair(-vec.second,vec.first);
	vec2.first=vec2.first/ll*l;
	vec2.second = vec2.second/ll*l;
	vector<pos> ret;
	ret.push_back(make_pair(q.first+vec2.first,q.second+vec2.second));
	ret.push_back(make_pair(q.first-vec2.first,q.second-vec2.second));
	return ret;
}

int solve(vector<pos> ps){
	int mx=0;
	for(int i=0;i<ps.size()-1;i++)
		for(int k=i+1;k<ps.size();k++){
			if(range(ps[i],ps[k],2)){
				//cerr << "*****" << i << " " << k << endl;
				vector<pos> vp = point2(ps[i],ps[k]);
				mx = max(mx,count(ps,vp[0].first,vp[0].second,i,k));
				mx = max(mx,count(ps,vp[1].first,vp[1].second,i,k));
			}
		}
	return mx;
}

int main(){
	//cerr << point2(make_pair(0,0),make_pair(1,1))[1].first << endl;
	while(true){
		int n;
		vector<pos> v;
		cin >> n;
		if(n==0)return 0;
		for(int i=0;i<n;i++){
			double x,y;
			cin >> x >> y;
			v.push_back(make_pair(x,y));
		}
		cout << solve(v) << endl;
	}
}