fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int32_t main() {
  5. ios::sync_with_stdio(false);
  6. cin.tie(nullptr);
  7.  
  8. string s;
  9. cin >> s;
  10.  
  11. for (int x = 0; x < 1000; x += 8) {
  12. string t = to_string(x);
  13. int j = 0;
  14. for (int i = 0; i < (int)s.size() && j < (int)t.size(); i++) {
  15. if (s[i] == t[j]) j++;
  16. }
  17. if (j == (int)t.size()) {
  18. cout << "YES\n" << t << "\n";
  19. return 0;
  20. }
  21. }
  22.  
  23. cout << "NO\n";
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0.01s 5316KB
stdin
10
stdout
YES
0