Как оптимизировать код на python?
Появилась необходимость ускорить данный код, но я не знаю как.
q = int(input())
coll = []
count = 0
for i in range(q):
typ, x = map(int, input().split())
if typ == 1:
coll.append(x)
elif typ == 2:
coll.remove(x)
elif typ == 3:
count = 0
used = []
for j in range(len(coll)):
if coll[j] % x == 0 and coll[j] not in used:
used.append(coll[j])
count += 1
print(count)
Как можно его ускорить?