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 <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <numeric>
#include <tuple>
#include <assert.h>

#define sqr(x) std::pow(x, 2.0)
#define INF 1e10
#define EPS 1e-10
#define REP(i, n) for (int i = 0; i < n; i++)
#define POS_OR_INF(x) (x > 0 ? x : INF)

using namespace std;

using ld = long double;

struct Point {
	Point() = default;
	Point(ld x, ld y): x(x), y(y) {}
	Point(const Point& s, const Point& e) : x(e.x-s.x), y(e.y-s.y) {}

	Point normalized(void) const {
		return Point(x / norm(), y / norm());
	}

	ld norm(void) const {
		return sqrt(x * x + y * y);
	}

	Point flipped(void) const {
		return Point(-x, -y);
	}

	Point normal_vector(bool normalize = false) const {
		auto vec = Point(-y, x);
		return normalize ? vec.normalized() : vec;
	}

	ld x, y;
};

using Vector = Point;

inline Vector points2vec(const Point& s, const Point& e) {
	return Vector(e.x - s.x, e.y - s.y);
}

inline ld distance(const Point& s, const Point& e) {
	return points2vec(s, e).norm();
}

inline ld distance_square(const Point& s, const Point& e) {
	return pow(points2vec(s, e).norm(), 2.0);
}

inline Vector operator * (const Vector& l, ld r) {
	return Vector(l.x * r, l.y * r);
}

inline Vector operator * (ld l, const Vector& r) {
	return r * l;
}

inline Vector operator / (const Vector& l, ld r) {
	return Vector(l.x / r, l.y / r);
}

inline Point operator + (const Point& l, const Point& r) {
	return Point(l.x + r.x, l.y + r.y);
}

inline Point operator - (const Point& l, const Point& r) {
	return Point(l.x - r.x, l.y - r.y);
}

inline istream& operator >> (istream& is, Point& p) {
	return is >> p.x >> p.y;
}

int main(int argc, char** argv) {
	int N;

	while (cin >> N && N > 0) {
		vector<Point> p(N);

		REP(i, N)
			cin >> p[i];

		long ans = 1;

		for (int i = 0; i < N; i++) {
			for (int j = i + 1; j < N; j++) {
				if (distance(p[i], p[j]) > 2.0) continue;

				auto mid = (p[i] + p[j]) / 2;
				auto l = sqrt(4 - distance_square(p[i], p[j])) / 2;
				auto normal = Vector(p[i], p[j]).normal_vector(true);

				auto center1 = mid + normal * l;
				auto center2 = mid - normal * l;

				long n1 = count_if(p.begin(), p.end(), [&](const Point& p) { return distance(center1, p) <= 1.0 + EPS; });
				long n2 = count_if(p.begin(), p.end(), [&](const Point& p) { return distance(center2, p) <= 1.0 + EPS; });

				ans = max(ans, max(n1, n2));
			}
		}
		cout << ans << endl;
	}
}

C++: #include<iostream>
#include<complex>
#include<cmath>
#include<algorithm>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define EPS 1e-10
#define PI 3.141592653589793238
// sqrtは重い
using namespace std;
typedef pair<double,double> P;

void display(complex<double> a,complex<double> b){
 cout << "(" << a.real() <<"," << a.imag() <<")"<< " " <<"("<< b.real() <<"," <<b.imag() << ")" << endl;
}

int main(){
  int n,ans;
  double xin,yin,X;
  complex<double> m;
  while(cin >> n && n){
    ans = 0;
    complex<double> point[n];
    for(int i=0;i<n;i++){
      cin >> xin >> yin;
      point[i] = complex<double>(xin,yin);
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	if(i == j)continue;
	complex<double> Rr = point[i]-point[j];
	if(abs(Rr) <= 2.0+EPS){

	  complex<double> UKPC,U,P1,P2;
	  UKPC = (point[i]+point[j])*0.5;
       
	  double T = sqrt(1-norm(point[i]-point[j])*0.25);

	  UKPC = (point[i]+point[j])*0.5;
	               /* unit vector(単位べく利ゅ)             *//* T倍に拡大 ９０度回転 */ 
  	  P1 = UKPC + (point[i]-point[j])/abs(point[i]-point[j])*polar(T,PI/2.0);
	  P2 = UKPC + (point[i]-point[j])/abs(point[i]-point[j])*polar(T,-PI/2.0);
	  //cout << "P1 = " << P1 << ", P2 = " << P2 << endl;
	  int cnt=0;
	  complex<double> CalcP;
	  double Calc;
	  for(int k=0;k<n;k++){
	    Calc = abs(P1-point[k]);
	    if(Calc < 1.0+EPS){
	      cnt++;
	    }
	  }	

	  ans = max(ans,cnt);
	  cnt = 0;
	  for(int k=0;k<n;k++){
	    Calc = abs(P2-point[k]);
	    if(fabs(Calc) < 1.0+EPS){
	      cnt++;
	    }
	  }	
  
	  ans = max(ans,cnt);
	  

	}

      }
    }

    cout << ans << endl;

  }
  return 0;
}

C++: #include <cmath>  
#include <algorithm>
#include <iostream>
#include <utility>

using namespace std;

const double eps=1e-8; 
struct point{
	double x,y;	
}P[310];
int x,y,N;
int ans=1;

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

point cal_center(point a, point b){
	point mid,center;
	mid.x = (a.x+b.x)/2.0;
	mid.y = (a.y+b.y)/2.0;
	double angle = atan2(a.x-b.x,b.y-a.y);
	double line = sqrt(1-(cal_distance(a,mid)*cal_distance(a,mid)));
	center.x = mid.x+line*cos(angle);
	center.y = mid.y+line*sin(angle);
	return center;
}

int main(){
	while(cin >> N && N>0){
		for (int i=0; i<N; i++){
				cin >> P[i].x >> P[i].y;
			}
			for (int i=0; i<N; i++){
				for (int j=i+1; j<N; j++){
					if (cal_distance(P[i],P[j]) > 2.0) continue;
					point center = cal_center(P[i], P[j]);
					int count = 0;
					for (int k=0; k<N;k++){
						if (cal_distance(P[k],center) < (1.0+eps)) count++;
					}
					ans = max(ans,count);
				}
			}
		cout << ans << endl;
	}
}

C++: #include <stdio.h>
#include <algorithm>
#include <iostream>
#include <stack>
#include <vector>
#include <math.h>
#include <queue>

using namespace std;

struct Point{
    double x,y;
};

void func(int N){

    Point point[N];
    double x_min = 100,y_min = 100,x_max = -1,y_max = -1;

    for(int i = 0; i < N; i++){
        scanf("%lf %lf",&point[i].x,&point[i].y);
        x_min = min(point[i].x,x_min);
        y_min = min(point[i].y,y_min);
        x_max = max(point[i].x,x_max);
        y_max = max(point[i].y,y_max);
    }

    if(x_min > 1)x_min -= 0.05;
    if(y_min > 1)y_min -= 0.05;
    if(x_max < 9)x_max += 0.05;
    if(y_max < 9)y_max += 0.05;

    int count,max_count = 0;

    for(double y = y_min; y <= y_max; y += 0.01){
        for(double x = x_min; x <= x_max; x += 0.01){
            count = 0;
            for(int i = 0; i < N; i++){
                if(sqrt((x-point[i].x)*(x-point[i].x)+(y-point[i].y)*(y-point[i].y)) <= 1.0)count++;
            }
            max_count = max(max_count,count);
        }
    }

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


int main(){

    int N;

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

        func(N);
    }


    return 0;
}