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 <cmath>
#include <vector>
#define eq(a,b) (fabs(a-b) < eps)
#define leq(a,b) (a - b < eps)
#define lt(a,b) (a - b < -eps)

const double EPS = 1e-4; // epsilon
const double R = 1;      // radius of circle

/* Distance from (x1,y1) to (x2,y2) */
double dist(std::pair<double, double> a, std::pair<double, double> b) {
    
    double ax, ay, bx, by;
    ax = a.first;
    ay = a.second;
    bx = b.first;
    by = b.second;
    return std::sqrt(
                        (by - ay) * (by - ay) +
                        (bx - ax) * (bx - ax)
                    );
}

/* Midpoint of two points */
std::pair<double, double>
getMidpoint(std::pair<double, double> a, std::pair<double, double> b) {
    std::pair<double, double> mid;
    mid.first = (a.first + b.first) / 2;
    mid.second = (a.second + b.second) / 2;
    return mid;
}

std::pair<std::pair<double,double>, std::pair<double,double>>
circleLineInter(std::pair<double, double> center, double r, double m, double c) {

    std::pair<double,double> inter1;
    std::pair<double,double> inter2;
    
    double p = center.first;
    double q = center.second;
    
    double A = m*m + 1;
    double B = 2*(m*c-m*q-p);
    double C = q*q - r*r + p*p -2*c*q + c*c;
    
    inter1.first = (-B + std::sqrt(B*B - 4*A*C)) / (2*A);
    inter1.second = m * inter1.first + c;
    
    inter2.first = (-B - std::sqrt(B*B - 4*A*C)) / (2*A);
    inter2.second = m * inter2.first + c;
    
    return std::make_pair(inter1, inter2);
}

double getYInter(double m, std::pair<double, double> a) {
    return a.second - m * a.first;
}

double getGradient(std::pair<double, double> a, std::pair<double, double> b) {
    return (b.second - a.second) /
           (b.first - a.first);
}

int main() {
    int n;
    while (std::cin >> n) {
        if (n <= 0) break;
        int maxPts = 1;
        if (n > 1) {
            std::vector<std::pair<double, double>> pts;
        
            // insert points into vector
            for(int i = 0; i < n; ++i) {
                double x, y;
                std::cin >> x >> y;
                pts.emplace_back(x, y);
            }
            
            for (unsigned int i = 0; i < pts.size() - 1; ++i) {
                for (unsigned int j = i + 1; j < pts.size(); ++j) {
                    // std::pair<double, double> a, b;
                    auto a = pts.at(i);
                    auto b = pts.at(j);
                    if( dist(a, b) <= 2*(R-EPS)) {
                        int numPts = 0;
                        
                        auto midpoint = getMidpoint(a, b);
                        auto m = getGradient(a,b);
                        m = -1 / m;
                        auto intersects = circleLineInter(a, R, m, getYInter(m, midpoint));
                        
                        auto c = intersects.first;
                        // std::cout << c.first << " " << c.second << "\n";
                        for (unsigned int k = 0; k < pts.size(); ++k) {
                            auto p = pts.at(k);
                            if (dist(c, p) <= (R + EPS)) {
                                numPts++;
                            }
                        }
                        maxPts = std::max(numPts, maxPts);
                        
                        numPts = 0;
                        c = intersects.second;
                        // std::cout << c.first << " " << c.second << "\n";
                        for (unsigned int k = 0; k < pts.size(); ++k) {
                            auto p = pts.at(k);
                            if (dist(c, p) <= (R + EPS)) {
                                numPts++;
                            }
                        }
                        maxPts = std::max(numPts, maxPts);
                    }
                }
            }
        
        }
        std::cout << maxPts << "\n";
    }
    return 0;
}

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

using namespace std;

#define int long long
#define MKP make_pair
#define fi first
#define se second
typedef pair<int, int> pii;

constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 205;
constexpr int MAX_W = 10005;
constexpr int INF = 1LL << 60;

/* 基本要素 */

typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;
const D EPS = 1e-9;    // 許容誤差。問題によって変える
#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

// 内積　dot(a,b) = |a||b|cosθ
D dot(P a, P b) {
  return (conj(a)*b).X;
}
// 外積　cross(a,b) = |a||b|sinθ
D cross(P a, P b) {
  return (conj(a)*b).Y;
}

VP crosspointCC(P a, D ar, P b, D br) {
  VP ps;
  P ab = b-a;
  D d = abs(ab);
  D crL = (norm(ab) + ar*ar - br*br) / (2*d);
  if (EQ(d, 0) || ar < abs(crL)) return ps;

  P abN = ab * P(0, sqrt(ar*ar - crL*crL) / d);
  P cp = a + crL/d * ab;
  ps.push_back(cp + abN);
  if (!EQ(norm(abN), 0)) ps.push_back(cp - abN);
  return ps;
}

int n;
vector<P> v;

bool solve() {
    v.clear();
    cin >> n;
    if (!n) return false;

    for (int i = 0; i < n; ++i) {
        double x, y;
        cin >> x >> y;
        v.emplace_back(P(x, y));
    }

    int res = 1;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            auto crs = crosspointCC(v[i], 1.0, v[j], 1.0);
            for (int k = 0; k < crs.size(); ++k) {
                int cnt = 0;
                for (int l = 0; l < n; ++l) {
                    double dist = abs(crs[k] - v[l]);
                    if (dist <= 1.0 + EPS) cnt++;
                }

                res = max(res, cnt);
            }
        }
    }

    cout << res << endl;

    return true;
}

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

    while (solve());
}