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 <complex>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

#define X real()
#define Y imag()

// ----- debug macro -----
#define DMPPT(p,stream) stream << (p).X << "," << (p).Y
// ----- ----- ----- -----

// ????????????????§???????????????????????????\??????????????????????????¨???????????????
typedef complex<double> PT;
typedef complex<double> VC;

// ??´??? or ???????????????????????????????????????
VC get_vc_normal(VC a) {
	a = a * PT(0,-1);
	return a / abs(a);
}

int N;
const double EPS = 1e-9;

// rest code
int main() {
	while(cin >> N, N) {
		vector<PT> p;
		for(int i = 0; i < N; i++) {
			double x, y;
			cin >> x >> y;
			p.push_back(PT(x,y));
		}

		int res = 1;
		for(int i = 0; i < p.size(); i++) {
			for(int j = 0; j < p.size(); j++) {
				if(i == j) continue;
				VC a, b;
				PT c[2];
				double len;
				a = (p[j] - p[i]) / 2.0;
				if(abs(a) > 1.0) continue;
				b = get_vc_normal(a);
				len = sqrt(1.0 - norm(a));
				c[0] = p[i] + a + len*b;
				c[1] = p[i] + a - len*b;

				for(int k = 0; k < 2; k++) {
					int tmp = 0;
					for(int l = 0; l < p.size(); l++) {
						if(abs(c[k] - p[l]) < 1.0 + EPS) tmp++;
					}
					res = max(res, tmp);
				}
			}
		}
		cout << res << endl;
	}
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
const double EPS = 1e-8;
typedef pair<double,double> P;

inline double dist(P p,P q){
  return ( (p.first-q.first)*(p.first-q.first) + (p.second-q.second)*(p.second-q.second));
}

int main(){
  int N;
  double sign[2] = {+1, -1};
  while(cin>>N,N){
    vector<P> p(N);
    REP(i,N)cin>>p[i].first>>p[i].second;
    int ans = 1;
    REP(i,N){
      REP(j,N){
        double dst = dist(p[i],p[j]);
        if(dst > 4.0) continue;
        P v((p[j].first-p[i].first)/dst, (p[j].second-p[i].second)/dst);
        P m((p[j].first+p[i].first)/2.0, (p[j].second+p[i].second)/2.0);
        double lth = sqrt(1.0-dst*dst/4.0);
        REP(k,2){
          double cx = m.first + sign[k] * v.first * lth;
          double cy = m.second - sign[k] * v.second * lth;
          P center(cx,cy);
          int count = 0;
          REP(l,N){
            if(l == i || l == j || dist(center,p[l]) < 1){
              count++;
            }
          }
          ans = max(ans, count);
        }
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

C++: #include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const long double EPS = 10e-6;

class Point{
    public: 
    long double x,y;
    
    Point(long double x = 0.0, long double y = 0.0): x(x), y(y) {}
    
    Point operator + (Point p) {
        return Point(x+p.x, y+p.y);
    }
    Point operator - (Point p) {
        return Point(x-p.x, y-p.y);
    }
    Point operator * (long double a) {
        return Point(x*a, y*a);
    }
    Point operator / (long double a) {
        return Point(x/a, y/a);
    }
    bool operator < (const Point &p) const {
        return (x != p.x ? x < p.x : y < p.y);
    }
    bool operator == (const Point &p) const {
        return fabsl(x - p.x) < EPS && fabsl(y - p.y) < EPS;
    }
    
    long double abs() {
        return sqrt(norm());
    }
    
    long double norm() {
        return x*x + y*y;
    }
    
    long double dot(Point p) {
        return x*p.x + y*p.y;
    }
    
    long double cross(Point p) {
        return x*p.y - y*p.x;
    }
};

class Segment{
    public: 
    Point p,q;
    long double grad;
    
    Segment(Point p, Point q): p(p), q(q) {
        this->grad = (q.y-p.y)/(q.x-p.x);
    }
    
};

class Circle{
    public:
    Point c;
    long double r;
    
    Circle(Point c = Point(), long double r = 0.0): c(c), r(r) {}
};

Point calc_center(Point p, Point mid, Point midv){
    midv = midv / midv.abs() * sqrt((1.0 - mid.norm()));
    return p+mid+midv;
}

int count(vector<Point> points, Point center){
    int tmp = 0;
    for(Point p: points){
        if((p-center).norm() <= 1.0 + EPS) tmp++;
    }
    return tmp;
}

int main() {
    int n;
    while(scanf("%d", &n) && n){
        vector<Point> points(n);
        rep(n) scanf("%Lf %Lf", &points[i].x, &points[i].y);

        int ans = 1;
        rep(n){
            repp(j, n){
                if(j == i) continue;
                Point mid = (points[j] - points[i]) * 0.5;
                Point center = calc_center(points[i], mid, Point(mid.y, -mid.x));
                ans = max(count(points, center), ans);

                center = calc_center(points[i], mid, Point(-mid.y, mid.x));
                ans = max(count(points, center), ans);
            }
        }
        printf("%d\n", ans);
    }
}