def problem142():
	i = 1
	record = 7691793
	while True:
		a1 = i**2
		# we need a1 - a3 = a6 > 0
		for j in range(2,i):
			a3 = j**2
			if isSquare(a1 - a3):
				# a6 is positive
				a6 = a1 - a3
				# need now that a3 and a4 have the same parity as a4 + a3 = 2x
				for k in range(j%2,j,2):
					a4 = k**2
					a5 = a1 - a4
					a2 = a3 - a5
					if a2 > 0 and a5> 0 and isSquare(a5) and isSquare(a2):
						if (a1 + a2) % 2 == 0 and (a5 + a6) % 2 == 0 and (a3 - a4) % 2 == 0:
							x = (a1 + a2)//2
							y = (a5 + a6)//2
							z = (a3 - a4)//2
							if x + y + z < record and x > y and y > z and z>0 and all([isSquare(x-y), isSquare(x+y), isSquare(x+z), isSquare(x-z), isSquare(y+z), isSquare(y-z)]):
								return x + y + z

		i += 1
		print(i)
def dictionariesGivingSquares(word):
	dictionaries = []
	for dictionary in possibleDictionaries(word):
		numb = numberReplacement(word,dictionary)
		if isSquare(numb):
			dictionaries.append(dictionary)
	return dictionaries
def problem80():
	getcontext().prec = 102
	total = 0
	for a in range(2, 100):
		if not isSquare(a):
			b = Decimal(a).sqrt()
			#total += applyToDigits(int(b * 10**100), lambda x: x)
			total += sum(int(c) for c in str(b * 10**100)[:100])
	return total
def solveQuadratic(a,b,c):
	disc = b**2 - 4*a*c
	soln = []
	if disc > 0:
		if isSquare(disc):
			d = integerSquare(disc)
			if (-b - d) % (2*a) == 0:
				soln.append((-b - d) // (2*a))
			if (-b + d) % (2*a) == 0:
				soln.append((-b + d) // (2*a))
	return soln
def problem141():
	#GOAL = 10**12
	GOAL = 10**12 # 623708737 = 10**9
	total = 0
	for a in range(2,int(GOAL**(1/3))):
		for b in [r for r in range(1,a) if (a**3*r + r**2 < GOAL and gcd(a,r) == 1)]:
			e,n = 1,0
			while n < GOAL:
				n = a**3*b*e**2 + e*b**2
				if isSquare(n):
					print(a,b,e)
					total += n
				e += 1
	return total
def problem211():
    total = 0
    for n in range(1, 64 * 10 ** 6):
        if isSquare(sigma(n, 2)):
            total += n
    return total