今週前半はAWSの試験があり、直前だったので一旦お休みしてました。
N,K = map(int,input().split())
A = {input() for i in range(N)}
for _ in range(K):
command = input().split()
if command[0] == 'handshake':
for name in sorted(A):
print(name)
elif command[0] == 'leave':
A.remove(command[1])
else:
A.add(command[1])
久しぶりだったのでちょっとど忘れしたりして長引いてしまいました。
キー無しの辞書は{}でできて、
削除や追加はremove,addでできる。
順序はもちろんsortedで。