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<complex>
#include<iostream>
#include<algorithm>
#include<cmath>

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

int main(){
	
	A:;
	int n;
	cin>>n;
	if(n==0)return 0;
	
	point p[333];
	
	rep(i,n){
		double a,b;
		cin>>a>>b;
		p[i] = point(a,b);
	}
	double eps = 1E-11;
	int ans = 0;
	rep(i,n){
		reps(j,i+1,n){
			point d = (p[j]-p[i])/point(2,0);
			double dlen = abs(d);
			if(dlen>1)continue;
			
			//cout<<p[j]<<" "<<p[i]<<" "<<d<<" "<<dlen<<endl;
			
			point center = p[i]+d;
			point e1 = d/point(dlen,0)*point(0,1)*point(sqrt(1-dlen*dlen),0);
			point e2 = d/point(dlen,0)*point(0,-1)*point(sqrt(1-dlen*dlen),0);
			
			point t1 = center+e1;
			point t2 = center+e2;
			
			//cout<<t1<<" "<<t2<<endl;
			
			int count1 = 0;
			int count2 = 0;
			rep(k,n){
				if(abs(t1-p[k])<1+eps)count1++;
				if(abs(t2-p[k])<1+eps)count2++;
			}
			
			ans = max(ans,count1);
			ans = max(ans,count2);
		}
	}
	
	printf("%d\n",ans);
	
	goto A;
}

/*
3
0 1
1 0
1 1

*/

C++: #include <stdio.h>
#include <algorithm>
#include <iostream>
#include <stack>
#include <vector>
#include <math.h>
#include <queue>

using namespace std;

struct Point{
	double x,y;
};

void func(int N){

	Point point[N];
	double x_min = 100,y_min = 100,x_max = -1,y_max = -1;

	for(int i = 0; i < N; i++){
		scanf("%lf %lf",&point[i].x,&point[i].y);
		x_min = min(point[i].x,x_min);
		y_min = min(point[i].y,y_min);
		x_max = max(point[i].x,x_max);
		y_max = max(point[i].y,y_max);
	}

	if(x_min > 1)x_min -= 1;
	if(y_min > 1)y_min -= 1;
	if(x_max < 9)x_max += 1;
	if(y_max < 9)y_max += 1;

	int count,max_count = 0;

	for(double y = y_min; y <= y_max; y += 0.1){
		for(double x = x_min; x <= x_max; x += 0.1){
			count = 0;
			for(int i = 0; i < N; i++){
				if(sqrt((x-point[i].x)*(x-point[i].x)+(y-point[i].y)*(y-point[i].y)) <= 1.0)count++;
			}
			max_count = max(max_count,count);
		}
	}

	printf("%d\n",max_count);
}


int main(){

	int N;

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func(N);
	}


    return 0;
}

C++: #include <stdio.h>
#include <algorithm>
#include <iostream>
#include <stack>
#include <vector>
#include <math.h>
#include <queue>

using namespace std;

struct Point{
    double x,y;
};

void func(int N){

    Point point[N];
    double x_min = 100,y_min = 100,x_max = -1,y_max = -1;

    for(int i = 0; i < N; i++){
        scanf("%lf %lf",&point[i].x,&point[i].y);
        x_min = min(point[i].x,x_min);
        y_min = min(point[i].y,y_min);
        x_max = max(point[i].x,x_max);
        y_max = max(point[i].y,y_max);
    }

    if(x_min > 1)x_min -= 0.05;
    if(y_min > 1)y_min -= 0.05;
    if(x_max < 9)x_max += 0.05;
    if(y_max < 9)y_max += 0.05;

    int count,max_count = 0;

    for(double y = y_min; y <= y_max; y += 0.0101){
        for(double x = x_min; x <= x_max; x += 0.0101){
            count = 0;
            for(int i = 0; i < N; i++){
                if(sqrt((x-point[i].x)*(x-point[i].x)+(y-point[i].y)*(y-point[i].y)) <= 1.0)count++;
            }
            max_count = max(max_count,count);
        }
    }

    printf("%d\n",max_count);
}


int main(){

    int N;

    while(true){
        scanf("%d",&N);
        if(N == 0)break;

        func(N);
    }


    return 0;
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
const double EPS = 1e-8;
typedef pair<double,double> P;

inline double dist(P p,P q){
  return ( (p.first-q.first)*(p.first-q.first) + (p.second-q.second)*(p.second-q.second));
}

int main(){
  int N;
  double sign[2] = {+1, -1};
  P p[301];
  while(cin>>N,N){
    REP(i,N)cin>>p[i].first>>p[i].second;
    int ans = 1;
    REP(i,N){
      FOR(j,i+1,N){
        double dst = dist(p[i],p[j]);
        if(dst > 4.0) continue;
        P v((p[j].first-p[i].first)/dst, (p[j].second-p[i].second)/dst);
        P m((p[j].first+p[i].first)/2.0, (p[j].second+p[i].second)/2.0);
        double lth = sqrt(1.0-dst*dst/4.0);
        REP(k,2){
          double cx = m.first + sign[k] * v.first * lth;
          double cy = m.second - sign[k] * v.second * lth;
          P center(cx,cy);
          int count = 0;
          REP(l,N){
            if(l == i || l == j || dist(center,p[l]) < 1){
              count++;
            }
            if(N-l-1 + count < ans)break;
          }
          ans = max(ans, count);
        }
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define mp(a,b) make_pair((a),(b))
#define eq ==

typedef long long ll;
typedef complex<double> point;
typedef pair<int,int> pii;

// →↑←↓
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};


const double EPS = 1e-9;

int main(){
    while(true){
        int N;
        cin >> N;
        if(N == 0) break;
        vector<point> P(N);
        for(int i=0;i<N;i++){
            cin >> P[i].real() >> P[i].imag();
        }

        int ret = 1;

        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                if(i == j) continue;
                point p1 = P[i];
                point p2 = P[j];

                if(abs(p1-p2) <= 2.0+EPS){
                    point d = p1 - p2;
                    point m = (p1+p2)/(point(2,0));

                    point nor = d * point(0,1);
                    nor /= abs(nor);
                    nor *= point(sqrt(1-(abs(d)/2)*(abs(d)/2)),0);

                    point p = m + nor;
                    int cnt = 0;
                    for(int k=0;k<N;k++){
                        if(abs(P[k]-p) <= 1+EPS) cnt++;
                    }
                    ret = max(ret,cnt);
                }
            }
        }
        cout << ret << endl;
    }
    return 0;
}