···11+import fileinput
22+33+44+def power_level(x, y, serial):
55+ x += 1
66+ y += 1
77+ rack_id = x + 10
88+ return (((rack_id * y + serial) * rack_id // 100) % 10) - 5
99+1010+1111+SERIAL = int(fileinput.input()[0])
1212+SIZE = 300
1313+GRID = [[power_level(x, y, SERIAL) for x in range(SIZE)] for y in range(SIZE)]
1414+1515+overall_sum = 0
1616+overall_x = 0
1717+overall_y = 0
1818+overall_size = 0
1919+2020+for size in range(3, 16): # window size of 16 is good enough...right?
2121+ best_sum = 0
2222+ best_x = 0
2323+ best_y = 0
2424+2525+ for y in range(SIZE - size):
2626+ for x in range(SIZE - size):
2727+ total = 0
2828+ for j in range(size):
2929+ for i in range(size):
3030+ total += GRID[y + j][x + i]
3131+3232+ if total > best_sum:
3333+ best_sum = total
3434+ best_x = x
3535+ best_y = y
3636+3737+ if size == 3:
3838+ print "Coordinate of most powerful 3x3 grid: {},{}".format(best_x + 1, best_y + 1)
3939+4040+ if best_sum > overall_sum:
4141+ overall_sum = best_sum
4242+ overall_x = best_x
4343+ overall_y = best_y
4444+ overall_size = size
4545+4646+print "Identifier of the largest total power: {},{},{}".format(overall_x + 1, overall_y + 1, overall_size)