from math import gcd みたいなことをせず import math.gcd みたいにする
from math import gcd
みたいなことをせず
import math.gcd
みたいにする