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 <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <complex>

 
using namespace std;
 
#define INF 1000000000
#define EPS 1e-9
#define PI acos(-1)
 
typedef long long ll;
typedef complex<double> vec;

#define MAX_N 300
int N;
double x[MAX_N], y[MAX_N];
vector<int> ans_list;

int par[MAX_N];

int main(){

  while(true){
    cin >> N;
    if(N == 0)
      break;
    for(int i = 0; i < N; i++){
      cin >> x[i] >> y[i];
    }

    int ans = 0;

    for(int i = 0; i < N; i++){
      for(int j = i+1; j < N; j++){
	if(sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j])) > 2.0001)
	  continue;
	int tmp = 0;
	vec p1 = vec(x[i], y[i]), p2 = vec(x[j], y[j]);
	vec mid = (p2-p1);
	mid /= 2;
	vec r1 = (mid * vec(0, 1)) / abs(mid);
	vec r2 = (mid * vec(0, -1)) / abs(mid);

	vec R = p1 + mid + r1*sqrt((1-abs(mid)*abs(mid)));
	double rx = R.real();
	double ry = R.imag();
	tmp = 2;
	for(int k = 0; k < N; k++){
	  if(k == i || k == j)
	    continue;
	  if((rx - x[k])*(rx-x[k]) + (ry - y[k])*(ry - y[k]) < 1)
	    tmp++;
	}
	ans = max(ans, tmp);
	R = p1 + mid + r2*sqrt((1-abs(mid)*abs(mid)));
	rx = R.real();
	ry = R.imag();
	tmp = 0;
	for(int k = 0; k < N; k++){
	  if(k == i || k == j)
	    continue;
	  if((rx - x[k])*(rx-x[k]) + (ry - y[k])*(ry - y[k]) < 1)
	    tmp++;
	}
	ans = max(ans, tmp);
      }
    }

    if(ans == 0 && N >= 1)
      ans_list.push_back(1);
    else
      ans_list.push_back(ans);
    
  }
  
  for(int i = 0; i < ans_list.size(); i++){
    cout << ans_list[i] << endl;
  }

  return 0;

}