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 <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) const {
        return Point(x+p.x, y+p.y);
    }
    Point operator - (Point p) const {
        return Point(x-p.x, y-p.y);
    }
    Point operator * (long double a) const {
        return Point(x*a, y*a);
    }
    Point operator / (long double a) const {
        return Point(x/a, y/a);
    }

    long double norm() {
        return x*x + y*y;
    }
    
    long double dot(Point p) {
        return x*p.x + y*p.y;
    }
};

Point calc_center(Point p, Point mid, Point midv){
    long double norm = mid.norm();
    midv = midv * sqrt((1.0 - norm) / 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);
        debug(ans);
    }
}

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;

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

int countP(double x,double y,vector<P>& p){
  P t(x,y);
  int ans = 0;
  REP(i,p.size()){
    if(dist(t,p[i]) < 1 + EPS){
      ans ++;
    }
  }
  return ans;
}

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

C++: #include <cstdio>
#include <complex>
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;

typedef complex<double> coor;

#define EPS 1e-5

double in_cir(coor o, coor x)
{
  return abs(x - o);
}

int search(vector<coor> P)
{
  int mx = 0;
  /*for (int i = 0; i < P.size(); i++) {
    printf("%lf, %lf\n", P[i].real(), P[i].imag());
    }*/
  for (int i = 0; i < P.size(); i++) {
    for (int j = i + 1; j < P.size(); j++) {
      for (int k = 0; k < 2; k++) {
	if (abs(P[i] - P[j]) - 2.0 > -EPS) {continue;}
	coor d = coor(P[i].imag() - P[j].imag(),
		      -(P[i].real() - P[j].real()));
	if (k == 1) {d = -d;}
	d /= abs(d);
	d *= sqrt(1 - norm(P[i] - P[j]) / 4);
	//printf("abs(d) = %lf\n", abs(d));
	d += (P[i] + P[j]) / 2.0;
	//printf("%lf, %lf\n", d.real(), d.imag());
	int ctr = 2;
	for (int l = 0; l < P.size(); l++) {
	  //printf("%lf\n", in_cir(d, P[l]));
	  if (l == i || l == j) {continue;}
	  if (in_cir(d, P[l]) - 1.0 < -EPS) {
	    ctr++;
	  }
	}
	//printf("_%d\n", ctr);
	mx = max(ctr, mx);
	
      }
    }
  }
  return mx;
}

int main()
{
  int N;
  while (scanf("%d ", &N) == 1) {
    if (N == 0) {
      break;
    }
    vector<coor> P(N);
    for (int i = 0; i < N; i++) {
      double x, y;
      scanf("%lf %lf ", &x, &y);
      P[i] = coor(x, y);
    }
    printf("%d\n", search(P));
  }
  return 0;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<58;
const long double eps=1e-3;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    while(true){
        int n;
        cin >> n;
        if(n==0) break;
        vector<long double> xs(n),ys(n);
        rep(i,0,n) cin >> xs[i] >> ys[i];

        auto count=[&](const long double x,const long double y){
            int res=0;
            rep(i,0,n) if((xs[i]-x)*(xs[i]-x)+(ys[i]-y)*(ys[i]-y)<=1+eps) ++res;
            return res;
        };

        int ans=0;
        rep(i,0,2401){
            const long double y=10.*i/2400;
            rep(j,0,n){
                const long double tmp=1-(ys[j]-y)*(ys[j]-y);
                if(tmp<0) continue;
                const long double x1=xs[j]-sqrtl(tmp),x2=xs[j]+sqrt(tmp);
                ans=max({ans,count(x1,y),count(x2,y)});
            }
        }
        cout << ans << endl;
    }
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    cout << fixed << setprecision(8);
    solve();
    return 0;
}