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++: //#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const ll INF = (1LL<<60);
#else
const int INF = (1LL<<30);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

// y???real(), x???imag()
//point
typedef complex<double> P;
namespace std {
	bool operator < (const P& a, const P& b) {
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
	bool cmp_y(const P &a, const P &b){
		return a.imag() != b.imag() ? a.imag() < b.imag() : a.real() < b.real();
	}
}
// circle
struct C {
	P p; double r;
	C(const P& p, double r) : p(p), r(r) {}
};

// 2???p1, p2?????????????????????r?????????2?????????
vector<C> calcCircle(P p1, P p2, double r) {
	if(abs(p1-p2) > 2*r) return {};
	P p3 = {(p1.real()+p2.real())/2, (p1.imag()+p2.imag())/2};
	// cout << p3.real() << " " << p3.imag() << endl;
	double l = abs(p1-p3);
	// cout << "l:" << l << endl;
	// ????????????p_1p_2
	P p1p2 = p2-p1;
	double a = p1p2.real(), b = p1p2.imag();
	double dx = b*sqrt((r*r-l*l)/(a*a+b*b)), dy = a*sqrt((r*r-l*l)/(a*a+b*b));
	// cout << "dx:" << dx << " dy:" << dy << endl;
	return {{{p3.real()+dx, p3.imag()-dy}, r}, {{p3.real()-dx, p3.imag()+dy}, r}};
}

// ???p??????c????????¨????????¨??????????????????
bool intersectCP(C c, P p) { return abs(p-c.p) <= c.r + EPS; }

P po[305];
signed main(void)
{
  while(true) {
    int n;
    cin >> n;
    if(!n) break;
    REP(i, n) {
      double x, y;
      cin >> x >> y;
      po[i] = {x, y};
    }

    int ans = 0;
    REP(i, n) FOR(j, i+1, n) {
      vector<C> ret = calcCircle(po[i], po[j], 1);
      if(ret.size() == 0) continue;
      // cout << "i:" << i << " j:" << j << endl;
      // cout << ret[0].p.real() << " " << ret[0].p.imag() << " " << ret[0].r << endl;
      // cout << ret[1].p.real() << " " << ret[1].p.imag() << " " << ret[1].r << endl;
      int num = 0;
      REP(k, n) {
        num += intersectCP(ret[0], po[k])?1:0;
        // if(intersectCP(ret[0], po[k])) cout << k << " ";
      }
      chmax(ans, num);
      // cout << "num:" << num << endl;
      num = 0;
      REP(k, n) {
        num += intersectCP(ret[1], po[k])?1:0;
        // if(intersectCP(ret[1], po[k])) cout << k << " ";
      }
      // cout << "num:" << num << endl;
      chmax(ans, num);
    }

    cout << ans << endl;
  }

  return 0;
}

C++: //???????????????????????????, ?????????????????????????????°????????????????????????????????????????????????2???????????¨???????????£?????\????????¨?????§????????????
//?????£???, 2??????????????????1?????????????????????????????????????????°??????????????????????£????, O(N^2)????????????????????????, ??¨?????§O(N^3)????????§?§£?????????
#include <iostream>
#include <complex>
#include <vector>
using namespace std;
typedef complex<double> Point;

int n;
double x[300], y[300];
vector<Point> points;	//????£???????

int main() {
	while (cin >> n) {
		if (n == 0) break;
		for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
		if (n == 1) { cout << 1 << endl; continue; }
		
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				Point p1 = Point(x[i], y[i]);
				Point p2 = Point(x[j], y[j]);
				if (norm(p1 - p2) < 4) {
					double h = sqrt(1.0 - norm(p1 - p2) / 4.0);
					Point t = p2 - p1; t /= abs(t);
					Point u = t * Point(0, 1);
					points.push_back(p1 + t * abs(p1 - p2) / 2.0 + u * h);
					points.push_back(p1 + t * abs(p1 - p2) / 2.0 - u * h);
				}
			}
		}
		
		double eps = 1e-7;
		int ans = 0;
		for (int i = 0; i < points.size(); i++) {
			double px = points[i].real();
			double py = points[i].imag();
			int cnt = 0;
			for (int j = 0; j < n; j++) {
				if ((x[j] - px) * (x[j] - px) + (y[j] - py) * (y[j] - py) < 1 + eps) {
					cnt++;
				}
			}
			if (ans < cnt) ans = cnt;
		}
		cout << ans << endl;
	}
	return 0;
}

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

using namespace std;

int N;
pair<double,double> dots[300];

int main(){

	while(cin >> N && N != 0){
		for(int i = 0; i < N; i++){
			pair<double,double> p;
			cin >> dots[i].second >> dots[i].first;
		}
		int maxCnt = 1;
		// ~ðìé½ßÌQ_ðßé
		for(int i = 0; i < N; i++){
			for(int j = i+1; j < N; j++){
				pair<double,double> dot1,dot2;
				dot1 = dots[i];
				dot2 = dots[j];

				double v = sqrt((dot1.first - dot2.first)*(dot1.first - dot2.first)
					+(dot1.second - dot2.second)*(dot1.second - dot2.second));
				// ñ_Ô£ª2æè¨¨«¯êÎÂ­êÈ¢
				if(v > 2){
					continue;
				}

				double x = sqrt(1 - (v/2)*(v/2));

				// ñgÌPÊ@üxNg
				pair<double,double> hose[2];
				hose[0].first = -1.0/(dots[i].first - dots[j].first);
				hose[0].second = 1.0/(dots[i].second - dots[j].second);
				hose[1].first = 1.0/(dots[i].first - dots[j].first);
				hose[1].second = -1.0/(dots[i].second - dots[j].second);

				double dd1 = sqrt((hose[0].second)*(hose[0].second)+(hose[0].first)*(hose[0].first));
				double dd2 = sqrt((hose[1].second)*(hose[1].second)+(hose[1].first)*(hose[1].first));
				hose[0].first /= dd1; hose[0].second /= dd1;
				hose[1].first /= dd2; hose[1].second /= dd2;

				// x{·é
				hose[0].first *= x;hose[1].first *= x;
				hose[0].second *= x;hose[1].second *= x;

				// mð«·
				hose[0].first += (dot1.first + dot2.first)/2;
				hose[0].second += (dot1.second + dot2.second)/2;
				hose[1].first += (dot1.first + dot2.first)/2;
				hose[1].second += (dot1.second + dot2.second)/2;

				// hose[0]Æhose[1]Í~ÌSÀW
				// e_ÉÖµÄ~ÌÉ¶Ý·é©Ç¤©ðßé
				for(int k = 0; k < 2; k++){
					int cnt = 0;
					for(int l = 0; l < N; l++){
						double dist = sqrt((dots[l].first -hose[k].first)*(dots[l].first -hose[k].first)
							+ (dots[l].second -hose[k].second)*(dots[l].second -hose[k].second));
						if(dist <= 1){
							cnt++;
						}
					}
					maxCnt = max(maxCnt,cnt);
				}
			}
		}
		cout << maxCnt << endl;
	}

	return 0;
}