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
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

struct P{
  double x, y;
  bool operator<(const P& r) const{
	return x < r.x || (x == r.x && y < r.y);
  }
};
int N;
P point[310];

double dist(P& cir, int i){
  return (cir.x - point[i].x)*(cir.x - point[i].x)
	+ (cir.y - point[i].y)*(cir.y - point[i].y);
}

int cnt(P& c){
  int res = 0;
  for(int i=0;i<N;++i)
	if(dist(c, i) <= 1.0)
	  ++res;
  return res;
}

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  while(true){
	cin >> N; if(N == 0) break;
	REP(i,N) cin >> point[i].x >> point[i].y;
	sort(point, point+N);

	int ans = 0;
	P c;
	for(int i1=0;i1<N;++i1){
	  for(int i2=i1+1;i2<N;++i2){
		for(int j1=0;j1<N;++j1){
		  for(int j2=j1+1;j2<N;++j2){
			c.x = (point[i1].x + point[i2].x) / 2.0;
			c.y = (point[j1].y + point[j2].y) / 2.0;
			ans = max(ans, cnt(c));
		  }
		}
	  }
	}
	
	cout << ans << endl;
  }

  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;

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

		int res=1;
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				if(abs(p[i]-p[j])>=2) continue;
				complex<double> mid=(p[i]+p[j])/complex<double>(2.0,0.0);
				auto a=(p[i]-p[j]);
				auto v=a*complex<double>(0,1);
				v=v/abs(v);
				double d=abs(mid-p[i]);
				double t=sqrt(1-d*d);
				complex<double> c[2]={mid+t*v,mid-t*v};
				for(int k=0;k<2;k++){
					int kai=0;
					for(int i=0;i<n;i++){
						if(abs(c[k]-p[i])<=1) kai++;
					}
					res=max(res,kai);
				}
			}
		}
		cout<<res<<endl;
	}

}

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

using namespace std;

#define all(c) ((c).begin()),((c).end())
#define debug(c) cerr<<"> "<<#c<<" = "<<(c)<<endl;
#define iter(c) __typeof((c).begin())
#define tr(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

#define EPS 1.0e-6

//ツ点
typedef complex<double> P;

struct C{
	P p;
	double r;
};

vector<P> isCC(const C &c1, const C &c2) {
	double d = abs(c1.p - c2.p);
	double x = (d*d + c1.r * c1.r - c2.r * c2.r) / 2 / d;
	double y = c1.r * c1.r - x * x;
	if(y < -EPS) return vector<P>();
	if(y < 0) y = 0;
	P diff = (c2.p - c1.p) / d;
	vector<P> res(2);
	res[0] = c1.p + diff * P(x, y);
	res[1] = c1.p + diff * P(x, -y);
	return res;
}

int main() {
	for (int N; cin >> N, N != 0; ) {
		vector<P> ps;
		rep (i, N) {
			double x, y; cin >> x >> y;
			ps.pb(P(x, y));
		}
		int res = 0;
		rep (i, N) REP (j, i + 1, N-1) {
			vector<P> isp = isCC((C){ps[i],1},(C){ps[j],1});
			rep (k, isp.size()) {
				int cnt = 0;
				rep (l, N) if (abs(isp[k] - ps[l]) <= 1) cnt++;
				res = max(res, cnt);
			}
		}
		cout << res <<endl;
	}
	
	return 0;
}

C++: #include <algorithm>
#include <iostream>
#include <stdio.h>
#include <complex>
#include <math.h>
#include <assert.h>

using namespace std;
typedef complex<double> Complex;

static const double E = 0.000001;

inline bool collide_circle_circle(const Complex p1, const double r1, const Complex p2, const double r2) {
  assert(r1 >= 0.0 && r2 >= 0.0);
  Complex dif = p1 - p2;
  return dif.real() * dif.real() + dif.imag() * dif.imag() <= (r1 + r2) * (r1 + r2) + E;
}

// include circle inside
inline bool collide_circle_point(const Complex p1, const double r1, const Complex p2) {
  return collide_circle_circle(p1, r1, p2, 0.0);
}

inline void intersection_circle_circle(const Complex p1, const double r1, const Complex p2, const double r2, int *size, Complex *ret1, Complex *ret2) {
  assert(p1 != p2);
  assert(ret1 != NULL && ret2 != NULL);
  if (!collide_circle_circle(p1, r1, p2, r2)) {
    if (size != NULL) { *size = 0; }
    *ret1 = *ret2 = Complex(NAN, NAN);
    return;
  }
  Complex center = (p1 * r2 + p2 * r1) / (r1 + r2);
  Complex vect = (center - p1) * Complex(0.0, 1.0);
  if (abs(vect) < E) {
    *ret1 = *ret2 = center;
    if (size != NULL) { *size = 1; }
    return;
  }
  vect *= sqrt(r1 * r1 - norm(vect)) / abs(vect);
  *ret1 = center + vect;
  *ret2 = center + vect * Complex(-1.0, 0.0);
  if (size != NULL) { *size = 2; }
}

Complex point[301];

int main() {
  int n;
  while (scanf("%d", &n), n != 0) {
    for (int i = 0; i < n; i++) {
      double a, b;
      scanf("%lf %lf", &a, &b);
      point[i] = Complex(a, b);
    }
    int max_ans = 1;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < i; j++) {
        if (!collide_circle_circle(point[i], 1.0, point[j], 1.0)) { continue; }
        int size;
        Complex m[2];
        intersection_circle_circle(point[i], 1.0, point[j], 1.0, &size, &m[0], &m[1]);
        for (int s = 0; s < size; s++) {
          int ans = 0;
          for (int k = 0; k < n; k++) {
            if (collide_circle_point(m[s], 1.0, point[k])) {
              ans++; }
          }
          max_ans = max(max_ans, ans);
        }
      }
    }
    printf("%d\n", max_ans);
  }
}