Pythonの便利関数 - ysknsid25/atcoder GitHub Wiki

divmod

商と余りを同時に求めてくれる。

q, r = divmod(n, m)