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 <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <bitset>
#include <iostream>
#include <iomanip>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <numeric>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e16;

/*
<url:>
問題文============================================================

=================================================================

解説=============================================================

================================================================
*/
typedef pair<double,double> Point;
const double eps = 1e-9;
Point P[305];

inline double Abs(const Point& p1,const Point& p2){
    return sqrt((p1.first - p2.first)*(p1.first - p2.first) + (p1.second - p2.second)*(p1.second - p2.second));
}
int main(void) {
//	cin.tie(0); ios::sync_with_stdio(false);
    int N;
    while(true){
        scanf("%d",&N);
        if(N == 0) break;
        for(int i = 0; i < N;i++){
            double x,y; scanf("%lf%lf",&x,&y);
            P[i] = Point(x,y);
        }
        if(N == 1){
            printf("1\n");
            continue;
        }
        int ans = 1;
        for(int i = 0; i < N;i++){
            for(int j = i + 1; j < N;j++){
                double dist = Abs(P[i],P[j]);
                if(dist > 2) continue;
                double r = sqrt(1 - dist*dist/4);
                Point cp = make_pair(-(P[i].second - P[j].second)*r/dist + (P[i].first + P[j].first)/2.0,
                                     (P[i].first - P[j].first)*r/dist + (P[i].second + P[j].second)/2.0);
                int cnt = 0;
                for(int k = 0; k < N;k++){
                    if(Abs(cp,P[k]) < 1.0 + eps) cnt++;
                }
                ans = max(ans,cnt);
            }
        }
        printf("%d\n",ans);
    }
	return 0;
}

C++: #include<bits/stdc++.h>
#define N 300
using namespace std;
typedef complex<double> P;
const double EPS = 1e-5;

struct Circle{
  P c;
  double r;
  Circle(P c=P(0,0),double r=0):c(c),r(r){}
};

vector<P> getIntersectCC(Circle c1, Circle c2){
  vector<P> res;
  double r1=c1.r,r2=c2.r,d;
  P p1=c1.c,p2=c2.c;
  d=abs(p1-p2);
  if(d<EPS&&abs(r1-r2)<EPS) return res;
  if(r1+r2<d-EPS||d+EPS<abs(r1-r2)) return res; 
  double a=(r1*r1-r2*r2+d*d)/(2*d);
  double h=sqrt(max(r1*r1-a*a,0.0));
  P tmp1=p1+a/d*(p2-p1);
  P tmp2=h/d*(p2-p1);
  if(abs(tmp2)<EPS)res.push_back(tmp1);
  else{
    res.push_back(P(real(tmp1)-imag(tmp2),imag(tmp1)+real(tmp2)));
    res.push_back(P(real(tmp1)+imag(tmp2),imag(tmp1)-real(tmp2)));
  }
  return res;
}

double getdistancepp(P a,P b){
  return sqrt((a.real()-b.real())*(a.real()-b.real())+(a.imag()-b.imag())*(a.imag()-b.imag()));
}

int main(){
  int n,ans=0;
  double a,b;
  P p[N];
  while(1){
    cin>>n;
    if(!n)break;
    for(int i=0;i<n;i++){
      cin>>a>>b;
      p[i]=P(a,b);
    }
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
	Circle c1,c2;
	c1.c=p[i];
	c2.c=p[j];
	c1.r=c2.r=1;
	vector<P> r=getIntersectCC(c1,c2);
	if(!r.size())continue;
	for(int k=0;k<r.size();k++){
	  int cnt=0;
	  for(int l=0;l<n;l++)
	    if(getdistancepp(r[k],p[l])<=1+EPS)cnt++;	    
	  ans=max(ans,cnt);
	}
      }
    }
    if(!ans&&n>=1)ans=1;
    cout<<ans<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <cmath>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;

int main(void) {
  for(int N; cin >> N, N > 0;) {
    double x[300], y[300];
    REP(i, 0, N) cin >> x[i] >> y[i];

    int answer = 1;
    REP(i, 0, N) {
      REP(j, i + 1, N) {
        double d = sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
        if(d > 2.) continue;
        double vx = (x[i] - x[j]) / d;
        double vy = (y[i] - y[j]) / d;
        double l = sqrt(1. - d * d / 4.);
        double sx = (x[i] + x[j]) / 2.;
        double sy = (y[i] + y[j]) / 2.;

        double cx1 = sx - vy * l;
        double cy1 = sy + vx * l;
        int cnt1 = 0;
        REP(k, 0, N) if(k == i || k == j || (x[k] - cx1) * (x[k] - cx1) + (y[k] - cy1) * (y[k] - cy1) <= 1.0) cnt1++;
        answer = max(answer, cnt1);

        double cx2 = sx + vy * l;
        double cy2 = sy - vx * l;
        int cnt2 = 0;
        REP(k, 0, N) if(k == i || k == j || (x[k] - cx2) * (x[k] - cx2) + (y[k] - cy2) * (y[k] - cy2) <= 1.0) cnt2++;
        answer = max(answer, cnt2);
      }
    }

    cout << answer << endl;
  }

  return 0;
}