Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
2.1 kB
4
Indexable
Never
#pragma GCC optimize ("O3")
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define rep(i,s, n) for(int i=s;i<n;++i)
#define repr(i,s, n) for(int i=n;i>=s;--i)
#define all(x) x.begin(), x.end()
#define mp make_pair
#define sz(x) int(x.size())
#define bpc          __builtin_popcount
#define pii          pair<int, int>
#define pll          pair<ll, ll>
#define piii         pair<pii, int>
#define vpii         vector<pii>
#define vpll         vector<pll>
#define f first
#define s second
#define endl '\n'
#define each(x, a) for (auto& x : a)
#define mem(a, b) memset(a, b, sizeof(a))
#define sortall(x) sort(all(x))
#define szof(arr) sizeof(arr)/sizeof(arr[0])
#define rrep(i, n) repr(i, n-1)
#define trav(a, x) for (auto& a : x)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c),x) != (c).end())
#define vpii         vector<pii>
#define vpll         vector<pll>
using namespace std;
using namespace __gnu_pbds;
using namespace __cxx11;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

const int MOD = 1e9 + 7;
const int INF = INT_MAX;
const ll LL_INF = LLONG_MAX;

void solve() {
    string k,s;
    cin >> k;
    s = k;
    for (char& x : k) {
        int num = x - '0';
        int complement = abs(9 - num);
        x = min(num, complement) + '0';
    }
    if(stoi(k) == 0){
        s[0] = min(s[0]-'0' , 9-(s[0]-'0'));
        rep(i,1,s.size()){
            s[i] = '0';
        }
        cout<<stoi(s);
        return;
    }
    cout << stoi(k) << endl;
}


int main() {
    fio;
    int t=1;

    while(t--){
        solve();
    }
    return 0;
}
Leave a Comment