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 <iostream>
#include <deque>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <complex>

#define loop(i,a,b) for(int i=a; i<int(b); i++)
#define rep(i,n) loop(i,0,n)

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef complex<double> vec;

double const pi = acos(-1);
double const eps = 1e-6;

int main(){
    int n;
    while (cin >> n && n){
        vector<vec> v(n);
        rep(i, n){
            double x, y; cin >> x >> y;
            vec p(x, y);
            v[i] = p;
        }

        if (n == 1) {
            puts("1");
            continue;
        }
        int ans = 1;
        rep(i, n)rep(j, i){
            double d = abs(v[i] - v[j]);
            if (d > 2) continue;
            ans = max(ans, 2);
            double h = 1 - d*d / 4;
            vec c1 = polar(h, arg(v[i] - v[j]) + pi / 2) + (v[i] + v[j]) / 2.;
            vec c2 = polar(h, arg(v[i] - v[j]) - pi / 2) + (v[i] + v[j]) / 2.;
            int a1 = 0, a2 = 0;
            rep(k, n){
                if (abs(c1 - v[k]) <= 1 - eps) a1++;
                if (abs(c2 - v[k]) <= 1 - eps) a2++;
            }
            ans = max(ans, a1);
            ans = max(ans, a2);
        }
        cout << ans << endl;
    }
}

C++: #include <iostream>
#include <deque>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <complex>

#define loop(i,a,b) for(int i=a; i<int(b); i++)
#define rep(i,n) loop(i,0,n)

using namespace std;
typedef complex<double> vec;

double const pi = acos(-1);
double const eps = 1e-6;

int main(){
    int n;
    while (cin >> n && n){
        vector<vec> v(n);
        rep(i, n){
            double x, y; cin >> x >> y;
            vec p(x, y);
            v[i] = p;
        }

        if (n == 1) {
            puts("1");
            continue;
        }
        int ans = 1;
        rep(i, n)rep(j, n)if (i != j){
            double d = abs(v[i] - v[j]);
            if (d > 2) continue;
            ans = max(ans, 2);
            double h = sqrt(1 - d*d / 4);
            vec c1 = polar(h, arg(v[i] - v[j]) + pi / 2) + (v[i] + v[j]) / 2.;
            vec c2 = polar(h, arg(v[i] - v[j]) - pi / 2) + (v[i] + v[j]) / 2.;
            int a1 = 0, a2 = 0;
            rep(k, n){
                if (abs(c1 - v[k]) <= 1) a1++;
                if (abs(c2 - v[k]) <= 1) a2++;
            }
            ans = max(ans, a1);
            ans = max(ans, a2);
        }
        cout << ans << endl;
    }
}

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

typedef double Num;
typedef complex<Num> Pt2;

struct Circle2 {
  Pt2 p; Num r;
  Circle2(Pt2 p, Num r) : p(p), r(r) {}
};

const double eps = 1e-10;
const double pi  = 3.14159265358979323846;

Pt2  ortho(Pt2 v)        { return v*Pt2(0,1); }
Pt2  unit (Pt2 v)        { return v/abs(v);   }

vector<Circle2> make_circle(Pt2 a, Pt2 b, Num r) {
	Num d = abs(b-a)/2.0;
	d = sqrt(r*r-d*d); // assert(r*r-d*d >= 0)
	Pt2 p = (b+a)/2.0;
	Pt2 v = unit(ortho(b-a)) * d;

	vector<Circle2> ret;
	ret.push_back(Circle2(p+v,r));
	ret.push_back(Circle2(p-v,r));
	return ret;
}

bool into_circle(Circle2 p, Pt2 a) {
	return abs(a-p.p)*abs(a-p.p) < p.r*p.r+eps;
}

int main()
{
	int N;
	while(cin>>N, N)
	{
		Pt2 ps[300];
		for(int i=0; i<N; i++) {
			Num x,y;
			cin>>x>>y;
			ps[i]=Pt2(x,y);
		}

		int ans=0;
		for(int i=  0; i<N; i++)
		for(int j=i+1; j<N; j++) {
			if(abs(ps[i]-ps[j]) > 2.0) continue;

			vector<Circle2> cs = make_circle(ps[i], ps[j], 1.0);
			for(int k=0; k<2; k++){
				int cnt=0;
				for(int l=0; l<N; l++) {
					if(into_circle(cs[k], ps[l])) cnt++;
				}
				ans=max(ans,cnt);
			}
		}
		cout << ans << endl;
	}
}

C++: #include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REPP(i,j,n) for(int i=(j);i<(int)(n);i++)

using namespace std;
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-5, pi = acos(-1.0);
ld dot(Point a, Point b){return real(conj(a)*b);}
ld cross(Point a, Point b){ return imag(conj(a)*b);}

Point p[310];
int n;

void solve(){
  int result=1;
  REP(i,n){
    REPP(j,i+1,n){
      Point ab=p[j]-p[i];
      if(norm(ab)>4)continue;
      Point c=(p[i]+p[j])/2.L+Point{imag(ab),-real(ab)}*sqrt(1-norm(ab)/4.L)/abs(ab)/2.L;
      Point d=(p[i]+p[j])/2.L+Point{-imag(ab),real(ab)}*sqrt(1-norm(ab)/4.L)/abs(ab)/2.L;
      int cntc=0,cntd=0;
      REP(k,n){
	if(abs(p[k]-c)<=1.0001L)cntc++;
	if(abs(p[k]-d)<=1.0001L)cntd++;
      }
      result=max({result,2,cntc,cntd});
    }
  }
  cout<<result<<endl;
}

int main(){ _;
  ld r,i;
  while(cin>>n,n!=0){
    REP(j,n){
      cin>>r>>i;
      p[j]=Point{r,i};
    }
    solve();
  }
}