fork download
  1. #include <iostream>
  2. #include <set>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. set<string> words;
  8. string a;
  9.  
  10. while (cin >> a) {
  11. if (words.count(a)) {
  12. cout << a << endl;
  13. break;
  14. } else {
  15. words.insert(a);
  16. }
  17. }
  18. }
Success #stdin #stdout 0s 3468KB
stdin
a
b
c
d
b
stdout
b