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 <bits/stdc++.h>
using namespace std;

using pos     = complex<double>;

template <typename Itr>
void printv(Itr begin, Itr end)
{
  for (Itr iter = begin; iter != end; iter++) {
    cout << *iter << ", ";
  }
  cout << endl;
}

double dist(pos a, pos b)
{
  return sqrt(pow(a.imag() - b.imag(), 2) + pow(a.real() - b.real(), 2));
}

pair<pos, pos> get_centers(pos a, pos b)
{
  pos c    = (a + b) / 2.0;
  double l = sqrt(1 - pow(dist(a, c), 2));
  pos vec  = (a - b) * pos(0, 1);
  vec      = (vec / dist(vec, 0)) * l;
  return {c + vec, c - vec};
}

int main()
{
  int n;
  while (cin >> n) {
    if (!n) break;

    vector<pos> t(n);
    for (int i = 0; i < n; ++i) {
      double x, y;
      cin >> x >> y;
      t[i] = pos(x, y);
    }

    int ans = 0;
    for (int pi = 0; pi < n; ++pi) {
      for (int qi = 0; qi < n; ++qi) {
        pos p = t[pi];
        pos q = t[qi];
        if (pi == qi || dist(p, q) > 2.0) {
          ans = max(ans, 1);
          continue;
        }
        pair<pos, pos> centers = get_centers(p, q);
        for (pos center : {centers.first, centers.second}) {
          int cnt_d = 2;
          for (int ci = 0; ci < n; ++ci) {
            if (ci != pi && ci != qi) {
              if (dist(t[ci], center) <= 1) {
                ++cnt_d;
              }
            }
          }
          ans = max(ans, cnt_d);
        }
      }
    }
    cout << ans << endl;
  }
}

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

double Dis(double x1, double y1, double x2, double y2);
int main(void){
	while(1){
		int n;
		int ans = 1;
		vector< pair<double, double> > p;

		cin >> n;
		if(n == 0) break;

		for(int i=0; i<n; i++){
			pair<double, double> t;
			cin >> t.first >> t.second;
			p.push_back(t);
		}

		for(int i=0; i<n; i++){
			for(int j=i+1; j<n; j++){
				//中点
				double mpx = (p[i].first + p[j].first) / 2.0;
				double mpy = (p[i].second + p[j].second) / 2.0;
				//2点間の距離
				double d1 = Dis(p[i].first, p[i].second, p[j].first, p[j].second);
				//p[i]からp[j]へ向かうベクトル
				double v1x = (p[j].first - p[i].first) / d1;
				double v1y = (p[j].second - p[i].second) / d1;
				//中点から円の中心へ向かう単位ベクトル
				double v2x = -v1y;
				double v2y = v1x;
				//中心から円の中心へ向かうベクトルの長さ
				double d2 = sqrt(1.0 - (d1*d1/4.0));

				//円の中心の座標
				double cx = mpx + v2x * d2;
				double cy = mpy + v2y * d2;

				int cnt = 0;
				for(int k=0; k<n; k++){
					if(k == i || k == j || (cx-p[k].first)*(cx-p[k].first) + (cy-p[k].second)*(cy-p[k].second) <= 1.0)	cnt++;
				}
				if(cnt > ans){
					ans = cnt;
				}

				cx = mpx - v2x * d2;
				cy = mpy - v2y * d2;

				cnt = 0;
				for(int k=0; k<n; k++){
				}
				if(cnt > ans){
					if(k == i || k == j || (cx-p[k].first)*(cx-p[k].first) + (cy-p[k].second)*(cy-p[k].second) <= 1.0)	cnt++;
					ans = cnt;
				}
			}
		}

		cout << ans << endl;


	}
	
	return 0;
}

double Dis(double x1, double y1, double x2, double y2){
	return sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

struct Point : public complex<double>
{
public:
  Point() { this->real(0);  this->imag(0); }
  Point(const double& x, const double& y) { this->real(x);  this->imag(y); }
  Point(const complex<double>& w)  { this->real(w.real());  this->imag(w.imag()); }
  inline double dot(Point p){ return (conj(*this) * p).real(); }  // 内積
  inline double det(Point p){ return (conj(*this) * p).imag(); }  // 外積
};

namespace std
{
  inline bool operator < (const Point& a, const Point& b)
  {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
typedef vector<Point> Polygon;
inline Point currPoint(vector<Point> P, int i){ return P[i]; }
inline Point nextPoint(vector<Point> P, int i){ return P[(i+1)%P.size()]; }
inline Point diffPoint(vector<Point> P, int i){ return nextPoint(P, i) - currPoint(P, i); }


struct Circle : Point
{
private:
  Point p;
  double r;

public:
  Circle(Point& p, double r) : p(p), r(r) {}
  Circle(double x, double y, double r) : p(Point(x, y)), r(r) {}
  inline Point center(){ return this->p; }
  inline double radius(){ return this->r; }
};

vector<Point> intersectionCC(Circle A, Circle B)
{
  vector<Point> ret;
  Point p = B.center() + A.center();
  Point d = B.center() - A.center();
  double m = (B.radius() + A.radius()) / abs(B.center() - A.center());
  double n = (B.radius() - A.radius()) / abs(B.center() - A.center());

  double s = m * n;
  double t = sqrt((m * m - 1.0) * (1.0 - n * n));

  ret.pb((p + Point(s, -t) * d) / 2.0);
  ret.pb((p + Point(s,  t) * d) / 2.0);

  return ret;
}


template<typename T> T add(T x, T y){ if(abs(x+y) < EPS*(abs(x)+abs(y))) return 0; return x + y; }
template<typename T> inline bool semieq(T x, T y){ return abs(x - y) < EPS; }
template<typename T> inline bool semige(T x, T y){ return y - x < -EPS; }
template<typename T> inline bool semile(T x, T y){ return x - y < -EPS; }

const double r = 1.0;
const int MAX_N = 300;
int N;
double x, y;

int main()
{
  while(~scanf("%d", &N) && N){
    vector<Point> p;
    int res = 0;
    rep(i, N){
      scanf("%lf %lf", &x, &y);
      p.pb(Point(x, y));
   }

    rep(i, N) rep(j, i) if(!semige(abs(p[i] - p[j]), 2.0)) {
      vector<Point> pnt = intersectionCC(Circle(p[i], r), Circle(p[j], r));
      vrep(v, pnt){
        int cnt = 0;
        vrep(w, p) if(!semige(abs(*w - *v), 1.0)) cnt += 1;
        //        cerr << cnt << endl;
        maxup(res, cnt);
      }
    }
    printf("%d\n", res);
  }


  return 0;
}