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;

#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}

const double EPS = 1e-8;
using P =  complex<double>;
namespace std {
  bool isnan(const P&p){
    return isnan(p.real()) or isnan(p.imag());
  }
}
struct C {
  P p; double r;
  C(const P &p_, double r_) : p(p_), r(r_) { }
};

// 交わらない場合はnanを返す
pair<P, P> crosspointCC(const C& c1, const C& c2){
  double d = abs(c1.p - c2.p);
  double rc = (d*d + c1.r*c1.r - c2.r*c2.r) / (2*d);
  double rs = sqrt(c1.r*c1.r - rc*rc);
  P diff = (c2.p - c1.p) / d;
  return make_pair(c1.p + diff * P(rc, rs), c1.p + diff * P(rc, -rs));
}

signed main(){
  int n;
  while(cin >> n, n){
    vector<P> ps(n);
    rep(i,n){
      double x, y; cin >> x >> y;
      ps[i].real(x);
      ps[i].imag(y);
    }
    vector<P> can;
    rep(i,n) FOR(j,i+1,n){
      C c1(ps[i],1), c2(ps[j],1);
      auto tmp = crosspointCC(c1, c2);
      if(not isnan(tmp.first))
	can.push_back(tmp.first);
      if((not isnan(tmp.second)) and abs(tmp.first - tmp.second) > EPS)
	can.push_back(tmp.second);
    }

    int ans = 1;
    rep(i,can.size()){
      int tmp = 0;
      rep(j,n)
	if(abs(can[i] - ps[j]) - EPS < 1) tmp++;
      chmax(ans, tmp);
    }
    cout << ans << endl;
  }
}

C++: #include <iostream>
#include <complex>

using namespace std;

typedef complex<double> P;

#define EPS (1e-6)

P p[300];
P tmp;

int main() {
  int n;
  while (cin >> n, n) {
    for (int i=0; i<n; i++) {
      cin >> p[i].real() >> p[i].imag();
    }

    int ans = 1;
    for (int i=0; i<n; i++) {
      for (int j=i+1; j<n; j++) {
        P v = p[i] - p[j];
        double absv = abs(v);
        if (absv > 2.0 + EPS) { continue; }

        P m = p[j] + (v / 2.0);
        P unv = (v * P(0, 1)) / absv; // unit normal vector
        P nv = sqrt(1.0 - absv*absv/4.0) * unv;
        for (int s=0; s<2; s++) {
          nv *= -1;
          P c = m + nv; // center point of the circle

          int cnt = 0;
          for (int k=0; k<n; k++) {
            // if (abs(p[k] - c) < 1.0 + EPS) { cnt++; } // too slow
            tmp = p[k] - c;
            if ( tmp.real()*tmp.real() + tmp.imag()*tmp.imag() < 1.0 + EPS ) { cnt++; }
          }
          if (cnt > ans) { ans = cnt; }
        }
      }
    }

    cout << ans << endl;
  }

  return 0;
}