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 <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef complex<double> P;
const double EPS = 1e-8;

int main() {
  int n;
  while(cin>>n,n) {
    vector<P> v;
    REP(i,n) {
      double x,y;
      cin >> x >> y;
      v.push_back(P(x,y));
    }
    int ans = 0;
    REP(i,n-1) {
      for (int j=i+1;j<n;j++) {
        P m = (v[i]+v[2])*P(0.5,0);
        P a = v[i]-v[j];
        double dis = abs(a);
        if (1-dis*dis/4<0) continue;
        double d = sqrt(1-dis*dis/4);
        int hoge[]={1,-1};
        REP(k,2) {
          P un = (a * P(0, hoge[k])) / dis;
          P o1 = m + un*d;
          int sum = 0;
          REP(l,n) {
            if (norm(v[l]-o1)<1+EPS) sum++;
          }
          ans = max(ans,sum);
        }
      }
    }
    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-9
#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 = 0;
    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){

	  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;
	               /* unit vector(単位べく利ゅ)             *//* T倍に拡大 ９０度回転 */ 
  	  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 <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
#define EPS 1e-10
#define MOD 1000000007
using namespace std;
typedef pair<double,double> P;
typedef pair<int,P> PP;

int n;
int ans;
vector<double> x, y;
vector<PP> v;

void solve(){
	x.clear(); y.clear(); v.clear();
	x.resize(n); y.resize(n);
	ans = 1;
	rep(i,n) cin >> x[i] >> y[i];
	for(int i = 0; i <= 1000; i++) for(int j = 0; j <= 1000; j++){
		double I = i/100.0, J = j/100.0;
		int cnt = 0;
		rep(k,n){
			if((x[k]-I)*(x[k]-I)+(y[k]-J)*(y[k]-J) < 1) cnt++;
		}
		v.push_back(PP(cnt,P(I,J)));
	}
	sort(v.begin(),v.end(), greater<PP>());
	rep(u,10){
		P p = v[u].second;
		for(int i = 0; i <= 100; i++) for(int j = 0; j <= 100; j++){
			double I = p.first-0.005+i/10000.0, J = p.second-0.005+j/10000.0;
			int cnt = 0;
			rep(k,n){
				if((x[k]-I)*(x[k]-I)+(y[k]-J)*(y[k]-J) < 1) cnt++;
			}
			ans = max(ans,cnt);
		}
	}
	cout << ans << endl;
}

int main(){
	while(cin >> n){
		if(n == 0) break;
		solve();
	}
}

C++: #include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

typedef long double R;
typedef complex<R> P;

const R EPS = 1e-10;
const R PI = acos((R)(-1));

R radNorP(R x) {
    return fmod(fmod(x, 2*PI)+2*PI, 2*PI);
}

const int MN = 330;

P p[MN];
typedef pair<R, int> Pi;

bool solve() {
    int n;
    cin >> n;
    if (!n) return false;

    for (int i = 0; i < n; i++) {
        R x, y;
        cin >> x >> y;
        p[i] = P(x, y);
    }

    int res = 0;
    for (int i = 0; i < n; i++) {
        vector<Pi> v;
        for (int j = 0; j < n; j++) {
            if (i == j) continue;
            if (2.0 < abs(p[j]-p[i])) continue;
            R th = acos(abs(p[j]-p[i])/2.0);
            R l = radNorP(arg(p[j]-p[i])-th-EPS);
            R r = radNorP(arg(p[j]-p[i])+th+EPS);
            if (r < l) {
                v.push_back(Pi(l-EPS, 1));
                v.push_back(Pi(2*PI+EPS, -1));
                v.push_back(Pi(0-EPS, 1));
                v.push_back(Pi(r+EPS, -1));
            } else {
                v.push_back(Pi(l-EPS, 1));
                v.push_back(Pi(r+EPS, -1));
            }

        }

        sort(v.begin(), v.end());
        int sm = 1;
        for (Pi p: v) {            
            sm += p.second;
            res = max(res, sm);
        }
    }
    cout << res << endl;
    return true;
}

int main() {
    while (solve()) {}
    return 0;
}