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<algorithm>
#include<math.h>

using namespace std;
typedef pair<double, double> P;

int N;
double X[300], Y[300];
P d[300];

P add(P p1, P p2) {
  return P(p1.first + p2.first, p1.second + p2.second);
}

P minas(P p1, P p2) {
  return P(p1.first - p2.first, p1.second - p2.second);
}

P mul(P p, double c) {
  return P(p.first * c, p.second * c);
}

P ave(P p1, P p2) {
  return P((p1.first + p2.first) / 2, (p1.second + p2.second) / 2);
}

void printP(P p) {
  printf("P:(%f, %f)\n", p.first, p.second);
}

double square(P p) {
  return p.first * p.first + p.second * p.second;
}

double size(P p) {
  return sqrt(square(p));
}

int count(P p) {
  // printP(p);
  int counter = 0;
  for (int i = 0; i < N; i++) {
    if (square(minas(p, d[i])) <= 1.0001) counter++;
  }
  // printf("%d\n",counter);
  return counter;
}

int check(int i, int j) {
  if (square(minas(d[i], d[j])) > 4.0) return 0;
  int ans = 0;
  P average = ave(d[i], d[j]);
  P dir = mul(minas(d[i], d[j]), 0.5);
  // printP(average);
  double s = sqrt(1.0 - square(dir));
  // printf("!!!!!!%f\n",s);
  P dir1 = P((Y[i] - Y[j]), - (X[i] - X[j]));
  //printf("!!!!!!%f\n",size(dir1));
  double r = s / size(dir1);
  P d1 = add(average, mul(dir1, r));
  P d2 = add(average, mul(dir1, -r));
  return max(count(d1), count(d2));
}

int main() {
  while (1) {
    scanf("%d", &N);
    if (N == 0) break;
    for (int i = 0; i < N; i++) scanf("%lf%lf", &X[i], &Y[i]), d[i] = P(X[i], Y[i]);
    int ans = 0;
    for (int i = 0; i < N; i++)
      for (int j = 0; j < i; j++)
        ans = max(ans, check(i, j));
    printf("%d\n", ans);
  }
}

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 double eps=1e-9;
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,801){
            const long double y=10.*i/800;
            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 <iostream>
#include <complex>
#include <cmath>
#include <algorithm>
using namespace std;

#define EPS 1e-8
typedef complex<double> P;

P center(P a, P b){
  P m  = (a+b) / 2.0;    // p[i]Æp[j]Ì_
  P n = (a-b) * P(0,1);  // @üxNg
  n = n / abs(n);
  
  double x = abs( a-b )/2.0;
  return m + n * sqrt( 1.0-x*x );     // ~ÌS
}

int main(){
  int n;
  P p[301];

  while( cin>>n && n ){
    for( int i=0;i<n;i++ )
      cin >> p[i].real() >> p[i].imag();

    int ans=1;
    for( int i=0;i<n;i++ ){
      for( int j=0;j<n;j++ ){
	if( i==j ) 	  continue;
	if( abs( p[i]-p[j] )+EPS > 2.0 ) continue;
	P c = center( p[i],p[j] );

	int num=0;
	for( int k=0;k<n;k++ )
	  if( abs( c-p[k] ) < 1.0 + EPS  )
	    num++;
	ans = max( ans,num );
      }
    }
    cout << ans << endl;
  }

  return 0;
}

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

#define P complex<double>
#define EPS 1.0e-4

int main(){
  int n;
  P p[301];
  int ans, num;

  while( cin>>n && n ){
    for( int i=0;i<n;i++ )
      cin >> p[i].real() >> p[i].imag();

    ans=0;
    for( int i=0;i<n;i++ ){
      for( int j=0;j<n;j++ ){
	if( i==j )
	  continue;
	if( abs( p[i]-p[j] )+EPS > 2.0 )
	  continue;

	P m  = (p[i]+p[j]) / 2.0; // p[i]Æp[j]Ì_
	P nn = (p[i]-p[j]) * P(0,1);       // @üxNg
	nn = nn / abs(nn);

	double x = abs( p[i]-p[j] )/2;
	x = sqrt( 1-x*x );
	P c = m + x * nn;        // ~ÌS

	num=0;
	for( int k=0;k<n;k++ )
	  if( abs( c-p[k] ) < 1.0 + EPS  )
	    num++;
	ans = max( ans,num );
      }
    }
    cout << ans << endl;
  }

  return 0;
}