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<iostream>
#include<iomanip>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

using dbl = double;
using P = complex<dbl>;

const dbl EPS = 1e-10;
void solve(int n){
    vector<P> ps(n);
    for(int i=0;i<n;i++){
        dbl x,y;
        cin>>x>>y;
        ps[i] = {x,y};
    }

    if(n==1){
        cout<<1<<endl;
        return;
    }
    
    auto f=[&](P center){
        int res = 0;
        for(auto p:ps){
            if(abs(center-p)<=1+EPS) res++;
        }
        return res;
    };
    auto calc=[&](P a,P b){
        if(abs(a-b)>=2+EPS) return 0;
        P c = (a+b)/dbl(2);
        P d = (a-b)*P(0,1);
        dbl len = sqrt(max(1-abs(a-c)*abs(a-c),dbl(0)));
        d = d/abs(d)*len;
        return max(f(c+d),f(c-d));
    };
    int res = 1;
    for(int i=0;i<n;i++){
        for(int j=0;j<i;j++){
            res = max(res,calc(ps[i],ps[j]));
        }
    }
    cout<<res<<endl;
    return;
}
int main(){
    int n;
    while(cin>>n,n){
        solve(n);
    }
    return 0;
}

C++: #include<bits/stdc++.h>
#define N 300
using namespace std;
typedef complex<double> P;
const double EPS = 1e-8;

struct Circle{
  P c;
  double r;
  Circle(P c=P(0,0),double r=0):c(c),r(r){}
};

vector<P> getIntersectCC(Circle c1, Circle c2){
  vector<P> res;
  double r1=c1.r,r2=c2.r,d;
  P p1=c1.c,p2=c2.c;
  d=abs(p1-p2);
  if(d<EPS&&abs(r1-r2)<EPS) return res;
  if(r1+r2<d-EPS||d+EPS<abs(r1-r2)) return res; 
  double a=(r1*r1-r2*r2+d*d)/(2*d);
  double h=sqrt(max(r1*r1-a*a,0.0));
  P tmp1=p1+a/d*(p2-p1);
  P tmp2=h/d*(p2-p1);
  if(abs(tmp2)<EPS)res.push_back(tmp1);
  else{
    res.push_back(P(real(tmp1)-imag(tmp2),imag(tmp1)+real(tmp2)));
    res.push_back(P(real(tmp1)+imag(tmp2),imag(tmp1)-real(tmp2)));
  }
  return res;
}

double getdistancepp(P a,P b){
  return sqrt((a.real()-b.real())*(a.real()-b.real())+(a.imag()-b.imag())*(a.imag()-b.imag()));
}

int main(){
  int n,ans=0;
  double a,b;
  P p[N];
  while(1){
    cin>>n;
    if(!n)break;
    for(int i=0;i<n;i++){
      cin>>a>>b;
      p[i]=P(a,b);
    }
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
	Circle c1,c2;
	c1.c=p[i];
	c2.c=p[j];
	c1.r=c2.r=1;
	vector<P> r=getIntersectCC(c1,c2);
	if(!r.size())continue;
	for(int k=0;k<r.size();k++){
	  int cnt=0;
	  for(int l=0;l<n;l++)
	    if(getdistancepp(r[k],p[l])<=1+EPS)cnt++;	    
	  ans=max(ans,cnt);
	}
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
static const double EPS = 1e-8;
static const double PI = 3.14159265;

typedef complex<double> P;
struct C {P p; double r;C(const P &p, double r) : p(p), r(r) { }};
#define toRad(n) (n*(PI/180.0))
vector<P> data;
pair<C,C> get(P a,P b){
	P diff = a-b;
	if(abs(diff) > 2)return make_pair(C(P(-1,-1),-1),C(P(-1,-1),-1));
	double theta = atan2(diff.imag(),diff.real()) + toRad(90);
	P mid = (a+b) / 2.0;
	double d = sqrt( 1 - (abs(diff)*abs(diff))/4.0 );
	double X = cos(theta)*d , Y = sin(theta)*d;
	return make_pair(C(mid+P(X,Y),1),C(mid-P(X,Y),1));
}
int check(C t){
	int ret = 0;
	rep(i,data.size()){
		if(abs(data[i]-t.p) <= 1+EPS)ret++;
	}
	return ret;
}
int main(){
	int n; 
	while(cin >> n , n){
		data.resize(n);
		rep(i,n){
			cin >> data[i].real() >> data[i].imag();
		}
		int ret = 1;
		rep(i,n){
			for(int j=i+1;j<n;j++){
				pair<C,C> g = get(data[i],data[j]);
				if(g.first.r == -1)continue;
				ret = max(ret,check(g.first));
				ret = max(ret,check(g.second));
			}
		}
		cout << ret << endl;
	}
}

C++: #include<iostream>
#include<complex>
#define rep(i,n) for(int i=0;i<n;i++)
#define EPS 1e-8
using namespace std;
typedef complex<double> P;
int main(){
	int n; double x,y;
	while(cin>>n,n){
		P p[n]; rep(i,n)cin>>x>>y,p[i]=P(x,y);
		int mx=1,m1,m2;
		rep(i,n)rep(j,i)if(norm(p[i]-p[j])<4+EPS){
			P M=(p[i]+p[j])/P(2,0),C1,C2; double l=sqrt(1-norm(M-p[i]));
			C1=M+polar(l,arg(p[j]-p[i])+M_PI/2);
			C2=M+polar(l,arg(p[j]-p[i])-M_PI/2);
			m1=m2=0;
			rep(k,n){
				if(norm(p[k]-C1)<1+EPS)m1++; if(norm(p[k]-C2)<1+EPS)m2++;
			}
			if(m1>mx)mx=m1; if(m2>mx)mx=m2;
		}
		cout<<mx<<endl;
	}
	return 0;
}