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>
#define EPS 10e-6
using namespace std;
typedef complex<double> xy_t;
int n;
xy_t points[301];
int count_in(xy_t center)
{
  int ans=0;
  for(int i=0;i<n;i++)
  {
    if (abs(center-points[i])<1.0+EPS)
      ans++;
  }
  return ans;
}
xy_t ppdcl(xy_t a)
{
  return xy_t(a.imag(),-a.real());
}
xy_t delta_v(xy_t C1,xy_t C2)
{
  xy_t half=(C1-C2)*0.5;
  double l=abs(half);
  return ppdcl(half)*sqrt(1-l*l)*(1.0/l);
}
int main()
{
  while(1)
  {
    cin>>n;
    if (n==0) break;
    double x,y;
    for(int i=0;i<n;i++)
    {
      cin>>x>>y;
      points[i]=xy_t(x,y);
    }
    int maxn=-1;
    for(int i=0;i<n;i++)
    {
      for(int j=i+1;j<n;j++)
      {
        if(abs(points[i]-points[j])<2.0+EPS)
        {
          xy_t mid_p=(points[i]+points[j])*0.5;
          maxn=max(maxn,count_in(mid_p+delta_v(points[i],points[j])));
          maxn=max(maxn,count_in(mid_p-delta_v(points[i],points[j])));
        }
      }
    }
    cout<<maxn<<endl;
  }

}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<58;
const long double eps=1e-3;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    while(true){
        int n;
        cin >> n;
        if(n==0) break;
        vector<long double> xs(n),ys(n);
        rep(i,0,n) cin >> xs[i] >> ys[i];

        auto count=[&](const long double x,const long double y){
            int res=0;
            rep(i,0,n) if((xs[i]-x)*(xs[i]-x)+(ys[i]-y)*(ys[i]-y)<=1+eps) ++res;
            return res;
        };

        int ans=0;
        rep(i,0,3001){
            const long double y=10.*i/3000;
            rep(j,0,n){
                const long double tmp=1-(ys[j]-y)*(ys[j]-y);
                if(tmp<0) continue;
                const long double x1=xs[j]-sqrtl(tmp),x2=xs[j]+sqrt(tmp);
                ans=max({ans,count(x1,y),count(x2,y)});
            }
        }
        cout << ans << endl;
    }
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    cout << fixed << setprecision(8);
    solve();
    return 0;
}

C++: #include <bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
const ll INF = 114514810;
const ll MOD = 1000000007;
const double EPS = 1e-8;
const double PI = acos(-1.0);
struct edge
{
  int to, cost;
  bool operator < (const edge& e) const { return cost < e.cost; }
  bool operator >(const edge& e) const { return cost > e.cost; }
};
int dx[] = { -1, 0, 0, 1 }; int dy[] = { 0, -1, 1, 0 };
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

bool eq(double a, double b) { return fabs(a - b) < EPS; }
typedef complex<double> Point;
typedef vector<Point> Polygon;

namespace std
{
  bool operator < (const Point& a, const Point& b)
  {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}

struct Line
{
  Point a, b;
  Line(Point p, Point q) :a(p), b(q) {};
};

struct Circle
{
  Point p; double r;
  Circle(Point a, double b) :p(a), r(b) {};
};

double dot(Point a, Point b)
{
  return real(conj(a)*b);
}

double cross(Point a, Point b)
{
  return imag(conj(a)*b);
}

int ccw(Point a, Point b, Point c)
{
  b -= a; c -= a;
  if (cross(b, c) > EPS) return 1;	//counter cloclwise
  if (cross(b, c) < -EPS) return -1;  //cloclwise
  if (dot(b, c) < 0) return 2;		//c--a--b on line 
  if (norm(b) < norm(c)) return -2;   //a--b--c on line
  return 0;							//a--c--b on line
}

vector<Point> is_cc(Circle c1, Circle c2)
{
  vector<Point> res;
  double d = abs(c1.p - c2.p);
  double rc = (d*d + pow(c1.r, 2) - pow(c2.r, 2)) / (2 * d);
  double dfr = pow(c1.r, 2) - rc*rc;
  if (abs(dfr) < EPS) dfr = 0;
  if (dfr < 0.0) return res;
  double rs = sqrt(dfr);
  Point diff = (c2.p - c1.p) / d;
  res.push_back(c1.p + diff*Point(rc, rs));
  if (dfr != 0.0) res.push_back(c1.p + diff*Point(rc, -rs));
  return res;
}




int main()
{
  int n;
  while (cin >> n, n)
  {
    int ans = 1;
    vector<Point> v;
    REP(i, n)
    {
      double x, y;
      cin >> x >> y;
      v.push_back(Point(x, y));
    }
    REP(i, n - 1)
    {
      FOR(j, 1 + 1, n)
      {
        Circle c1(v[i], 1), c2(v[j], 1);
        auto vp = is_cc(c1, c2);

        REP(k, vp.size())
        {
          int cnt = 0;
          Point tmp = vp[k];
          REP(l, n)
          {
            if (abs(tmp - v[l])-1<= EPS) cnt++;
          }
          chmax(ans, cnt);
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}