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 <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

typedef complex<double> P;
const double r = 1.0;


vector<P> GetCrossPoint(P a, P b)
{
	vector<P> res;
	
	// ツ堕スツ閉ェツつャツづィツつャツづィツ静堋触ツつオツづつ「ツづゥ
	if(abs(abs(b - a) - r * 2) < EPS)
	{
		P c = a + b;
		res.push_back( P(c.real() / 2,c.imag() / 2) );
	}
	// ツ閉津環づ可古ーツづュツづづつ「ツづゥ
	else if(abs(b - a) < r * 2)
	{
		P ab = b - a;
		P center = a + P(ab.real() / 2, ab.imag() / 2);
		
		P u1 = (ab * P(0, +1)) / abs(ab);
		P u2 = (ab * P(0, -1)) / abs(ab);
		
		double dist = sqrt(1 - pow(abs(ab) / 2, 2));
		P c1 = center + u1 * dist;
		P c2 = center + u2 * dist;
		
		res.push_back(c1);
		res.push_back(c2);
	}
	
	return res;
}


int main()
{
	int n;
	while(cin >> n && n)
	{
		vector<P> c(n);
		
		double x, y;
		
		rep(i, n)
		{
			cin >> x >> y;
			
			c[i] = P(x, y);
		}
		
		
		int res = 1;
		
		rep(i, n) REP(j, i + 1, n)
		{
			vector<P> crs(GetCrossPoint(c[i], c[j]));
			
			rep(k, crs.size())
			{
				int cover = 2;
				
				rep(l, n) if(l != i && l != j && abs(crs[k] - c[l]) - 1.0 < EPS)
				{
					cover++;
				}
				
				chmax(res, cover);
			}
		}
		
		cout << res << endl;
	}
}

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 || n) {
		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++) {
			int cnt = 0;
			for (int j = 0; j < n; j++) {
				Point p = Point(x[j], y[j]);
				if (norm(points[i] - p) < 1 + eps) {
					cnt++;
				}
			}
			if (ans < cnt) ans = cnt;
		}
		cout << ans << endl;
	}
	return 0;
}

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)
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};
  P p[310];
  while(scanf("%d",&N) != EOF){
    if(N == 0)break;
    REP(i,N)scanf("%lf %lf",&p[i].first,&p[i].second);
    int ans = 1;
    REP(i,N)REP(j,N)if(i!=j){
      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.00001){
       count++;
       }
       if(N-l-1 + count < ans)break;
       }
       if(ans < count) ans = count;
       }
       */
      P dp((p[j].first-p[i].first)/2.0 , (p[j].second-p[i].second)/2.0);
      double d = sqrt(dist(P(0,0),dp));
      double t = sqrt(1.0-d*d)/d;
      P center(p[i].first + dp.first - t * dp.second, p[i].second + dp.second + t * dp.first);
      int count = 0;
      REP(k,N){
        if(dist(center,p[k]) < 0.00001 + 1)count++;
      }
      ans = max(ans,count);
    }
    printf("%d\n",ans);
  }
return 0;
}