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 <bits/stdc++.h>
using namespace std;

const double EPS = 1e-6;
using P = complex<double>;
int n;
P p[300];

int main(){
  while (cin >> n, n){
    for (int i = 0; i < n; i++){
      double x, y;
      cin >> x >> y;
      p[i] = P(x, y);
    }
    vector<P> ps;
    for (int i = 0; i < n; i++){
      for (int j = 0; j < i; j++){
        if (abs(p[i] - p[j]) >= 2.0) continue;
        P v = p[j] - p[i];
        P u = v * P(0.0, 1.0);
        u *= sqrt(1.0 - abs(v) / 2.0) / abs(u);
        ps.push_back(p[i] + v / 2.0 + u);
        ps.push_back(p[i] + v / 2.0 - u);
      }
    }
    int res = 1;
    for (P c : ps){
      int s = 0;
      for (int i = 0; i < n; i++){
        s += abs(c - p[i]) <= 1.0 + EPS;
      }
      res = max(res, s);
    }
    cout << res << endl;
  }
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef complex<double> pt;
#define rep(i,n) for(int i=0;i<n;i++)
int n;
pt z[305];
int check(pt C){
	int ret = 0;
	rep(i,n){
		if(abs(z[i]-C) <= 1.0+1e-12) ret++;
	}
	assert(ret>=2);
	return ret;
}
int main(){
	while(1){
		scanf("%d",&n);
		if(n == 0) return 0;
		rep(i,n){
			double x,y; scanf("%lf%lf",&x,&y);
			z[i] = pt(x,y);
		}
		int ans = 1;
		rep(i,n) for(int j=i+1;j<n;j++){
			if(abs(z[i]-z[j]) > 2.0+1e-12) continue;
			pt mid = (z[i]+z[j])/2.0;
			double leng = sqrt(1.0-abs(z[i]-z[j])*abs(z[i]-z[j])/4.0);
			pt c1 = mid + (z[i]-z[j])/abs(z[i]-z[j]) * polar(leng,3.141592653589/2.0);
			pt c2 = mid - (z[i]-z[j])/abs(z[i]-z[j]) * polar(leng,3.141592653589/2.0);
			ans = max(ans,check(c1));
			ans = max(ans,check(c2));
		}
		printf("%d\n",ans);
	}
}

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

#define EPS 1e-8

typedef complex<double> P;
typedef const P &rP;

const double pi = acos(-1.0);

void intrcc(rP p1, double r1, rP p2, double r2, vector<P> &ret){
	double d = abs(p2 - p1);
	double phi = arg(p2 - p1);
	
	double ct = (d * d + r1 * r1 - r2 * r2) / (2.0 * d * r1);
	if(abs(d) < EPS || abs(ct) > 1.0 + EPS){ return; }
	if(ct > 1.0){ ct = 1.0; }
	else if(ct < -1.0){ ct = -1.0; }
	
	double theta = acos(ct);

	ret.push_back(p1 + polar(r1, phi + theta));
	ret.push_back(p1 + polar(r1, phi - theta));
}

int main(){
	vector<P> chk;
	chk.reserve(100000);

	int n;
	while(scanf("%d", &n), n){
		chk.clear();

		vector<P> ps(n);
		double x, y;
		for(int i = 0; i < n; ++i){
			scanf("%lf%lf", &x, &y);
			ps[i] = P(x, y);
			
			for(int j = 0; j < i; ++j){
				intrcc(ps[i], 1.0, ps[j], 1.0, chk);
			}
		}
		
		int ans = 1;
		for(int i = 0; i < chk.size(); ++i){
			int cnt = 0;
			for(int j = 0; j < n; ++j){
				if(abs(ps[j] - chk[i]) < 1.0 + EPS){
					++cnt;
				}
			}
			ans = max(ans, cnt);
		}

		printf("%d\n", ans);
	}
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
#define EPS 1e-10
#define MOD 1000000007
using namespace std;
typedef pair<double,double> P;
typedef pair<int,P> PP;

int n;
int ans;
vector<double> x, y;
vector<PP> v1, v2;

void solve(){
	x.clear(); y.clear(); v1.clear(); v2.clear();
	x.resize(n); y.resize(n);
	ans = 1;
	rep(i,n) cin >> x[i] >> y[i];
	for(int i = 0; i <= 100; i++) for(int j = 0; j <= 100; j++){
		double I = i/10.0, J = j/10.0;
		int cnt = 0;
		rep(k,n){
			if((x[k]-I)*(x[k]-I)+(y[k]-J)*(y[k]-J) < 1) cnt++;
		}
		v1.push_back(PP(cnt,P(I,J)));
	}
	sort(v1.begin(),v1.end(), greater<PP>());
	rep(u,10){
		P p = v1[u].second;
		for(int i = 0; i <= 100; i++) for(int j = 0; j <= 100; j++){
			double I = p.first-0.05+i/1000.0, J = p.second-0.05+j/1000.0;
			int cnt = 0;
			rep(k,n){
				if((x[k]-I)*(x[k]-I)+(y[k]-J)*(y[k]-J) < 1) cnt++;
			}
			v2.push_back(PP(cnt,P(I,J)));
		}
	}
	sort(v2.begin(),v2.end(), greater<PP>());
	
	rep(u,10){
		P p = v2[u].second;
		for(int i = 0; i <= 100; i++) for(int j = 0; j <= 100; j++){
			double I = p.first-0.005+i/10000.0, J = p.second-0.005+j/10000.0;
			int cnt = 0;
			rep(k,n){
				if((x[k]-I)*(x[k]-I)+(y[k]-J)*(y[k]-J) < 1) cnt++;
			}
			ans = max(ans,cnt);
		}
	}
	cout << ans << endl;
}

int main(){
	while(cin >> n){
		if(n == 0) break;
		solve();
	}
}

C++: #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <complex>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <utility>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define each(e,c) for(auto&e:c)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<(DUMP(),__VA_ARGS__).str()<<" ["<<__LINE__<<"]"<<endl)
struct DUMP:ostringstream{template<class T>DUMP &operator,(const T&t){if(this->tellp())*this<<", ";*this<<t;return *this;}};
#else
#define dump(...)
#endif
template<class T> ostream& operator<<(ostream& os, vector<T> const& v){
    rep(i,v.size()) os << v[i] << (i+1==v.size()?"":" ");
    return os;
}

typedef double R;
typedef complex<R> P;
R const eps = 1e-8;
R const pi = acos(-1);

int main(){
    int n;
    while(cin>>n && n){
        vector<P> ps(n);
        rep(i,n){
            R x,y; cin >> x >> y;
            ps[i] = P(x,y);
        }
        int ans = 1;
        rep(i,n)rep(j,i){
            P & p = ps[i];
            P & q = ps[j];
            R d = abs(p-q)/2;
            if(d+eps > 1.0) continue;
            P m = (p+q)/R(2);
            R l = sqrt(1-d*d);
            P c = m + (p-m)/d*l*P(0,1);
            int cnt = 0;
            rep(k,n){
                if(abs(c-ps[k]) < 1.0+eps) cnt++;
                if(n-k+cnt+1 < ans) break;
            }
            ans = max(ans,cnt);
            if(ans==n) goto END;
        }
    END:;
        cout << ans << endl;
    }
}