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++: #define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
int main() {
	iostream::sync_with_stdio(false);
	while (true) {
		int n;
		cin >> n;
		if (n == 0) return 0;
		vector<pair<long double, long double>> inputs;
		REP(i, n) {
			long double a, b;
			cin >> a >> b;
			inputs.push_back(make_pair(a, b));
		}
		int ans = 1;
		REP(i, inputs.size()) {
			for (int q = i + 1; q < inputs.size(); ++q) {
				long double x = inputs[i].first + inputs[q].first;
				long double y = inputs[i].second + inputs[q].second;
				x /= 2.0;
				y /= 2.0;
				long double neko = (x - inputs[i].first) * (x - inputs[i].first) + (y - inputs[i].second) * (y - inputs[i].second);
				if (neko > 1.0+eps) {
					continue;
				}
				neko = sqrt(1.0 - neko);
				long double xe = inputs[i].second - inputs[q].second;
				long double ye = inputs[i].first - inputs[q].first;
				ye *= -1.0;
				long double tani = xe * xe + ye * ye;
				tani = sqrt(tani);
				xe /= tani;
				ye /= tani;
				for (long double j = -1; j <= 1; j += 2.0) {
					long double next_x = x + xe * j * neko;
					long double next_y = y + ye * j * neko;
					int cnt = 0;
					REP(j, inputs.size()) {
						long double dist = (inputs[j].first - next_x) * (inputs[j].first - next_x) + (inputs[j].second - next_y) * (inputs[j].second - next_y);
						if (dist <= 1.0 + eps) {
							cnt++;
						}
					}
					ans = max(ans, cnt);
				}
			}
		}
		cout << ans << endl;
	}
}

C++: #include <bits/stdc++.h>
using namespace std;

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<58;
const long double eps=1e-3;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    while(true){
        int n;
        cin >> n;
        if(n==0) break;
        vector<long double> xs(n),ys(n);
        rep(i,0,n) cin >> xs[i] >> ys[i];

        auto count=[&](const long double x,const long double y){
            int res=0;
            rep(i,0,n) if((xs[i]-x)*(xs[i]-x)+(ys[i]-y)*(ys[i]-y)<=1+eps) ++res;
            return res;
        };

        int ans=0;
        rep(i,0,1001){
            const long double y=10.*i/1000;
            rep(j,0,n){
                const long double tmp=1-(ys[j]-y)*(ys[j]-y);
                if(tmp<0) continue;
                const long double x1=xs[j]-sqrtl(tmp),x2=xs[j]+sqrt(tmp);
                ans=max({ans,count(x1,y),count(x2,y)});
            }
        }
        cout << ans << endl;
    }
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    cout << fixed << setprecision(8);
    solve();
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

double Dis(double x1, double y1, double x2, double y2);
int main(void){
	while(1){
		int n;
		int ans = 1;
		vector< pair<double, double> > p;

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

		for(int i=0; i<n; i++){
			pair<double, double> t;
			cin >> t.first >> t.second;
			p.push_back(t);
		}

		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				//中点
				double mpx = (p[i].first + p[j].first) / 2.0;
				double mpy = (p[i].second + p[j].second) / 2.0;
				//2点間の距離
				double d1 = Dis(p[i].first, p[i].second, p[j].first, p[j].second);
				//p[i]からp[j]へ向かうベクトル
				double v1x = (p[i].first - p[j].first) / d1;
				double v1y = (p[i].second - p[j].second) / d1;
				//中点から円の中心へ向かう単位ベクトル
				double v2x = -v1y;
				double v2y = v1x;
				//中心から円の中心へ向かうベクトルの長さ
				double d2 = sqrt(1.0 - (d1*d1/4.0));

				//円の中心の座標
				double cx = mpx + v2x * d2;
				double cy = mpy + v2y * d2;

				int cnt = 0;
				for(int k=0; k<n; k++){
					if(k == i || k == j || (cx-p[k].first)*(cx-p[k].first) + (cy-p[k].second)*(cy-p[k].second) <= 1.0)	cnt++;
				}
				if(cnt > ans){
					ans = cnt;
				}

				cx = mpx - v2x * d2;
				cy = mpy - v2y * d2;

				cnt = 0;
				for(int k=0; k<n; k++){
					if(Dis(cx, cy, p[k].first, p[k].second) <= 1.0)	cnt++;
				}
				if(cnt > ans){
					ans = cnt;
				}
			}
		}

		cout << ans << endl;


	}
	
	return 0;
}

double Dis(double x1, double y1, double x2, double y2){
	return sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));
}