AtCoder Beginner Contest 193 C - Unexpressed【Python】

https://atcoder.jp/contests/abc193/tasks/abc193_c
AtCoder ProblemsのRecommendationで Difficulty: 379、Solve Probability: 44%でした。

N = int(input())
amax = int(N ** 0.5)
#2 ** 34 > 10 ** 10
bmax = 33
can = 0
s = set()
for a in range(2, amax+1):
    for b in range(2, bmax+1):
        n = pow(a, b)
        if N >= n:
            s.add(n)
        else:
            break
ans = N - len(s)
print(ans)

breakを入れなかったことでTLEとなってしまいました。
わざわざbmax = 33とする必要もなかったですね。