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 <complex>
#include <vector>
using namespace std;
typedef complex<double> P;
const double PI=3.141592653589793238462643383279;

bool inC(P p, P c, double r){return abs(p-c)<r+1e-9;}

P getE(P p){return p/abs(p);}

double sq(double x){ return  x*x;}

int main(){
    int n,i,j,k,ans,cnt;
    double x, y;
    while(scanf("%d",&n)){
        if(n==0) break;
        ans=0;
        vector<P> ps(n);
        for(i=0; i<n; i++){
            scanf("%lf%lf",&x,&y);
            ps[i] = P(x,y);
        }
        for(i=0;i<n;i++)
            for(j=i+1;j<n;j++)if(abs(ps[i]-ps[j])<2){
                    double d=sqrt(1-sq(abs(ps[j]-ps[i])*0.5));
                    P c1=0.5*(ps[i]+ps[j])+getE(ps[j]-ps[i])*polar(d,PI/2);
                    P c2=0.5*(ps[i]+ps[j])+getE(ps[j]-ps[i])*polar(d,-PI/2);
                    cnt=0;
                    for(k=0;k<n;k++)if(inC(ps[k],c1,1.0))cnt++;
                    if(cnt>ans)ans=cnt;
                    cnt=0;
                    for(k=0;k<n;k++)if(inC(ps[k],c2,1.0))cnt++;
                    if(cnt>ans)ans=cnt;
                }
        if(ans==0) ans++;
        printf("%d\n",ans);
    }
    return 0;
}

C++: #include <stdio.h>
#include <cmath>
#include <vector>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
using namespace std;

vector<double> getAreaPointx(int x,int y,vector<double> lx,vector<double> ly)
{
	vector<double> result;
	vector<double>::iterator itx=lx.begin();
	vector<double>::iterator ity=ly.begin();
	while (itx != lx.end())
	{
		if ((*itx <= x+1) && (*itx >= x-2) && (*ity <= y+1) && (*ity >= y-2)){
			result.push_back(*itx);
		}
		itx++;
		ity++;
	}
	return result;
}

vector<double> getAreaPointy(int x,int y,vector<double> lx,vector<double> ly)
{
	vector<double> result;
	vector<double>::iterator itx=lx.begin();
	vector<double>::iterator ity=ly.begin();
	while (itx != lx.end())
	{
		if ((*itx <= x+1) && (*itx >= x-2) && (*ity <= y+1) && (*ity >= y-2)){
			result.push_back(*ity);
		}
		itx++;
		ity++;
	}
	return result;
}


double distance(double x1,double y1,double x2,double y2)
{
	return sqrt(pow((x1-x2),2)+pow((y1-y2),2));
}

int countInside(double x,double y,vector<double> lx,vector<double> ly)
{
	int c=0;
	vector<double>::iterator itx=lx.begin();
	vector<double>::iterator ity=ly.begin();
	while (itx != lx.end())
	{
		if (distance(x,y,*itx,*ity) <= 1)
		{
			c++;
		}
		itx++;
		ity++;
	}
	return c;
}

int main(void) {
	vector<int> r;
	while (true)
	{
		int n=0;
		scanf("%d",&n);
		if (n==0){
			break;
		}
		vector<double> x,y;
		int map[12][12]={{0}};
		int maxx=0,maxy=0;
		int maxpoint=0;
		for (int i=0; i<n; i++)
		{
			double tx=0,ty=0;
			scanf("%lf %lf", &tx, &ty);
			x.push_back(tx);
			y.push_back(ty);
			int ttx=0,tty=0;
			ttx = int(round(tx+0.5));
			tty = int(round(ty+0.5));
			map[ttx][tty]++;
			if (maxpoint < map[ttx][tty]){
				maxpoint = map[ttx][tty];
				maxx=ttx;
				maxy=tty;
			}
		}
		for (double dif=0.5; dif>=0.005; dif/=10)
		{
			for (int i=1; i<=10; i++)
			{
				for (int j=1; j<=10; j++)
				{
					int aroundpoint=0;
					for (int k=-1; k<=1; k++)
					{
						for (int l=-1; l<=1; l++)
						{
							aroundpoint+=map[i+k][j+l];
						}
					}
					if (maxpoint >= aroundpoint){
						continue;
					} else {
						vector<double> lx=getAreaPointx(i,j,x,y);
						vector<double> ly=getAreaPointy(i,j,x,y);
						for (double k=0; k<1; k+=dif)
						{
							for (double l=0; l<1; l+=dif)
							{
								int tmp = countInside(i-1+k,j-1+l,lx,ly);
								if (tmp>maxpoint){
									maxpoint = tmp;
								}
							}
						}
					}
				}
			}
		}
		r.push_back(maxpoint);
	}
	for(int i=0; i<r.size(); i++)
	{
		cout << r[i] << endl;
	}
	return 0;
}