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>
using namespace std;
#include <math.h>
int main(){
	int n=0;
	while(cin>>n && n!=0){
		double x[300]={},y[300]={};
		int ans=1;
		for(int i=0;i<n;i++){
			cin>>x[i]>>y[i];
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(i!=j){
					double dx=x[i]-x[j],dy=y[i]-y[j];
					double dd=dx*dx+dy*dy;
					if(dd<4.0){
						double h=pow(1.0-dd/4.0,1.0/2.0),d=pow(dd,1.0/2.0);
						double px=(x[i]+x[j])/2.0+h*dy/d,py=(y[i]+y[j])/2.0-h*dx/d;
						int a=0;
						for(int k=0;k<n;k++){
							if((x[k]-px)*(x[k]-px)+(y[k]-py)*(y[k]-py)<1.001) a++;
						}
						if(a>ans)ans=a;
					}
				}
			}
		}
		cout<<ans<<endl;
	}
}

C++: #include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef pair<double, double> P;
const double EPS = 1e-4;

#include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()

using namespace std;

double dist(P a, P b)
{
    return hypot(a.first - b.first, a.second - b.second);
}

vector<P> center(P a, P b)
{
    auto t = atan2(b.first - a.first, b.second - a.second);
    auto x = dist(a, b) / 2;
    auto y = sqrt(1.0 - x * x);
    auto cs = cos(t), sn = sin(t);
    return { 
        { cs * x - sn * y + a.first, sn * x + cs * y + a.second },
        { cs * x + sn * y + a.first, sn * x - cs * y + a.second }
    };
}

int main()
{
    while (1) {
        int n; cin >> n;
        if (!n) break;
        vector<P> pnt;
        loop (n, i) {
            double x, y; cin >> x >> y;
            pnt.emplace_back(x, y);
        }
        int ans = 1;
        loop (n, i) loop (n, j) {
            auto ps = center(pnt[i], pnt[j]);
            for (auto o : ps) {
                int cnt = 0;
                loop (n, l) {
                    auto x = o.first - pnt[l].first;
                    auto y = o.second - pnt[l].second;
                    if (x * x + y * y < 1 + EPS) cnt++;
                    //if (dist(o, pnt[l]) < 1 + EPS) cnt++;
                }
                ans = max(ans, cnt);
            }
        }
        cout << ans << endl;
    }
    return 0;
}

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

const double eps = 1e-5;
const int MAXN = 333;
int N;
P ps[MAXN];

int calc(P c) {
  int res = 0;
  for(int i = 0; i < N; ++i) {
    double d = norm(c - ps[i]);
    if(d < 1.0 + eps) ++res;
  }
  return res;
}

int main() {
  for(; cin >> N && N; ) {
    for(int i = 0; i < N; ++i) {
      cin >> ps[i].real() >> ps[i].imag();
    }
    int res = 1;
    for(int i = 0; i < N; ++i) {
      for(int j = i+1; j < N; ++j) {
        P base = ps[j] - ps[i];
        P m = ps[i] + base / 2.0;
        double d = abs(base);
        double a = sqrt(1.0 - d * d / 4.0);
        P base2(-base.imag(), base.real());
        base2 = base2 / abs(base2) * a;
        res = max(res, max(calc(m + base2), calc(m - base2)));
      }
    }
    cout << res << endl;
  }
  return 0;
}