startl = [12,1,16,3,11,0]
def solve(iters, inp):
lookup = list([0]*iters)
speak = inp.pop()
for c, n in enumerate(inp):
lookup[n] = c+1
for i in range(len(inp)+1, iters+1):
spoke = speak
speak = 0
if lookup[spoke] != 0:
speak = i - lookup[spoke]
lookup[spoke] = i
return spoke
print("a", solve(2020, startl[:]))
print("b", solve(30000000, startl[:]))