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 <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define F first
#define S second


int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};


main(){
  int n;
  while(cin>>n,n){
    double x[n],y[n];

    rep(i,n)cin>>x[i]>>y[i];

    int ans=0;

    rep(i,n){
      rep(j,i){
	double sx,sy;
	double tx=x[i]-x[j],ty=y[i]-y[j];
	double len=sqrt(tx*tx+ty*ty);
	if(len>2+EPS)continue;
	len=sqrt(1-len*len/4);
	double theta=atan2(ty,tx)+M_PI/2;
	int tans=0;
	sx=(x[i]+x[j])/2+cos(theta)*len;
	sy=(y[i]+y[j])/2+sin(theta)*len;
	rep(k,n){
	  tx=sx-x[k];
	  ty=sy-y[k];
	  if(tx*tx+ty*ty<=1+EPS)++tans;
	}
	ans=max(ans,tans);
	tans=0;
	sx=(x[i]+x[j])/2-cos(theta)*len;
	sy=(y[i]+y[j])/2-sin(theta)*len;
	rep(k,n){
	  tx=sx-x[k];
	  ty=sy-y[k];
	  if(tx*tx+ty*ty<=1+EPS)++tans;
	}
	ans=max(ans,tans);
      }
    }
    cout<<ans<<endl;
  }
}

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

using namespace std;

int main(){

	int n;
	double x[301],y[301];
	int cnt,ans;

	while(1){

		cin>>n;
		if(n==0) break;

		for(int i=0;i<n;i++){
			cin>>x[i]>>y[i];
		}

		ans=0;
		for(double i=0;i<=10;i+=0.01){
			for(double j=0;j<=10;j+=0.01){
				cnt=0;
				for(int k=0;k<n;k++){
					if(pow(i-x[k],2.0)+pow(j-y[k],2.0)<=1) cnt++;
				}
				if(cnt>ans) ans=cnt;
				cnt=0;
			}
		}
		cout<<ans<<endl;
	}

	return 0;
}

C++: #include <iostream>
#include <string>
#include <sstream>
#include <cmath>
#include <vector>

using namespace std;

typedef double ld;

struct Point {
    ld x, y;
    Point(ld x, ld y) : x(x), y(y) {}
    string to_s() {
        ostringstream os;
        os << x << ',' << y;
        return os.str();
    }
    Point operator+(const Point& o) const {
        return Point(x+o.x, y+o.y);
    }
    Point operator/(const int d) const {
        return Point(x/d, y/d);
    }
};

struct Circle {
    ld x, y;
    ld r;
    Circle(ld x=0, ld y=0, ld r=1) : x(x), y(y), r(r) {}
    const static ld eps = 1e-8;
    bool isIntersect(const Circle& o) const {
        ld dx = o.x - x;
        ld dy = o.y - y;
        return (r + o.r) * (r + o.r) > (dx*dx + dy*dy);
    }
    pair<Point, Point> intersectionPoint(const Circle& o) const {
        ld dx = o.x - x;
        ld dy = o.y - y;
        ld d = sqrt(dx*dx + dy*dy);

        ld slope = dy / dx;
        ld theta = atan(slope);
        ld theta_p = acos((r*r - o.r*o.r + d*d) / (2*r*d));

        return make_pair(
                Point(x + r*cos(theta - theta_p), y + r*sin(theta - theta_p)),
                Point(x + r*cos(theta + theta_p), y + r*sin(theta + theta_p)));
    }
    bool contains(ld px, ld py) const {
        return r * r + eps > (px - x) * (px - x) + (py - y) * (py - y);
    }
    string to_s() {
        ostringstream os;
        os << x << ',' << y << ':' << r << endl;
        return os.str();
    }
};

int countContainingPoints(const Circle& c, const vector<Circle>& ps) {
    int cnt = 0;
    for (int i = 0; i < ps.size(); i++) 
        if (c.contains(ps[i].x, ps[i].y)) 
            cnt++;
    return cnt;
}

Point midPoint(pair<Point, Point>& pp) {
    return (pp.first + pp.second) / 2;
}

int N;
int main() {
    vector<Circle> cs;
    while (cin >> N, N) {
        cs.clear(); cs.resize(N);
        for (int i = 0; i < N; i++) cin >> cs[i].x >> cs[i].y;

        vector<Point> ips; // Intersection PointS
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                if (i == j) continue;
                if (!cs[i].isIntersect(cs[j])) continue;
                pair<Point, Point> ip = cs[i].intersectionPoint(cs[j]);
                ips.push_back(ip.first);
                ips.push_back(ip.second);
                //ips.push_back(midPoint(ip));
            }
        }

        int maxPoint = 0;
        for (int i = 0; i < ips.size(); i++) {
            maxPoint = max(maxPoint, countContainingPoints(Circle(ips[i].x, ips[i].y, 1), cs));
        }
        cout << maxPoint << endl;
    }
    return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 300

typedef double P_type;
typedef complex<P_type> P;
const P_type P_eps = 1e-8; //整数の時はゼロ

namespace std{
  template<class T> bool operator<(const complex<T> &a, const complex<T> &b){
    return a.real() == b.real() ? a.imag() < b.imag() : a.real() < b.real();
  }
};

/* 円の点包含判定 */
double isContainedCP(P c, double r, P p){
  //return abs(c-p) < r - P_eps; //円周上を含まない
  return abs(c-p) < r + P_eps; //円周上を含む
}

int solve(){
  int n;
  double x[SIZE], y[SIZE];

  scanf("%d", &n);
  if(n == 0) return false;

  if(n == 1){
    puts("1");
    return true;
  }
  
  for(int i=0;i<n;i++){
    scanf("%lf%lf", x+i, y+i);
  }

  int ans = 0;
  
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(i == j) continue;
      P vec = P(x[i]-x[j], y[i]-y[j]);

      if(abs(vec) > 2.0 + P_eps) continue;
      
      P p = P(-vec.imag(), vec.real());
      p = p / abs(p) * sqrt(1 - norm(vec) / 4);
      //debug(p);

      p += vec / 2.0 + P(x[j], y[j]); 

      int counter = 0;
      // debug(abs(p - P(x[i], y[i])));
      
      for(int k=0;k<n;k++){
        counter += isContainedCP(p, 1, P(x[k], y[k]));
      }

      ans = max(ans, counter);
    }
  }

  printf("%d\n", ans);
  return true;
}


int main(){
  while(solve());
  return 0;
}