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 <complex>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

#define X real()
#define Y imag()

// ----- debug macro -----
#define DMPPT(p,stream) stream << (p).X << "," << (p).Y
// ----- ----- ----- -----

// ???????§???????????§????????????£°????£°?????????????????????§???????????\?????¶????????????????????¶????????????????¨????????§???????????£???
typedef complex<double> PT;
typedef complex<double> VC;

// ??¶??´??±???or ??±?£?????????????????????´??????????£??????§???????????????????????VC get_vc_normal(VC a) {
	a = a * PT(0,-1);
	return a / abs(a);
}

int N;
const double EPS = 1e-9;

// rest code
int main() {
	while(cin >> N, N) {
		vector<PT> p;
		for(int i = 0; i < N; i++) {
			double x, y;
			cin >> x >> y;
			p.push_back(PT(x,y));
		}

		int res = 1;
		for(int i = 0; i < p.size(); i++) {
			for(int j = 0; j < p.size(); j++) {
				if(i == j) continue;
				VC a, b;
				PT c[2];
				double len;
				a = (p[j] - p[i]) / 2.0;
				if(abs(a) > 1.0) continue;
				b = get_vc_normal(a);
				len = sqrt(1.0 - norm(a));
				c[0] = p[i] + a + len*b;
				c[1] = p[i] + a - len*b;

				for(int k = 0; k < 2; k++) {
					int tmp = 0;
					for(int l = 0; l < p.size(); l++) {
						if(abs(c[k] - p[l]) < 1.0 + EPS) tmp++;
					}
					res = max(res, tmp);
				}
			}
		}
		cout << res << endl;
	}
}

C++: #include <iostream>
#include <cmath>
#define eps 1.0e-9

using namespace std;

int N;
double x[305], y[305];

int count(double cx, double cy)
{
	int ret = 0;
	for(int i = 0; i < N; i++){
		if( (cx - x[i])*(cx - x[i]) + (cy - y[i])*(cy - y[i]) <= 1 + eps) ret++;
	}
	return ret;
}

int main(void)
{
	while(1){
		cin >> N;
		if(N == 0) break;
		for(int i = 0; i < N; i++) cin >> x[i] >> y[i];
		
		int ans = 1;
		double cx, cy;
		for(int i = 0; i < N; i++){
			for(int j = 0; j < N; j++){
				if(i >= j) continue;
				
				double px = x[j] - x[i];
				double py = y[j] - y[i];
				double pnorm = sqrt(px*px + py*py);
				px /= pnorm;
				py /= pnorm;
				
				double mx = (x[i] + x[j]) / 2.0;
				double my = (y[i] + y[j]) / 2.0;
				
				double qnorm = 1 - pnorm*pnorm/4.0;
				if(qnorm < eps) continue;
				qnorm = sqrt(qnorm);
				double qx = qnorm * py;
				double qy = qnorm * -px;
				
				ans = max(ans, count(mx + qx, my + qy));
				ans = max(ans, count(mx - qx, my - qy));
			}
		}
		cout << ans << endl;
	}
	
	return 0;
}