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-5;

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;
        }
        if (n == 2){
            if (abs(v[0] - v[1]) < 2 - eps) {
                puts("2"); 
            }
            else{
                puts("1"); 
            }
            continue;
        }

        int ans = 0;
        rep(i, n)rep(j, i){
            double d = abs(v[i] - v[j]);
            if (d - eps > 2) continue;
            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<complex>
#include<cmath>
#include<algorithm>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define EPS 1e-10
#define PI 3.141592653589793238
// sqrt重い
using namespace std;
typedef pair<double,double> P;

void display(complex<double> a,complex<double> b){
 cout << "(" << a.real() <<"," << a.imag() <<")"<< " " <<"("<< b.real() <<"," <<b.imag() << ")" << endl;
}

int main(){
  int n,ans;
  double xin,yin,X;
  complex<double> m;
  while(cin >> n && n){
    ans = 1;
    complex<double> point[n];
    for(int i=0;i<n;i++){
      cin >> xin >> yin;
      point[i] = complex<double>(xin,yin);
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	if(i == j)continue;
	complex<double> Rr = point[i]-point[j];
	if(abs(Rr) <= 2+EPS){

	  complex<double> UKPC,U,P1,P2;
	  UKPC = (point[i]+point[j])*0.5;       
	  double T = sqrt(1-norm(point[i]-point[j])*0.25);

	  UKPC = (point[i]+point[j])*0.5;
  	  P1 = UKPC + (point[i]-point[j])/abs(point[i]-point[j])*polar(T,PI/2.0);
	  P2 = UKPC + (point[i]-point[j])/abs(point[i]-point[j])*polar(T,-PI/2.0);
	  //cout << "P1 = " << P1 << ", P2 = " << P2 << endl;
	  int cnt=0;
	  complex<double> CalcP;
	  double Calc;
	  for(int k=0;k<n;k++){
	    Calc = abs(P1-point[k]);
	    if(Calc < 1.0+EPS){
	      cnt++;
	    }
	  }	

	  ans = max(ans,cnt);
	  cnt = 0;
	  for(int k=0;k<n;k++){
	    Calc = abs(P2-point[k]);
	    if(fabs(Calc) < 1.0+EPS){
	      cnt++;
	    }
	  }	
  
	  ans = max(ans,cnt);
	  

	}

      }
    }

    cout << ans << endl;

  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<limits>
#include<iomanip>
using namespace std;
typedef unsigned long long int ull;
typedef vector<char> vc;
typedef vector<vc> vvc;



typedef pair<double,double> Point;
#define F first
#define S second
#define MK make_pair
#define equal abs(a-b)<=1e-8

Point pls(Point a,Point b){
    return MK(a.F+b.F,a.S+b.S);
}

Point mns(Point a,Point b){
    return MK(a.F-b.F,a.S-b.S);
}

Point T(Point t){
    return MK(t.S,-1.0*t.F);
}

double abs(Point a){
    return sqrt(a.F*a.F+a.S*a.S);
}

Point mid(Point a,Point b){
    return MK(a.F/2+b.F/2,a.S/2+b.S/2);
}

bool in(Point c,Point t){
    if(abs(mns(t,c))<=1){return true;}
    return false;
}


int main(){
    while(1){
        int n;
        cin>>n;
        if(n==0){break;}
        vector<Point> vp;
        int mx=0;
        for(int i=0;i<n;i++){
            double a,b;
            cin>>a>>b;
            vp.push_back(MK(a,b));
        }
        sort(vp.begin(),vp.end());
        for(int i=0;i<vp.size();i++){
            for(int t=i+1;t<vp.size() && vp[t].F-vp[i].F<=2;t++){
                if(abs(mns(vp[t],vp[i]))>2){continue;}
                Point m=mid(vp[i],vp[t]);
                Point l=mns(vp[t],vp[i]);
                Point lt=T(l);
                double h=sqrt(1-abs(l)*abs(l)/4.0);
                lt.F=h*lt.F/abs(l);
                lt.S=h*lt.S/abs(l);
                Point c=pls(m,lt);
                int count=2;
                for(int k=0;k<vp.size();k++){
                    if(k!=i && k!=t && in(c,vp[k])){count++;}
                }
                mx=max(mx,count);
                c=mns(m,lt);
                count=2;
                for(int k=0;k<vp.size();k++){
                    if(k!=i && k!=t && in(c,vp[k])){count++;}
                }
                mx=max(mx,count);
            }
        }
        cout<<mx<<endl;
    }
    return 0;
}