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;

#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 double eps=1e-9;
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,201){
            const long double y=10.*i/200;
            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;
}

C++: #include <cstdio>
#include <complex>
#include <cmath>
using namespace std;
typedef complex<double> point;

point ins[310];
int main(){
    for(;;){
        int N;
        scanf("%d",&N);
        if(N==0) break;
        double x,y;
        for(int i=0;i<N;i++){
            scanf("%lf%lf",&x,&y);
            ins[i]=point(x,y);
        }
        int ma=1;
        for(int i=0;i<N;i++){
            for(int j=i+1;j<N;j++){
                double no=norm(ins[i]-ins[j]);
                if(no<4){
                    double di=sqrt(1-no/4);
                    point hen=(ins[i]-ins[j])*point(cos(M_PI/2),sin(M_PI/2))*(di/sqrt(norm(ins[i]-ins[j])));
                    point cen[2];
                    cen[0]=(ins[i]+ins[j])/2.0+hen;
                    cen[1]=(ins[i]+ins[j])/2.0-hen;
                    for(int k=0;k<2;k++){
                        int cnt=2;
                        for(int l=0;l<N;l++){
                            if(l==i || l==j) continue;
                            if(norm(cen[k]-ins[l])<1) cnt++;
                        }
                        ma=max(ma,cnt);
                    }
                }
            }
        }
        printf("%d\n",ma);
    }
}

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

#define EPS 1e-8
typedef complex<double> P;

P center(P a, P b){
  P m  = (a+b) / 2.0;    // p[i]Æp[j]Ì_
  P n = (a-b) * P(0,1);  // @üxNg
  n = n / abs(n);
  
  double x = abs( a-b )/2.0;
  return m + n * sqrt( 1.0-x*x );     // ~ÌS
}

int main(){
  int n;
  P p[301];

  while( cin>>n && n ){
    for( int i=0;i<n;i++ )
      cin >> p[i].real() >> p[i].imag();

    int ans=0;
    for( int i=0;i<n;i++ ){
      for( int j=0;j<n;j++ ){
	if( i==j ) 	  continue;
	if( abs( p[i]-p[j] )+EPS > 2.0 ) continue;
	P c = center( p[i],p[j] );

	int num=0;
	for( int k=0;k<n;k++ )
	  if( abs( c-p[k] ) < 1.0 + EPS  )
	    num++;
	ans = max( ans,num );
      }
    }
    cout << ans << endl;
  }

  return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <utility>

using namespace std;

typedef complex<double> Point;

bool eqv(double a, double b) {
    return abs(a-b) < 1e-10;
}

bool inCircle(const Point &p, const Point &center, double radius) {
    double dist2 = norm(p-center);
    double rad2 = radius*radius;
    return dist2 < radius*radius || eqv(dist2, rad2);
}

int check(const Point &center, const vector<Point> &points) {
    const int N = points.size();
    int cnt = 0;
    for(int i = 0; i < N; ++i) {
        if(inCircle(points[i], center, 1)) ++cnt;
    }
    return cnt;
}

int test(int a, int b, const vector<Point> &points) {
    const Point v(points[a]-points[b]);
    const double hlen = abs(v)/2;

    if(hlen*hlen >= 1) return 0;
    const double plen = sqrt(1 - hlen*hlen);
    Point perp = v*Point(0, 1);
    perp /= abs(perp);
    const Point mid = points[b] + v/2.0;
    return max(check(mid + perp*plen, points), check(mid - perp*plen, points));
}

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

    while(true) {
        int N;
        cin >> N;
        if(!N) break;

        vector<Point> points(N);
        for(int i = 0; i < N; ++i) {
            cin >> points[i].real() >> points[i].imag();
        }
        int ans = 0;
        for(int i = 0; i < N; ++i) {
            for(int j = 0; j < i; ++j) {
                ans = max(ans, test(i, j, points));
            }
        }
        cout << ans << endl;
    }
    return 0;
}

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

double ds(double x1,double y1,double x2,double y2){
  return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}

int main(){
  int n;
  while(1){
  cin>>n;
  if(n==0)break;
  double x[310],y[310];
  for(int i=0;i<n;i++){
    cin>>x[i]>>y[i];
  }

  int ma=1;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      double d=ds(x[i],y[i],x[j],y[j]);
      if(d>2.0)continue;
      double tx=(x[i]+x[j])/2;
      double ty=(y[i]+y[j])/2;
      double k=sqrt(1-(d/2.0)*(d/2.0));
      double vx,vy,tvx,tvy;
      vx=x[i]-tx;
      vy=y[i]-ty; 
      tvx=-vy;
      tvy=vx;
      double l=sqrt(tvx*tvx+tvy*tvy);
      tvx/=l;
      tvy/=l;
      int cnt=2;
      // cout<<tvx<<" "<<tvy<<endl;
      double ox,oy;
      ox=tx+tvx*k;
      oy=ty+tvy*k;
      //cout<<ox<<" "<<oy<<endl;
      for(int k=0;k<n;k++){
	   if(i==k||j==k)continue;
	   if(ds(ox,oy,x[k],y[k])<=1)cnt++;
      }
      ma=max(ma,cnt);
      cnt=2;
      ox=tx-tvx*k;
      oy=ty-tvy*k;
      //cout<<ox<<" "<<oy<<endl;
      for(int k=0;k<n;k++){
	   if(i==k||j==k)continue;
	if(ds(ox,oy,x[k],y[k])<=1)cnt++;
      }
      ma=max(ma,cnt);
    }
  }
  cout<<ma<<endl;
}
  return 0;
}