Buggy python submission (verdict: Time Limit Exceeded):
while 1:
	n = input()
	if n == 0: break
	xy = [map(int,raw_input().split()) for i in range(n)]
	ans = 0
	for i in range(n):
		x1,y1 = xy[i]
		for j in range(n-1,i,-1):
			x2,y2 = xy[j]
			dx,dy = x2-x1,y2-y1
			if [x1-dy,y1-dx] in xy and [x2+dy,y2-dx] in xy:
				ans = max(ans,dx**2+dy**2)
			if [x1-dy,y1+dx] in xy and [x2-dy,y2+dx] in xy:
				ans = max(ans,dx**2+dy**2)
	print ans

Fixed submission:
while 1:
	n = input()
	if n == 0: break
	xy = [map(int,raw_input().split()) for i in range(n)]
	S = set(map(tuple,xy))
	ans = 0
	for i in range(n-1):
		x1,y1 = xy[i]
		for j in range(i+1,n):
			x2,y2 = xy[j]
			a = (x2-y2+y1,y2+x2-x1)
			b = (x1-y2+y1,y1+x2-x1)
			if a in S and b in S:
				ans = max(ans,(x1-x2)**2 + (y1-y2)**2)
	print ans

Buggy python submission (verdict: Time Limit Exceeded):
while 1:
	n = input()
	if n == 0: break
	xy = sorted([map(int,raw_input().split()) for i in range(n)])
	x,y = xy[0]
	xy = sorted(xy, key = lambda XY:(XY[0]-x)**2 + (XY[1]-y)**2)
	ans = 0
	for i in range(n):
		x1,y1 = xy[i]
		for j in range(n-3,i,-1):
			x2,y2 = xy[j]
			dx,dy = x2-x1,y2-y1
			if [x1-dy,y1-dx] in xy[j+1:] and [x2+dy,y2-dx] in xy[j+1:]:
				ans = dx**2+dy**2
			if [x1-dy,y1+dx] in xy[j+1:] and [x2-dy,y2+dx] in xy[j+1:]:
				ans = dx**2+dy**2
			if ans: break
		if ans: break
	print ans

Fixed submission:
while 1:
	n = input()
	if n == 0: break
	xy = [map(int,raw_input().split()) for i in range(n)]
	S = set(map(tuple,xy))
	ans = 0
	for i in range(n-1):
		x1,y1 = xy[i]
		for j in range(i+1,n):
			x2,y2 = xy[j]
			a = (x2-y2+y1,y2+x2-x1)
			b = (x1-y2+y1,y1+x2-x1)
			if a in S and b in S:
				ans = max(ans,(x1-x2)**2 + (y1-y2)**2)
	print ans

Buggy python submission (verdict: Time Limit Exceeded):
while 1:
	n = input()
	if n == 0: break
	xy = sorted([map(int,raw_input().split()) for i in range(n)])
	x,y = xy[0]
	xy = sorted(xy, key = lambda XY:(XY[0]-x)**2 + (XY[1]-y)**2)
	ans = 0
	for i in range(n):
		x1,y1 = xy[i]
		for j in range(n-3,i,-1):
			x2,y2 = xy[j]
			dx,dy = x2-x1,y2-y1
			if [x1-dy,y1-dx] in xy[j+1:j+501] and [x2+dy,y2-dx] in xy[j+1:j+501]:
				ans = dx**2+dy**2
			if [x1-dy,y1+dx] in xy[j+1:j+501] and [x2-dy,y2+dx] in xy[j+1:j+501]:
				ans = dx**2+dy**2
			if ans: break
		if ans: break
	print ans

Fixed submission:
while 1:
	n = input()
	if n == 0: break
	xy = [map(int,raw_input().split()) for i in range(n)]
	S = set(map(tuple,xy))
	ans = 0
	for i in range(n-1):
		x1,y1 = xy[i]
		for j in range(i+1,n):
			x2,y2 = xy[j]
			a = (x2-y2+y1,y2+x2-x1)
			b = (x1-y2+y1,y1+x2-x1)
			if a in S and b in S:
				ans = max(ans,(x1-x2)**2 + (y1-y2)**2)
	print ans

