Expressing as a sum of squares. Suppose a number can be expressed as a sum of two squares. If I know it's prime factorization, what is the easiest way to find two such numbers?
For e.g., let us consider the number $97^5 \cdot 641^3 \cdot 3^8$, how can I find $a$ and $b$ such that $a^2 + b^2 = 97^5 \cdot 641^3 \cdot 3^8$?

First you must do it for its prime factors by trial, then you can use Brahmagputa's identity.
$$(a^2+b^2)(c^2+d^2)=a^2c^2+a^2d^2+b^2c^2+b^2d^2+2abcd-2abcd$$
$$=(ac+bd)^2+(ad-bc)^2$$
Notice that if $p$ is a prime number and there exist $a$ and $b$ such that $a^2+b^2=p$ then without loss of generality we can assume that $a>b$ therefore $$\displaystyle 2b^2<a^2+b^2=p \implies b^2 <\frac{p}{2} \implies b \leq \lfloor\sqrt{\frac{p}{2}}\rfloor $$ So you only need to check the first $\lfloor\sqrt{\frac{p}{2}}\rfloor$ numbers to find the smaller number $b$ in $a^2+b^2=p$, and once you've found it the other one has already been found from  $a^2 = p-b^2$.
