Project Euler 29 - Distinct Powers
The code is very suboptimal. Keep in mind that Project Euler problems are not about brute force.

You only need to count the distinct powers. You don't have to actually calculate them. Instead, you need to realize that


a base \$a\$ may generate a repeat only if it is a perfect power itself.
each base which is not a perfect power contributes the same amount of unique elements (that is, there is 98 powers of 2, 98 powers of 6, etc) and all such sets are fully disjoint.
sets of elements generated by \$a\$, \$a^2\$, ... \$a^{100}\$ and \$b\$, \$b^2\$, ... \$b^{100}\$ are also equipotent and disjoint.


So, to obtain a solution you need to find out


how many numbers below \$b\$ are not perfect powers (linear complexity),
how many elements are in each set (also linear complexity; think of unique numbers in a multiplication table)


and multiply the results.