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 _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;
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 = 0;
        rep(i,n)rep(j,n)if(i!=j){
            P & p = ps[i];
            P & q = ps[j];
            R d = abs(p-q);
            if(d > 2) continue;
            P m = (p+q)/2.;
            R l = sqrt(1-(d/2)*(d/2));
            P c = m + (p-m)*(d/2)*l * P(0,1);
            int cnt = 0;
            rep(k,n){
                if(abs(c-ps[k]) < 1+eps) cnt++;
            }
            ans = max(ans,cnt);
        }
        cout << ans << endl;
    }
}

C++: #include<cstdio>
#include<complex>
#include<iostream>
#include<algorithm>
#include<cmath>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

typedef complex<double> point;

int main(){
	
	A:;
	int n;
	cin>>n;
	if(n==0)return 0;
	
	point p[333];
	
	rep(i,n){
		double a,b;
		cin>>a>>b;
		p[i] = point(a,b);
	}
	double eps = 1E-8;
	int ans = 0;
	rep(i,n){
		reps(j,i+1,n){
			point d = (p[j]-p[i])/point(2,0);
			double dlen = abs(d);
			if(dlen>1)continue;
			
			//cout<<p[j]<<" "<<p[i]<<" "<<d<<" "<<dlen<<endl;
			
			point center = p[i]+d;
			point e1 = d/point(dlen,0)*point(0,1)*point(sqrt(1-dlen*dlen),0);
			point e2 = d/point(dlen,0)*point(0,-1)*point(sqrt(1-dlen*dlen),0);
			
			point t1 = center+e1;
			point t2 = center+e2;
			
			//cout<<t1<<" "<<t2<<endl;
			
			int count1 = 0;
			int count2 = 0;
			rep(k,n){
				if(abs(t1-p[k])<1+eps)count1++;
				if(abs(t2-p[k])<1+eps)count2++;
			}
			
			ans = max(ans,count1);
			ans = max(ans,count2);
		}
	}
	
	printf("%d\n",ans);
	
	goto A;
}

/*
3
0 1
1 0
1 1

*/

C++: #include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(_v) for(auto _x:_v){cout<<_x<<" ";}cout<<endl
#define printVS(vs) for(auto x : vs){cout << x << endl;}
#define printVV(_vv) for(auto _v:_vv){for(auto _x:_v){cout<<_x<<" ";}cout<<endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;

typedef complex<double> P;
typedef vector<P> G;
#define here(g, i) g[i]
#define next(g, i) g[(i + 1) % g.size()]
#define prev(g, i) g[(i - 1 + g.size()) % g.size()]
const double EPS = 1e-8;
const double INF = 1e12;
const double PI = acos(-1);

P readP() {
    double x, y;
    cin >> x >> y;
    return P(x, y);
}

// rot p around q by theta (counter-clockwise)
P rotP(P p, P q, double theta) {
    p -= q;
    double x = p.real(), y = p.imag();
    p = P(x * cos(theta) - y * sin(theta), x * sin(theta) + y * cos(theta));
    p += q;
    return p;
}

P center(P p, P q) {
    P v = p - q;
    double theta = asin(abs(v) / 2);
    v *= (1 / abs(v));
    P u = rotP(v, p, theta);
    return p + u;
}

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int n;
    while (cin >> n, n) {
        vector<P> p(n);
        rep(i, n) p[i] = readP();

        int ans = 1;
        rep(i, n) {
            rep(j, n) {
                if (i == j) continue;
                if (abs(p[i] - p[j]) <= 2) {
                    P c = center(p[i], p[j]);
                    int cnt = 2;
                    rep(k, n) {
                        if (k == i || k == j) continue;
                        if (abs(p[k] - c) <= 1) {
                            cnt++;
                        }
                    }
                    ans = max(ans, cnt);
                }
            }
        }

        cout << ans << endl;
    }
}

C++: #include<bits/stdc++.h>

using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
using P = complex<double>;
using vp = vector<P>;

vp points;
vp cross;

int main()
{
  int n;
  while(cin >> n,n){
    points.clear();
    cross.clear();

    REP(i,n){
      double a,b;
      cin >> a >> b;
      points.push_back({a,b});

    }
    REP(i,n)REP(j,n){
      auto dif = (points[i]-points[j]);
      if(abs(dif) <= 2){
        auto veci = dif/P(abs(dif),abs(dif));
        cross.push_back(points[j]+dif/P(2,2)+veci*P(0,1));
        cross.push_back(points[j]+dif/P(2.2)+veci*P(0,-1));
      }
    }

    int ma = 0;
    REP(i,cross.size()){
      int now = 0;
      REP(j,n){
      if(abs(cross[i]-points[j]) <= 1){
        now++;
      }
      ma = max(ma,now);
      }
    }
    cout << ma << endl;
  }
}