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 <algorithm>/*{{{*/
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

static const double PI (3.14159265358979323846);
static const double EPS (1e-10);

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef complex<double> P;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define FOR(i, b, e) for (typeof(b) i = (b); assert((i) <= (e)), i != (e); ++i)
#define REP(i, n) FOR(i, 0, n)

#define OPOVER(_op, _type) inline bool operator _op (const _type &t) const

#define arrsz(a) ( sizeof(a) / sizeof(a[0]) )

#define F first
#define S second
#define MP(a, b) make_pair(a, b)

#define SZ(a) ((ll)a.size())
#define PB(e) push_back(e)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())

#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

#define BIT(n) (1ULL << (n))
#define BITOF(n, m) ((n) >> (m) & 1)

#define RANGE(a, b, c) ((a) <= (b) && (b) <= (c))

#define DEBUG_ON_

#ifdef DEBUG_ON
	#define dprt(fmt, ...) fprintf(stderr, fmt, __VA_ARGS__)
	#define darr(a) copy( (a), (a) + arrsz(a), ostream_iterator<int>(cerr, " ") ); cerr << endl
	#define darr_range(a, f, t) copy( (a) + (f), (a) + (t), ostream_iterator<int>(cerr, " ") ); cerr << endl
	#define dvec(v) copy( ALL(v), ostream_iterator<int>(cerr, " ") ); cerr << endl
	#define darr2(a, n, m) FOR(i, 0, (n)){ darr_range( (a)[i], 0, (m) ); }
	#define dvec2(v) FOR(i, 0, SZ(v)){ dvec( (v)[i] ); }
	#define WAIT() { string _wait_; cerr << "(hit return to continue)" << endl; getline(cin, _wait_); }
#else
	#define dprt(fmt, ...)
	#define darr(a)
	#define darr_range(a, f, t)
	#define dvec(v)
	#define darr2(a, n, m)
	#define dvec2(v)
	#define WAIT()
#endif
/*}}}*/

int N;
vector<P> points;

P middle_point(P a, P b)
{
	return a + (b-a) / 2.0;
}

// 点pを中心としてr(radian)回転 p(0,0)で原点を中心として回転
P rotate(P t, P p ,double r){
	// double r=radians(angle);
	return (t - p) * P(cos(r), sin(r)) + p;
}

// 2円 |x-a|=raと|x-b|=rbの交点計算
bool intersection_c_c(P a, double ra, P b, double rb, P ans[]){
	double di = abs(a-b);
	if(di > ra+rb || di < abs(ra-rb)) return false;
	double t=(ra*ra - rb*rb + di*di) / (di+di);
	double rd = acos(t/ra);

	P dv = (b-a) / abs(b-a);
	P g1 = rotate(dv, P(0,0), rd);
	P g2 = rotate(dv, P(0,0), -rd);
	ans[0] = a + g1*ra;
	ans[1] = a + g2*ra;
	return true;
}

int main(int argc, char const* argv[])
{
	while (cin >> N, N) {
		int ans = 1;
		points.clear();
		REP(i, N) {
			double x, y;
			cin >> x >> y;
			points.PB(P(x, y));
		}
		REP(i, N) {
			FOR(j, i+1, N) {
				P p1 = points[i], p2 = points[j];
				dprt("(%lf, %lf) and (%lf, %lf)\n", p1.real(), p1.imag(), p2.real(), p2.imag());
				P centers[2];
				if (intersection_c_c(p1, 1, p2, 1, centers)) {
					REP(k, 2) {
						dprt(" center: (%lf, %lf)\n", centers[k].real(), centers[k].imag());
						int cnt = 0;
						REP(l, N) {
							if (abs(centers[k] - points[l]) < 1.0 + EPS) {
								++cnt;
							}
						}
						ans = max(ans, cnt);
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

C++: 3
1 0
0 0
0 1
3
6.47634 7.69628
5.16828 4.79915
6.69533 6.20378
6
7.15296 4.08328
6.50827 2.69466
5.91219 3.86661
5.29853 4.16097
6.10838 3.46039
6.34060 2.41599
8
7.90650 4.01746
4.10998 4.18354
4.67289 4.01887
6.33885 4.28388
4.98106 3.82728
5.12379 5.16473
7.84664 4.67693
4.02776 3.87990
20
6.65128 5.47490
6.42743 6.26189
6.35864 4.61611
6.59020 4.54228
4.43967 5.70059
4.38226 5.70536
5.50755 6.18163
7.41971 6.13668
6.71936 3.04496
5.61832 4.23857
5.99424 4.29328
5.60961 4.32998
6.82242 5.79683
5.44693 3.82724
6.70906 3.65736
7.89087 5.68000
6.23300 4.59530
5.92401 4.92329
6.24168 3.81389
6.22671 3.62210
0

C++: #include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
using namespace std;

const double ESP = 1E-9;
double x[300];
double y[300];

int main(){
	int n;
	while(cin >> n && n){
		for(int i = 0; i < n; i++){
			cin >> x[i];
			cin >> y[i];
		}
		int count = 1;
		for(int i = 1; i < n; i++){
			for(int j = 0; j < i; j++){
				double dx = x[j] - x[i];
				double dy = y[j] - y[i];
				double mx = (x[j]+x[i]) / 2;
				double my = (y[j]+y[i]) / 2;
				double dis = sqrt(dx*dx + dy*dy);
				if(dis > 2.0) continue;
				double mdis = dis / 2;
				double dis2 = sqrt(1-mdis*mdis);
				dx /= dis;
				dy /= dis;
				double px[2], py[2];
				px[0] = mx + dis2 * dy;
				px[1] = mx - dis2 * dy;
				py[0] = my - dis2 * dx;
				py[1] = my + dis2 * dx;
				for(int k = 0; k < 2; k++){
					int c = 0;
					for(int l = 0; l < n; l++){
						double dx2 = px[k] - x[l];
						double dy2 = py[k] - y[l];
						double dis3 = dx2 * dx2 + dy2 * dy2;
						if(dis3 < 1 + ESP) c++;
					}
					count = max(count, c);
				}
			}
		}
		cout << count << endl;
	}
	return 0;
}