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)
	}
}

Python: #import matplotlib.pyplot as plt
#import matplotlib.patches as patches
from itertools import combinations
printed_later = []
while True:
    n = int(input())
    if(n == 0):
        break
    dots = []
    for _ in range(n):
        x, y = map(float, input().split())
        dots.append(complex(x, y))
    inside_max = 1
    for p, q in combinations(dots, 2):
        abs_p_q = abs(p - q)
        if abs_p_q > 2:
            continue
        for pl_mn_j in [1j, -1j]:
            center = (p + q) / 2 + (p - q) * pl_mn_j / abs_p_q * (1 - (abs_p_q / 2) ** 2) ** 0.5
            dots_inside_num = 0
            for dot in dots:
                #plt.gca().add_patch(patches.Circle(xy=(center.real, center.imag), radius=1, fill=False, ec='r'))  # debug
                if abs(dot - center) < 1 or dot == p or dot == q:
                    dots_inside_num += 1
            if dots_inside_num > inside_max:
                inside_max = dots_inside_num
    printed_later.append(inside_max)
    #plt.scatter([z.real for z in dots], [z.imag for z in dots])
    #plt.show()
for line in printed_later:
    print(line)

Python: #!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

def func():
    while True:
        N = input()
        if N == 0:
            break
        R = range(N)
        pos = []
        for loop in R:
            S = map(float, raw_input().split())
            pos.append(S)
        ans = 0
        for i in R:
            for j in R:
                v = [pos[j][0] - pos[i][0], pos[j][1] - pos[i][1]]
                norm = math.sqrt(v[0] * v[0] + v[1] * v[1])
                if norm > 2 or norm == 0:
                    continue
                vn = [v[0] / norm, v[1] / norm]
                norm /= 2
                norm2 = math.sqrt(1 - norm * norm)
                v90 = [-vn[1], vn[0]]
                cent = [pos[i][0] + v[0] / 2 + v90[0] * norm2, 
                pos[i][1] + v[1] / 2 + v90[1] * norm2]
                S = 2
                for k in R:
                    if i == k or j == k:
                        continue
                    x = cent[0] - pos[k][0]
                    y = cent[1] - pos[k][1]
                    if x * x + y * y <= 1:
                        S += 1
                ans = max(S, ans)
        print(max(1, ans))

if __name__ == '__main__':
    func()

Python: def cent(p1,p2):
    if abs(p1-p2) >= 2:
        return None,None
    else:
        q = (p1+p2)/2
        r = (p1-p2)/2
        n = abs(r)
        t = r * 1j * ((1-n**2)**0.5/n)
        return(q + t, q - t)

while(True):
    ans = 1
    n = int(input())
    if n == 0:
        quit()
    elif n == 1:
        print(1)
    ps = []
    for _ in range(n):
        x,y = map(float,input().split())
        ps.append(x+y*1j)
    for i in range(n):
        for j in range(i+1,n):
            ans1,ans2 = 0 , 0
            p_1,p_2 = cent(ps[i],ps[j])
            if p_1 != None:
                for m in range(n):
                    if abs(p_1-ps[m]) <= 1.001:
                        ans1 += 1
                    if abs(p_2-ps[m]) <= 1.001:
                        ans2 += 1
                ans = max(ans,ans1,ans2)
    print(ans)

Python: def cent(p1,p2):
    if abs(p1-p2) >= 2:
        return None,None
    else:
        q = (p1+p2)/2
        r = (p1-p2)
        n = abs(p1-p2)
        t = r * 1j * ((1-r*2)**0.5/r)
        return(q + t, q - t)

while(True):
    ans = 0
    n = int(input())
    ps = []
    for _ in range(n):
        x,y = map(int,input().split())
        ps.append(x+yj)
    for i in range(n):
        for j in range(i+1,n):
            ans1,ans2 = 0 , 0
            p1,p2 = cent(ps[i],ps[j])
            if p1 != None:
                for m in range(n):
                    if abs(p1-ps[m]) <= 1:
                        ans1 += 1
                    if abs(p2-ps[m]) <= 1:
                        ans2 += 1
                ans = max(ans,ans1,ans2)
    print(ans)

Python: import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def cc(x1, y1, x2, y2):
    xd = x2 - x1
    yd = y2 - y1
    xc = (x1 + x2) / 2
    yc = (y1 + y2) / 2
    k = pow(1.0 / (xd**2 + yd**2) - 0.25, 0.5)
    xd *= k
    yd *= k
    return [[xc - yd, yc + xd], [xc + yd, yc - xd]]

def main():
    rr = []
    eps1 = 1 + eps

    def f(n):
        a = sorted([LF() for _ in range(n)])
        r = 1
        for i in range(n):
            ax, ay = a[i]
            for j in range(i+1,n):
                bx, by = a[j]
                if bx - ax > 2:
                    break
                if pow(ax-bx, 2) + pow(ay-by, 2) > 4:
                    continue
                for x, y in cc(ax, ay, bx, by):
                    t = 0
                    for k in range(n):
                        if x - a[k][0] > 1:
                            continue
                        if a[k][0] - x > 1:
                            break
                        if pow(x-a[k][0], 2) + pow(y-a[k][1], 2) < eps1:
                            t += 1
                    if r < t:
                        r = t

        return r

    while 1:
        n = I()
        if n == 0:
            break
        rr.append(f(n))

    return '\n'.join(map(str,rr))


print(main())

Python: def cent(p1,p2):
    if abs(p1-p2) >= 2:
        return None,None
    else:
        q = (p1+p2)/2
        r = (p1-p2)/2
        n = abs(r)
        t = r * 1j * ((1-n**2)**0.5/n)
        return(q + t, q - t)

while(True):
    ans = 0
    n = int(input())
    if n == 0:
        quit()
    ps = []
    for _ in range(n):
        x,y = map(float,input().split())
        ps.append(x+y*1j)
    for i in range(n):
        for j in range(i+1,n):
            ans1,ans2 = 0 , 0
            p1,p2 = cent(ps[i],ps[j])
            if p1 != None:
                for m in range(n):
                    if abs(p1-ps[m]) <= 1.001:
                        ans1 += 1
                    if abs(p2-ps[m]) <= 1.001:
                        ans2 += 1
                ans = max(ans,ans1,ans2)
    print(ans)