Buggy python submission (verdict: Time Limit Exceeded):
p = 100
while 1:
	n = input()
	if n == 0: break
	xy = sorted([map(int,raw_input().split()) for i in range(n)])
	x,y = xy[0]
	xy = sorted(xy, key = lambda XY:(XY[0]-x)**2 + (XY[1]-y)**2)
	ans = 0
	for i in range(n-4):
		x1,y1 = xy[i]
		for j in range(n-3,i,-1):
			x2,y2 = xy[j]
			dx,dy = x2-x1,y2-y1
			if [x1-dy,y1-dx] in xy[j+1:j+p] and [x2+dy,y2-dx] in xy[j+1:j+p]:
				ans = dx**2+dy**2
			if [x1-dy,y1+dx] in xy[j+1:j+p] and [x2-dy,y2+dx] in xy[j+1:j+p]:
				ans = dx**2+dy**2
			if ans: break
		if ans: break
	print ans

Fixed submission:
while 1:
	n = input()
	if n == 0: break
	xy = [map(int,raw_input().split()) for i in range(n)]
	S = set(map(tuple,xy))
	ans = 0
	for i in range(n-1):
		x1,y1 = xy[i]
		for j in range(i+1,n):
			x2,y2 = xy[j]
			a = (x2-y2+y1,y2+x2-x1)
			b = (x1-y2+y1,y1+x2-x1)
			if a in S and b in S:
				ans = max(ans,(x1-x2)**2 + (y1-y2)**2)
	print ans

Buggy python submission (verdict: Time Limit Exceeded):
p = 50
while 1:
	n = input()
	if n == 0: break
	xy = sorted([map(int,raw_input().split()) for i in range(n)])
	x,y = xy[0]
	xy = sorted(xy, key = lambda XY:(XY[0]-x)**2 + (XY[1]-y)**2)
	ans = 0
	for i in range(n-4):
		x1,y1 = xy[i]
		for j in range(n-3,i,-1):
			x2,y2 = xy[j]
			dx,dy = x2-x1,y2-y1
			if [x1-dy,y1-dx] in xy[j+1:j+p] and [x2+dy,y2-dx] in xy[j+1:j+p]:
				ans = dx**2+dy**2
			if [x1-dy,y1+dx] in xy[j+1:j+p] and [x2-dy,y2+dx] in xy[j+1:j+p]:
				ans = dx**2+dy**2
			if ans: break
		if ans: break
	print ans

Fixed submission:
while 1:
	n = input()
	if n == 0: break
	xy = [map(int,raw_input().split()) for i in range(n)]
	S = set(map(tuple,xy))
	ans = 0
	for i in range(n-1):
		x1,y1 = xy[i]
		for j in range(i+1,n):
			x2,y2 = xy[j]
			a = (x2-y2+y1,y2+x2-x1)
			b = (x1-y2+y1,y1+x2-x1)
			if a in S and b in S:
				ans = max(ans,(x1-x2)**2 + (y1-y2)**2)
	print ans

Buggy python submission (verdict: Runtime Error):
p = 50
while 1:
	n = input()
	if n == 0: break
	xy = sorted([map(int,raw_input().split()) for i in range(n)])
	x1,y1 = xy[0]
	xy = sorted(xy, key = lambda XY:(XY[0]-x1)**2 + (XY[1]-y11)**2)
	ans = 0
	for j in range(n-3,0,-1):
		x2,y2 = xy[j]
		dx,dy = x2-x1,y2-y1
		if [x1-dy,y1-dx] in xy[j+1:j+p] and [x2+dy,y2-dx] in xy[j+1:j+p]:
			ans = dx**2+dy**2
		if [x1-dy,y1+dx] in xy[j+1:j+p] and [x2-dy,y2+dx] in xy[j+1:j+p]:
			ans = dx**2+dy**2
		if ans: break
	print ans

