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 <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000000
#define sz(x) ((int)(x).size())
#define sq(x) ((x)*(x))
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
double add(double a,double b){
	if(abs(a+b)<eps*(abs(a)+abs(b)))return 0;
	return a+b;
}
struct P{
	double x,y;
	P() {}
	P(double x,double y) : x(x),y(y){}
	P operator + (P p){
		return P(add(x,p.x),add(y,p.y));
	}
	P operator - (P p){
		return P(add(x,-p.x),add(y,-p.y));
	}
	P operator * (double d){
		return P(x*d,y*d);
	}
	double dot(P p){
		return add(x*p.x,y*p.y);
	}
	double det(P p){
		return add(x*p.y,-y*p.x);
	}
	double norm(){
		return sqrt(x*x+y*y);
	}
	double dist2(P p){
		return sq(x-p.x)+sq(y-p.y);
	}
	P vert(){
		return P(y,-x);
	}
	void dump(){
		printf("%.12f %.12f\n",x,y);
		return;
	}
};
int N;
P pts[305];
int solve(){
	scanf("%d",&N);
	if(N==0)return 1;
	for(int i=0;i<N;i++){
		scanf("%lf %lf",&pts[i].x,&pts[i].y);
	}
	int ans = 0;
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			P m = (pts[i]+pts[j])*0.5;
			P a = (pts[i]-pts[j]);
			double na = a.norm();
			if(na>2.0)continue;
			a = (a.vert())*(1/na);
			a = a*(sqrt(1-sq(na/2.0)));
			P b = m+a;
			P c = m-a;
			/*cout << i << ' ' << j << endl;
			m.dump();
			a.dump();
			b.dump();
			c.dump();
			cout << endl;*/
			int cnt = 0;
			for(int k=0;k<N;k++){
				//printf("%d:%.12f\n",k,pts[k].dist2(b));
				if(pts[k].dist2(b)<=1.0+eps)cnt++;
			}
			ans = max(ans,cnt);
			cnt = 0;
			for(int k=0;k<N;k++){
				//printf("%d:%.12f\n",k,pts[k].dist2(c));
				if(pts[k].dist2(c)<=1.0+eps)cnt++;
			}
			ans = max(ans,cnt);
		}
	}
	printf("%d\n",ans);
	return 0;
}
int main(){
	while(!solve()){}
	return 0;
}

C++: #include<bits/stdc++.h>

using namespace std;


#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

typedef complex<double> P;

vector<P> point;

const double EPS = 0.0000000001;


void init(){
  point.clear();
}


bool input(){
  int n;
  cin>>n;
  if(n==0)return false;

  rep(i,n){
    double a ,b;
    cin>>a>>b;
    point.push_back(P(a,b));
  }
  return true;
}

vector<P> make_cand(){
  vector<P> ret;
  rep(i,point.size()){
    reps(j,i+1,point.size()){
      P dist = point[j]-point[i];
      double d = abs(dist)/2;

      if(d>1)continue;
      double h = sqrt(1-d*d);
      P e = dist/(d*2);

      P e1 = e*P(0,1);
      P e2 = e*P(0,-1);

      P c1 = point[i]+e*d+h*e1;
      P c2 = point[i]+e*d+h*e2;

      //cout<<"d="<<d<<" h="<<h<<endl;
      //cout<<point[i]<<" "<<point[j]<<" "<<c1<<" "<<c2<<endl;
      ret.push_back(c1);
      ret.push_back(c2);
    }
  }
  return ret;
}

int count_in(P p){
  int sum = 0;
  rep(i,point.size()){
    P d  = point[i]-p;
    if(abs(d)<=1+EPS)sum++;
  }
  return sum;
}
int solve(){
  vector<P> cand = make_cand();
  int ans = 0;
  rep(i,cand.size()){
    ans = max(ans, count_in(cand[i]));
  }
  return ans;
}

int main(){
  while(init(),input()){
    printf("%d\n",solve());
  }
}

C++: #include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vec> mat;
double dist(double ax,double ay,double bx,double by){
    return sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by));
}
int n;
double X[300],Y[300];
int search(double x,double y){
    int m=0;
    rep(i,n) if(dist(x,y,X[i],Y[i])<1.0001) m++;
    return m;
}
int main(){
    while(true){
        int ans=1;
        cin>>n;
        if(n==0) break;
        rep(i,n) cin>>X[i]>>Y[i];
        rep(i,n)for(int j=i+1;j<n;j++){
            if(dist(X[i],Y[i],X[j],Y[j])>2) continue;
            double mx=(X[i]+X[j])/2,my=(Y[i]+Y[j])/2,k=(Y[j]-Y[i])/(X[j]-X[i]);
            double vx=1/dist(0,0,1,-1/k),vy=(-1/k)/dist(0,0,1,-1/k);
            double a=sqrt(1-pow(dist(mx,my,X[i],Y[i]),2));
            ans=max(ans,search(mx+a*vx,my+a*vy));
            ans=max(ans,search(mx-a*vx,my-a*vy));
        }
        cout<<ans<<"\n";
    }
}