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 <cmath>
#include <iostream>
#include <vector>
#include <algorithm>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const long double EPS = 10e-6;

class Point{
    public: 
    long double x,y;
    Point(long double x = 0.0, long double y = 0.0): x(x), y(y) {}
    Point operator + (Point p) const {
        return Point(x+p.x, y+p.y);
    }
    Point operator - (Point p) const {
        return Point(x-p.x, y-p.y);
    }
    Point operator * (long double a) const {
        return Point(x*a, y*a);
    }
    Point operator / (long double a) const {
        return Point(x/a, y/a);
    }
    long double norm() const {
        return x*x + y*y;
    }
    long double dot(Point p) const {
        return x*p.x + y*p.y;
    }
};

Point calc_center(Point p, Point mid, Point midv){
    long double norm = mid.norm(), vnorm = midv.norm();
    midv = midv * sqrt((1.0 - norm)/vnorm);
    return p+mid+midv;
}

int count(vector<Point> points, Point center){
    int tmp = 0;
    for(Point p: points){
        Point v = p-center;
        if(v.norm() <= 1.0 + EPS) tmp++;
    }
    return tmp;
}

int main() {
    int n;
    while(scanf("%d", &n) && n){
        vector<Point> points(n);
        rep(n) scanf("%Lf %Lf", &points[i].x, &points[i].y);

        int ans = 1;
        Point mid, midv, center;
        rep(n){
            repp(j, n){
                if(j == i) continue;
                mid = (points[j] - points[i]);
                mid = mid * 0.5;
                midv = Point(mid.y, -mid.x);
                center = calc_center(points[i], mid, midv);
                ans = max(count(points, center), ans);
                /*
                midv = midv * (-1);
                center = calc_center(points[i], mid, midv);
                ans = max(count(points, center), ans);
                */
            }
        }
        printf("%d\n", ans);
        // debug(ans);
    }
}

C++: // http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1132&lang=jp
// 解説AC（http://www.deqnotes.net/acmicpc/1981/）
// ICPC:国内予選2004D
// Circle and Points


#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;
using pdd = pair<double, double>;

double my_dist(pdd a, pdd b){
  return (a.first-b.first)*(a.first-b.first)+(a.second-b.second)*(a.second-b.second);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int n;
  while(cin >> n, n){
    vector<pdd> points(n);
    for(pdd &i: points) cin >> i.first >> i.second;
    int ans = 0;
    for(int i = 0; i < n; i++){
      for(int j = i+1; j < n; j++){
        double mid_dist = my_dist(points[i], points[j]);
        if(mid_dist > 4.0) continue;
        int cnt = 0; double x, y;
        pdd mid = {(points[i].first+points[j].first)/2.0, (points[i].second+points[j].second)/2.0};
        double alpha, beta, a, b, c;
        alpha = (points[i].second - points[j].second) / (points[j].first - points[i].first);
        beta = mid.first - alpha * mid.second;
        a = alpha * alpha + 1.0;
        b = 2.0 * (alpha * beta - alpha * points[i].first - points[i].second);
        c = (beta - points[i].first) * (beta - points[i].first) + points[i].second*points[i].second - 1.0;
        y = (-b + sqrt(b*b - 4 * a * c)) / (2.0 * a);
        x = alpha * y + beta;
        for(int k = 0; k < n; k++){
          if(my_dist({x, y}, points[k]) <= 1.0001) cnt++;
        }
        ans = max(ans, cnt);
        cnt = 0;
        // x = mid.first - sqrt(c_m_dist/(1.0 + alpha * alpha));
        // y = mid.second - alpha * sqrt(c_m_dist / (1.0 + alpha * alpha));
        y = (-b - sqrt(b*b - 4 * a * c)) / (2.0 * a);
        x = alpha * y + beta;
        for(int k = 0; k < n; k++){
          if(my_dist({x, y}, points[k]) <= 1.0001) cnt++;
        }
        ans = max(ans, cnt);
      }
    }
    cout << max(1, ans) << endl;
  }
  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}