Problem p03240 (python)

Fixed submission:
import collections
n = int(raw_input())
pts = [map(int , raw_input().split()) for _ in range(n)]

def f(pts):
	for cx,cy in [(ii,jj) for ii in range(100+1) for jj in range(100+1)]:	
		H = min([abs(cx - x) + abs(cy - y) for x,y,h in pts if h == 0] or [+float('inf')])
		
		cc = collections.Counter()
		for x,y,h in pts:
			q = abs(cx - x) + abs(cy - y)
			if h > 0:
				Y = h + q
				if 1<=Y <= H:
					cc[Y]+=1
				else:
					cc[-1] += 1
		if len(cc) == 1:
			for k in cc:
				if 1<=k <= H:
					return k,cx,cy

h,x,y = f(pts)

print x,y,h

Buggy submission (verdict: Runtime Error):
import collections
n = int(raw_input())
pts = [map(int , raw_input().split()) for _ in range(n)]

def f(pts):
	for cx,cy in [(ii,jj) for ii in range(100+1) for jj in range(100+1)]:	
		H = min([abs(cx - x) + abs(cy - y) for x,y,h in pts if h == 0] or [10 ** 9])
		
		cc = collections.Counter()
		for x,y,h in pts:
			q = abs(cx - x) + abs(cy - y)
			if h > 0:
				Y = h + q
				if 1<=Y <= H:
					cc[Y]+=1
				else:
					cc[10 ** 9 + 2] += 1
		if len(cc) == 1:
			for k in cc:
				if 1<=k <= 10 ** 9:
					return k,cx,cy

h,x,y = f(pts)

print x,y,h

Buggy submission (verdict: Runtime Error):
import collections
n = int(raw_input())
pts = [map(int , raw_input().split()) for _ in range(n)]
res = -1
def f(pts):
	for cx,cy in [(ii,jj) for ii in range(100+1) for jj in range(100+1)]:	
		H = max([abs(cx - x) + abs(cy - y) for x,y,h in pts if h == 0] or [-float('inf')])
		for x,y,h in pts:
			q = abs(cx - x) + abs(cy - y)
			if h:
				#Y  - q = h
				Y = h + q
				if Y >= H:
					cc[Y]+=1
				else:
					cc[10 ** 9 + 1] += 1
		if len(cc) == 1:
			for k in cc:
				return k,cx,cy

h,x,y = f(pts)

print x,y,h

Buggy submission (verdict: Runtime Error):
import collections
n = int(raw_input())
pts = [map(int , raw_input().split()) for _ in range(n)]
res = -1
def f(pts):
	for cx,cy in [(ii,jj) for ii in range(100+1) for jj in range(100+1)]:	
		H = max([abs(cx - x) + abs(cy - y) for x,y,h in pts if h == 0] or [-float('inf')])
		for x,y,h in pts:
			q = abs(cx - x) + abs(cy - y)
			if h:
				#Y  - q = h
				Y = h + q
				if Y >= H:
					cc[Y]+=1
				else:
					cc[10 ** 9 + 1] += 1
		if len(cc) == 1:
			for k in cc:
				return k,cx,cy

h,x,y = f(pts)

print x,y,h

Buggy submission (verdict: Runtime Error):
import collections
n = int(raw_input())
pts = [map(int , raw_input().split()) for _ in range(n)]
res = -1
def f(pts):
	for cx,cy in [(ii,jj) for ii in range(100+1) for jj in range(100+1)]:	
		H = 10 ** 9 + 1
		cc = collections.Counter()
		H = max([abs(cx - x) + abs(cy - y) for x,y,h in pts if h == 0] or [-float('inf')])
	
		for x,y,h in pts:
			q = abs(cx - x) + abs(cy - y)
			if h:
				Y = h + q
				if Y >= H:
					cc[Y]+=1
		if len(cc) == 1:
			for k in cc:
				return k,cx,cy

h,x,y = f(pts)

print x,y,h

Buggy submission (verdict: Runtime Error):
import collections
n = int(raw_input())
pts = [map(int , raw_input().split()) for _ in range(n)]
res = -1
def f(pts):
	for cx,cy in [(ii,jj) for ii in range(100+1) for jj in range(100+1)]:	
		H = 10 ** 9 + 1
		cc = collections.Counter()
		H = max([abs(cx - x) + abs(cy - y) for x,y,h in pts if h == 0] or [-float('inf')])
	
		for x,y,h in pts:
			q = abs(cx - x) + abs(cy - y)
			if h:
				Y = h + q
				if Y >= H:
					cc[Y]+=1
		if len(cc) == 1:
			for k in cc:
				return Y,cx,cy

h,x,y = f(pts)

print x,y,h