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 <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <numeric>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<((x))<<endl
#define fi first
#define se second

#define INF 2147483600
#define long long long
#define EPS 1e-8

// ???????°???°???????????????
inline double add(double a, double b){
  if(abs(a+b) < EPS*(abs(a) + abs(b))) return 0;
  return a+b;
}

struct Point{
  double x,y;
  Point() {}
  Point(double nx, double ny) : x(nx), y(ny) {}
  inline Point operator + (const Point & p){ return Point(add(x, p.x), add(y, p.y)); }
  inline Point operator - (const Point & p){ return Point(add(x,-p.x), add(y,-p.y)); }
  inline Point operator * (double d){ return Point(x*d, y*d); }
  inline double dot(const Point & p){ return add(x * p.x, y*p.y); }  //??????
  inline double det(const Point & p){ return add(x * p.y, -y*p.x); } //??????
  inline double dist(const Point & p){ return sqrt((x-p.x)*(x-p.x) + (y-p.y)*(y-p.y)); }
  inline bool operator < (const Point & p) const {
    if(x != p.x) return x < p.x;
    else return y < p.y;
  }
  inline bool operator == (const Point & p) const {
    return (add(x, -p.x)==0) && (add(y, -p.y)==0);
  }
  friend ostream& operator<<(ostream& os, const Point& p) {
    os << "[" << p.x << "," << p.y << "]";
    return os;
  }
};

pair<Point, Point> calcCenter(Point &p1, Point &p2){
  if(add(p1.x, -p2.x)==0){
    double y = (p1.y + p2.y)/2;
    double dx = sqrt(1 - (p1.y - y)*(p1.y - y));
    return mp(Point(p1.x+dx, y), Point(p1.x-dx,y));
  }
  // 2???????????´???????????? Ax + By + C = 0 , A != 0
  double A = 2*(p1.x - p2.x);
  double B = 2*(p1.y - p2.y);
  double C = - p1.x*p1.x + p2.x*p2.x - p1.y*p1.y + p2.y*p2.y;
  // x = py+q
  double p = -B/A; double q = -C/A;

  // p1, p2 ??¨????????¢???1?????? ay^2 + 2by + c = 0
  double a = 1 + p*p;
  double b = p*q - p1.x*p - p1.y;
  double c = q*q - 2*p1.x*q + p1.x*p1.x + p1.y*p1.y - 1;

  double rt = sqrt(b*b-a*c);
  double y1 = (-b+rt)/a;
  double y2 = (-b-rt)/a;

  return mp(Point(p*y1+q, y1), Point(p*y2+q, y2));
}

int main(){
  int n;
  while(scanf("%d", &n), n){
    vector<Point> vec;
    rep(i,n){
      double x,y;
      scanf("%lf %lf", &x, &y);
      vec.pb(Point(x,y));
    }

    int res=0;
    rep(i,n) repl(j,i+1,n) if(vec[i].dist(vec[j]) < 2){
      pair<Point, Point> pr = calcCenter(vec[i], vec[j]);
//      cout << pr.fi << pr.se << endl;
      int cnt=0;
      rep(k,n) if(pr.fi.dist(vec[k]) < 1) cnt++;
      res = max(res, cnt);
      cnt=0;
      rep(k,n) if(pr.se.dist(vec[k]) < 1) cnt++;
      res = max(res, cnt);
    }

    printf("%d\n", res);

  }
  return 0;
}

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.00001) counter++;
  }
  return counter;
}

int check(int i, int j) {
  if (square(minas(d[i], d[j])) >= 4.0001) 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);
  }
}