fork(1) download
  1. # your code goes here
  2. import sys
  3. input = sys.stdin.readline
  4. n, m = map(int, input().split())
  5. cant_hear = set()
  6. cant_see = set()
  7. for i in range(n):
  8. cant_hear.add(input())
  9. for j in range(m):
  10. cant_see.add(input())
  11.  
  12. result = sorted(list(cant_hear & cant_see))
  13.  
  14. print(len(result))
  15.  
  16. for _ in result:
  17. print(_)
Success #stdin #stdout 0.04s 9664KB
stdin
3 4
ohhenrie
charlie
baesangwook
obama
baesangwook
ohhenrie
clinton
stdout
2
baesangwook

ohhenrie