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++: /**
 *  Circle and Points (PKU 1981)
 *  by Kenji Inoue, 2007-01-05
 **/

#include <iostream>
#include <math.h>

using namespace std;

#define EPS (1e-6)

double x[300], y[300];

int sign[] = {+1, -1};

int main(void) {
  int n;
  while (cin >> n, n) {
    for (int i=0; i<n; i++) {
      cin >> x[i] >> y[i];
    }

    int ans = 1;
    for (int i=0; i<n; i++) {
      for (int j=i+1; j<n; j++) {
        double d = hypot(x[i]-x[j], y[i]-y[j]);
        if ( d > 2.0 + EPS ) { continue; }

        double mx = (x[i] + x[j]) / 2;
        double my = (y[i] + y[j]) / 2;
        double vx = (x[j] - x[i]) / d;
        double vy = (y[j] - y[i]) / d;
        double e = sqrt(1.0 - d*d/4.0);

        for (int s=0; s<2; s++) {
          double px = mx + sign[s]*e*vy;
          double py = my - sign[s]*e*vx;

          int cnt = 2;
          for (int k=0; k<n; k++) {
            if (k==i || k==j) { continue; }
            if ( (px-x[k])*(px-x[k]) + (py-y[k])*(py-y[k]) < 1.0 + EPS ) { cnt++; }
          }
          if (cnt > ans) { ans = cnt; }
        }
      }
    }

    cout << ans << endl;
  }
  return 0;
}

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;

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; }


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; }
};

int intersectionDeterminationOfCC(Circle A, Circle B)
{
  double d = abs(A.center() - B.center());
  if(semile(d, A.radius() - B.radius())) return  1;  // B in A
  if(semile(d, B.radius() - A.radius())) return -1;  // A in B
  if(semieq(d, A.radius() - B.radius())) return  2;  // B in A????????\???
  if(semieq(d, B.radius() - A.radius())) return -2;  // A in B????????\???
  if(semige(d, A.radius() + B.radius())) return  3;  // ???????????????
  if(semieq(d, A.radius() + B.radius())) return -3;  // ?????\
  return 4;  // ????????£?????????
}


// ???????????????????¨±??????????????????????????????????????¨????????????????¨???????????????????
vector<Point> intersectionOfCC(Circle A, Circle B)
{
  vector<Point> ret;
  double d = abs(A.center() - B.center());
  double rc = (d * d + A.radius() * A.radius() - B.radius() * B.radius()) / (2.0 * d);
  double rs = sqrt(A.radius() * A.radius() - rc * rc);
  Point diff = (B.center() - A.center()) / d;
  ret.pb(A.center() + diff * Point(rc,  rs));
  ret.pb(A.center() + diff * Point(rc, -rs));
  return ret;
}

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

int main()
{
  while((cin >> N) && N){
    vector<Point> P;

    rep(i, N){
      cin >> x >> y;
      P.pb(Point(x, y));
    }

    int res = 1;
    rep(i, N) rep(j, i) if(!semige(abs(P[i] - P[j]), 2.0 * r)){
      Circle A = Circle(P[i], r);
      Circle B = Circle(P[j], r);
      vector<Point> PP = intersectionOfCC(A, B);

      vrep(v, PP){
        int cnt = 0;
        vrep(w, P) if(!semige(abs(*w - *v), r)) cnt += 1;
        maxup(res, cnt);
      }
    }
    cout << res << endl;
  }

  return 0;
}

C++: #include<iostream>
#include<complex>
#include<algorithm>
#include<cmath>
#define EPS 1e-8
using namespace std;
 
typedef complex<double> P;
 
P center(P a,P b){
  P m = (a+b)/2.0;
  P n = (a-b)*P(0,1);
  n = n/abs(n);
 
  double x = abs(a-b)/2.0;
  return m + n*sqrt(1.0 - x*x);
}
 
int main(){
  int n;
  P p[300];
 
  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=0;j<n;j++){
    if(i!=j){
      if(abs(p[i]-p[j])+EPS>2.0)continue;
      P c = center(p[i],p[j]);
      int num = 0;
      for(int k=0;k<n;k++)
        if(abs(c-p[k])<1.0+EPS)num++;
      ans = max(ans,num);
    }
      }
    }
    cout << ans << endl;
  }
}