#!/usr/bin/env python
"""
A Pythagorean triplet is a set of three natural numbers, a b c, for which,
a^2 + b^2 = c^2
For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2.
There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc.
"""
import math
def solve():
limit = 500
squares = [x*x for x in xrange(1, limit)]
for x in xrange(1, limit):
for y in xrange(1, limit):
product = x*x + y*y
if product in squares:
z = int(math.sqrt(product))
if x + y + z == 1000:
return x * y *z
if __name__ == '__main__':
print solve()