fork download
  1. import fileinput
  2.  
  3. words = set() #NOTE: it is unordered but it doesn't affect the result
  4. tokens = (token for line in fileinput.input() for token in line.split())
  5. for op, word in zip(*[tokens]*2):
  6. if op == '+':
  7. words.add(word)
  8. elif op == '-':
  9. words.discard(word)
  10. elif op == '?':
  11. print(word, "Yes" if word in words else "No")
Success #stdin #stdout 0.04s 9440KB
stdin
+ The + donation + will + go + toward + the ? CDC - Global + Disaster + Response 
- The 
    ? The
        ? will
stdout
CDC No
The No
will Yes