Fixed submission:
while 1:
	n = input()
	if n == 0: break
	xy = [map(int,raw_input().split()) for i in range(n)]
	S = set(map(tuple,xy))
	ans = 0
	for i in range(n-1):
		x1,y1 = xy[i]
		for j in range(i+1,n):
			x2,y2 = xy[j]
			a = (x2-y2+y1,y2+x2-x1)
			b = (x1-y2+y1,y1+x2-x1)
			if a in S and b in S:
				ans = max(ans,(x1-x2)**2 + (y1-y2)**2)
	print ans

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
while 1:
	n = input()
	if n == 0: break
	xy = sorted([map(int,raw_input().split()) for i in range(n)])
	dxy = [[xy1[0]-xy2[0],xy1[1]-xy2[1]] for xy1,xy2 in itertools.combinations(xy,2)]
	for dx,dy in dxy:
		if dxy.count([dx,dy]) > 1 and (dxy.count([dy,-dx]) > 1 or dxy.count([-dy,-dx]) > 1):
			print dx**2+dy**2
			break
	else:
		print 0

Fixed submission:
while 1:
	n = input()
	if n == 0: break
	xy = [map(int,raw_input().split()) for i in range(n)]
	S = set(map(tuple,xy))
	ans = 0
	for i in range(n-1):
		x1,y1 = xy[i]
		for j in range(i+1,n):
			x2,y2 = xy[j]
			a = (x2-y2+y1,y2+x2-x1)
			b = (x1-y2+y1,y1+x2-x1)
			if a in S and b in S:
				ans = max(ans,(x1-x2)**2 + (y1-y2)**2)
	print ans

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
while 1:
	n = input()
	if n == 0: break
	xy = sorted([map(int,raw_input().split()) for i in range(n)])
	dxy = [[xy1[0]-xy2[0],xy1[1]-xy2[1]] for xy1,xy2 in itertools.combinations(xy,2)]
	for i in range(len(dxy)-1,-1,):
		if dxy.count(dxy[i]) < 2: del dxy[i]
	dxy = sorted(dxy, key = lambda d:d[0]**2 + d[1]**2, reverse = True) 
	for dx,dy in dxy:
		if dxy.count([dy,-dx]) > 1 or dxy.count([-dy,-dx]) > 1:
			print dx**2 + dy**2
			break
	else:
		print 0

Fixed submission:
while 1:
	n = input()
	if n == 0: break
	xy = [map(int,raw_input().split()) for i in range(n)]
	S = set(map(tuple,xy))
	ans = 0
	for i in range(n-1):
		x1,y1 = xy[i]
		for j in range(i+1,n):
			x2,y2 = xy[j]
			a = (x2-y2+y1,y2+x2-x1)
			b = (x1-y2+y1,y1+x2-x1)
			if a in S and b in S:
				ans = max(ans,(x1-x2)**2 + (y1-y2)**2)
	print ans

Buggy python submission (verdict: Runtime Error):
while 1:
	n = input()
	if n == 0: break
	xy = [map(int,raw_input().split()) for i in range(n)]
	S = set(map(tuple,xy))
	ans = 0
	for i in range(n):
		x1,y1 = xy[i]
		for j in range(n-1,i,-1):
			x2,y2 = xy[j]
			a = (x2-y2+y1,y2+x2-x1)
			b = (x1-y2+y1,y1+x2-x1)
			if a in S and b in S:
				ans = max((x1-x2)**2 + (y1-y2)**2)
	print ans

Fixed submission:
while 1:
	n = input()
	if n == 0: break
	xy = [map(int,raw_input().split()) for i in range(n)]
	S = set(map(tuple,xy))
	ans = 0
	for i in range(n-1):
		x1,y1 = xy[i]
		for j in range(i+1,n):
			x2,y2 = xy[j]
			a = (x2-y2+y1,y2+x2-x1)
			b = (x1-y2+y1,y1+x2-x1)
			if a in S and b in S:
				ans = max(ans,(x1-x2)**2 + (y1-y2)**2)
	print ans