func_code_string: #include <bits/stdc++.h>   using namespace std;   int gets(string s) {     int sum = 0;     while ((s[0] ==  0 ) and (s.size() != 1)) s = s.substr(1, s.size() - 1);     for (int i = 0; i < s.size(); i++) sum += s[i] - 48;     return sum;   }   int main() {     string s, s1, m;     int kol;     cin >> s;     m = s;     kol = gets(s);     for (int i = 0; i < s.size(); i++) {       s1 = s;       int kol1 = 0;       if (s1[i] !=  0 ) s1[i]--;       for (int j = i + 1; j < s.size(); j++) s1[j] =  9 ;       kol1 = gets(s1);       while ((s1[0] ==  0 ) and (s1.size() != 1))         s1 = s1.substr(1, s1.size() - 1);       if ((kol1 > kol) or           ((kol == kol1) and            ((s1.size() > m.size()) or ((s1 > m) and (s1.size() == m.size()))))) {         m = s1;         kol = kol1;       }     }     cout << m;   }   