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 <bits/stdc++.h>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

// ??\??? ????????¨???
template<class T> bool operator==(T a, T b){return abs(a-b)< eps;}
template<class T> bool operator< (T a, T b){return a < b-eps;}
template<class T> bool operator<=(T a, T b){return a < b+eps;}
template<class T> int sig(T r) {return (r==0||r==-0) ? 0 : r > 0 ? 1 : -1;}
#define X real()
#define Y imag()

typedef bool B;
typedef long double D;
typedef complex<D> P;

P p[310];

int main(void){
	int n;
	while(cin >> n,n){
		double ix,iy;
		rep(i,n){
			scanf("%lf %lf",&ix,&iy);
			p[i].real(ix),p[i].imag(iy);
		}
		int ans=1;
		rep(i,n)rep(j,n){
			if(i==j) continue;
			D d=norm(p[j]-p[i]);
			if(d>4.0) continue;
			P v=(p[j]-p[i])/P(2.0,0.0);
			D s=sqrt((1.0-norm(v))/norm(v));
			P cnt1=p[i]+v+s*P(v.imag(),-v.real());
			int num=2;
			rep(k,n){
				if(k==i||k==j) continue;
				if(norm(p[k]-cnt1)<1.0) num++;
			}
			ans=max(ans,num);
			P cnt2=p[i]+v+s*P(-v.imag(),v.real());
			int num2=2;
			rep(k,n){
				if(k==i||k==j) continue;
				if(norm(p[k]-cnt2)<1.0) num2++;
			}
			ans=max(ans,num2);
		}
		printf("%d\n",ans);
	}
	return 0;
}

C++: #include "bits/stdc++.h"
using namespace std;
typedef complex<double> Point;
const double eps = 1e-9;
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
	int N; 
	while (cin >> N, N) {
		vector<Point> P(N);
		for (int i = 0; i < N;i++) {
			double x, y; cin >> x >> y;
			P[i] = Point(x, y);
		}
		if (N == 1) { cout << 1 << endl; return 0; }
		int ans = 0;
		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);
			double difx = -(P[i] - P[j]).imag()*r / dist;
			double dify = (P[i] - P[j]).real()*r / dist;
			Point new_P(difx, dify);
			Point check_P(new_P + (P[i] + P[j]) / 2.0);
			
			int cnt = 0;
			for (int k = 0; k < N;k++) {
				if (abs(check_P - P[k]) < 1.0 + eps)cnt++;
			}
			ans = max(ans, cnt);
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <complex>
#include <vector>
#include <cmath>
#include <utility>
#include <algorithm>
using namespace std;


typedef complex<double> Point;
typedef pair<Point, Point> Line;
#define EPS 1e-9
#define INF 1000000000

double dis(Point a, Point b){ return abs(a - b); }
double dot(Point a, Point b){ return a.real() * b.real() + a.imag() * b.imag(); }
double cross(Point a, Point b){ return a.real() * b.imag() - a.imag() * b.real(); }
int ccw(Point a, Point b, Point c){
  if(cross(b - a, c - a) > EPS) return 1;
  if(cross(b - a, c - a) < -EPS) return -1;
  if(dot(b - a, c - a) < -EPS) return 2;
  if(dis(a, b) + EPS < dis(c, a)) return -2;
  return 0;
}
int ccw(Line a, Point b){ return ccw(a.first, a.second, b); }

bool SegmentCross(Line a, Line b){
  return ccw(a, b.first) * ccw(a, b.second) == -1
    && ccw(b, a.first) * ccw(b, a.second) == - 1;
}

Point MiddlePoint(Point a, Point b){
  double x = (a.real() + b.real()) / 2;
  double y = (a.imag() + b.imag()) / 2;
  return Point(x, y);
}

Line Equidistant(Point a, Point b, double r = -1){
  Point m = MiddlePoint(a, b);
  double m_dis = dis(m, a);
  double slope = (b.real() - a.real()) / (a.imag() - b.imag());
  
  if(r <= EPS){ r = m_dis * 2; }
  
  if(r <= m_dis + EPS){ return make_pair(Point(0, 0), Point(0, 0)); }

  double target_dis = r * r - m_dis * m_dis;
  double x = sqrt(target_dis / (1 + slope * slope));
  double y = slope * x;
  
  Point s(m.real() + x, m.imag() + y);
  Point t(m.real() - x, m.imag() - y);
  
  return make_pair(s, t);
}


int main(void){
  while(true){
    int n;
    cin >> n;
    if(n == 0){ break; }

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

    int ans = 1;
    for(int i = 0; i < n; i++){
      for(int j = i + 1; j < n; j++){
        Line tmpLine = Equidistant(P[i], P[j], 1 - EPS);
        if(tmpLine.first == tmpLine.second){ continue; }

        Point center[] = {tmpLine.first, tmpLine.second};
        for(int l = 0; l < 2; l++){
          int count = 0;
          for(int k = 0; k < n; k++){
            if(dis(center[l], P[k]) <= 1.0 + EPS){
              ++count;
            }
          }
          
          ans = max(ans, count);
        }
      }
    }

    // ??????
    cout << ans << endl;
     
  }

  return 0; 
}