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 <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.00001
using namespace std;

struct Point{
	bool operator<(const struct Point &arg) const{
			return x < arg.x;
	};
	double x,y;
};

double a,b,c,d;

double calc(double x){
	return ((c-a)*x)/(b-d)+(b+d)/2-(c-a)*(a+c)/(2*(b-d));
}


double dist(double x,double y){
	return sqrt((x-a)*(x-a)+(y-b)*(y-b));
}

int main(){

	int N,maximum,count;
	Point points[300];
	double left,right,m,tmp_x,tmp_y,tmp_dist;

	bool FLG;

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		maximum = 1;

		for(int loop = 0; loop < N; loop++){
			scanf("%lf %lf",&points[loop].x,&points[loop].y);
		}

		sort(points,points+N);

		for(int i = 0; i <= N-2; i++){
			for(int k = i+1; k <= N-1; k++){

				a = points[i].x;
				b = points[i].y;
				c = points[k].x;
				d = points[k].y;

				left = 0.0;
				right = (a+c)/2;
				m = (left+right)/2;

				FLG = false;

				while(left <= right){
					tmp_y = calc(m);
					tmp_dist = dist(m,tmp_y);

					if(fabs(tmp_dist-1.0) < EPS){
						FLG = true;
						tmp_x = m;
						break;
					}else if(tmp_dist > 1.0){
						left = m + EPS;
					}else{
						right = m - EPS;
					}
					m = (left+right)/2.0;
				}

				if(FLG){
					count = 0;
					for(int p = 0; p < N; p++){
						if(sqrt((tmp_x-points[p].x)*(tmp_x-points[p].x)+(tmp_y-points[p].y)*(tmp_y-points[p].y)) < 1.0){
							count++;
						}else if(fabs(sqrt((tmp_x-points[p].x)*(tmp_x-points[p].x)+(tmp_y-points[p].y)*(tmp_y-points[p].y))-1.0) <= EPS){
							count++;
						}
					}
					maximum = max(maximum,count);
				}

				left = (a+c)/2;
				right = 10.0;
				m = (left+right)/2;
				FLG = false;

				while(left <= right){
					tmp_y = calc(m);
					tmp_dist = dist(m,tmp_y);

					if(fabs(tmp_dist-1.0) < EPS){
						FLG = true;
						tmp_x = m;
						break;
					}else if(tmp_dist > 1.0){
						right = m - EPS;
					}else{
						left = m + EPS;
					}
					m = (left+right)/2.0;
				}

				if(FLG){
					count = 0;
					for(int p = 0; p < N; p++){
						if(sqrt((tmp_x-points[p].x)*(tmp_x-points[p].x)+(tmp_y-points[p].y)*(tmp_y-points[p].y)) < 1.0){
							count++;
						}else if(fabs(sqrt((tmp_x-points[p].x)*(tmp_x-points[p].x)+(tmp_y-points[p].y)*(tmp_y-points[p].y))-1.0) <= EPS){
							count++;
						}
					}
					maximum = max(maximum,count);
				}

			}
		}

		printf("%d\n",maximum);
	}

	return 0;
}