#include #include using namespace std; using namespace atcoder; using mint = modint998244353; //using mint = modint1000000007; using ll = long long; using P = pair; using T = tuple; templatebool chmax(T_& a, const T_& b) { if (a < b) { a = b;return true; } else { return false; } } templatebool chmin(T_& a, const T_& b) { if (a > b) { a = b;return true; } else { return false; } } #ifdef LOCAL template ostream& operator<<(ostream& o, const pair& p) { return o << "(" << p.first << ", " << p.second << ")"; } template ostream& operator<<(ostream& o, const tuple& t) { o << "("; apply([&o](auto&&... a) { int c = 0; (((o << (c++ ? ", " : "") << a)), ...); }, t); return o << ")"; } template auto operator<<(ostream& o, const V& v) -> std::enable_if_t && !std::is_same_v, decltype(v.begin(), o)> { o << "{"; int c = 0; for (auto& x : v) o << (c++ ? ", " : "") << x; return o << "}"; } #define dbg(...) cerr<<"["<<#__VA_ARGS__<<"]: ",([](auto&&... a){((cerr<> s; int n = s.size(); vector ans(n); bool kur = false; bool ok = true; for (int i = n - 1; i >= 0; i--) { if (kur) { kur = false; if (s[i] >= '6')ans[i] = '5'; else if (s[i] >= '5')ans[i] = '4'; else { if (i == 0) { ok = false; for (int j = 0; j < n - 1; j++) { cout << '5'; }cout << "\n"; } else { ans[i] = '5'; kur = true; } } } else { if (s[i] >= '5')ans[i] = '5'; else if (s[i] == '4')ans[i] = '4'; else { if (i == 0) { ok = false; for (int j = 0; j < n - 1; j++) { cout << '5'; }cout << "\n"; } else { ans[i] = '5'; kur = true; } } } } if (ok) { for (auto x : ans) { cout << x; } cout << "\n"; } } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int t = 1; // cin >> t; while (t--) { solve(); } }