class Solution(object):
	def maxIncreaseKeepingSkyline(self, grid):
		"""
		:type grid: List[List[int]]
		:rtype: int
		"""
		def maxRow(row):
			return max(row)

		def maxColumn(column):
			return max(column)
		# map(max, grid), map(max, zip(*grid)) is much more efficient
		gridInverse = [list(x) for x in zip(*grid)]
		count = 0
		for r in range(len(grid)):
			for c in range(len(grid[0])):
				count += min(maxRow(grid[r]), maxColumn(gridInverse[c])) - grid[r][c] 

		return count