malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int a, b, c, s;   vector<double> x, y11, z;   double rx, ry, rz, mn = -1000000000;   double mln(double x) { return log(x); }   void upd(double nx, double ny, double nz) {     if (nx + ny + nz > (s + 1e-7)) return;     double cur = 0;     if (a) cur += a * mln(nx);     if (b) cur += b * mln(ny);     if (c) cur += c * mln(nz);     if (cur > mn) {       mn = cur;       rx = nx;       ry = ny;       rz = nz;     }   }   int main() {     scanf( %d %d %d %d , &s, &a, &b, &c);     if (a == 0 && b == 0 && c == 0) {       puts( 0.0 0.0 0.0 );       return 0;     }     if (a != 0) {       double S = s;       double m = 1 + b * 1. / a + c * 1. / a;       double x0 = S / m;       x.push_back(x0);       y11.push_back(x0 * b * 1. / a);       z.push_back(x0 * c * 1. / a);     } else if (b != 0) {       double S = s;       double m = 1 + a * 1. / b + c * 1. / b;       double x0 = S / m;       x.push_back(x0 * a * 1. / b);       y11.push_back(x0);       z.push_back(x0 * c * 1. / b);     } else if (c != 0) {       double S = s;       double m = 1 + a * 1. / c + b * 1. / c;       double x0 = S / m;       x.push_back(x0 * a * 1. / c);       y11.push_back(x0 * b * 1. / c);       z.push_back(x0);     }     double S = s;     x.push_back(0);     y11.push_back(0);     z.push_back(s);     x.push_back(0);     y11.push_back(s);     z.push_back(0);     x.push_back(s);     y11.push_back(0);     z.push_back(0);     if (a + b) {       z.push_back(0);       z.push_back(0);       x.push_back(a * c / (b + a + 0.));       y11.push_back(S - a * c / (b + a + 0.));       x.push_back(b * c / (b + a + 0.));       y11.push_back(S - b * c / (b + a + 0.));     }     if (b + c) {       x.push_back(0);       x.push_back(0);       y11.push_back(b * a / (b + c + 0.));       z.push_back(S - b * a / (b + c + 0.));       y11.push_back(c * a / (b + c + 0.));       z.push_back(S - c * a / (b + c + 0.));     }     if (a + c) {       y11.push_back(0);       y11.push_back(0);       x.push_back(a * b / (c + a + 0.));       z.push_back(S - a * b / (c + a + 0.));       x.push_back(c * b / (c + a + 0.));       z.push_back(S - c * b / (c + a + 0.));     }     for (int i = 0; i < x.size(); i++) {       upd(x[i], y11[i], z[i]);     }     printf( %.11lf %.11lf %.11lf n , rx, ry, rz);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct Pnt {     int x, y;     Pnt() {}     Pnt(int _x, int _y) {       x = _x;       y = _y;     }     bool operator<(const Pnt& o) const {       if (x != o.x) return x < o.x;       return y < o.y;     }     void show() { printf( Pnt %d %d n , x, y); }   };   const int MAXN = 1000005;   const int MAXS = 20;   const int dx[] = {1, 0, -1, 0};   const int dy[] = {0, 1, 0, -1};   int n, m;   char s[MAXN];   int f[MAXN][2];   void preGao() {}   void init() {     if (scanf( %s , s) == EOF) exit(0);     n = strlen(s);   }   void work() {     f[n][0] = 0;     f[n][1] = 2;     for (int i = n - 1; i >= 0; i--) {       f[i][0] = f[i + 1][0] + (s[i] ==  1 );       f[i][0] = min(f[i][0], f[i + 1][1]);       f[i][1] = f[i + 1][0] + 2 + (s[i] ==  0 );       f[i][1] = min(f[i][1], f[i + 1][1] + (s[i] ==  0 ));     }     printf( %d n , min(f[0][0], f[0][1]));   }   int main() {     preGao();     while (true) {       init();       work();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-9;   const double pi = acos(-1.0);   const int INF = 1000000000;   const int dx[4] = {0, 0, 1, -1};   const int dy[4] = {1, -1, 0, 0};   const int N = 100001;   int n, a[N];   int ans;   int main() {     ios_base::sync_with_stdio(0);     cin >> n;     for (int i = 0; (i) < (n); ++i) cin >> a[i];     sort(a, a + n);     int c = 1;     for (int i = 0; i < n; i++) {       if (a[i] >= c) {         c++;       }     }     cout << c << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 5;   const int inf = 1e9;   char aa[maxn];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int t;     cin >> t;     while (t--) {       int n, k;       cin >> n >> k;       for (int i = 1; i <= n; i++) {         cin >> aa[i];       }       sort(aa + 1, aa + 1 + n);       if (aa[1] != aa[k])         cout << aa[k] << endl;       else {         int mark = 1;         if (aa[n] == aa[k + 1]) mark = 0;         if (mark == 0) {           for (int i = 1; i <= n; i += k) cout << aa[i];           cout << endl;         } else {           cout << aa[1];           for (int i = k + 1; i <= n; i++) cout << aa[i];           cout << endl;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> G[14];   int dp[1 << 14], dp2[14][14][1 << 14];   vector<int> re[1 << 14];   pair<int, int> last_pair[1 << 14];   int pre[1 << 14];   int last[14][14][1 << 14];   bool v[1 << 14];   int main() {     int n, m, x, y;     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; i++) {       scanf( %d%d , &x, &y);       G[x - 1].push_back(y - 1);       G[y - 1].push_back(x - 1);     }     for (int i = 0; i < n; i++) v[1 << i] = 1;     memset(dp, 0x3f, sizeof(dp));     dp[1] = 0;     for (int i = 0; i < n; i++)       for (int j = 0; j < n; j++)         for (int k = 0; k < (1 << n); k++) {           dp2[i][j][k] = 0x3f3f3f3f;         }     for (int i = 0; i < n; i++)       for (auto x : G[i]) {         dp2[i][x][0] = 1;         last[i][x][0] = i;       }     for (int i = 0; i < (1 << n); i++) {       for (int j = 0; j < n; j++) {         if ((i >> j) & 1) continue;         for (int k = 0; k < n; k++) {           if ((i >> k) & 1) continue;           if (j == k || dp2[j][k][i] == 0x3f3f3f3f) continue;           for (auto z : G[k]) {             if ((i >> z) & 1) continue;             if (z == last[j][k][i]) continue;             int tmp = i ^ (1 << k);             if (dp2[j][z][tmp] == 0x3f3f3f3f) {               dp2[j][z][tmp] = 1;               last[j][z][tmp] = k;             }           }         }       }     }     for (int i = 0; i < n; i++) dp[1 << i] = 0;     for (int i = 0; i < (1 << n); i++)       for (int j = 0; j < n; j++) {         if ((i >> j) & 1) re[i].push_back(j);       }     for (int i = 0; i < (1 << n); i++) {       for (int j = i; j; j = (j - 1) & i) {         int tmp = i ^ j;         int cnt = __builtin_popcount(j) + 1;         if (dp[i] < dp[tmp] + cnt) continue;         for (auto x : re[tmp])           for (auto y : re[tmp]) {             if (dp2[x][y][j] == 1) {               dp[i] = min(dp[i], dp[tmp] + cnt);               last_pair[i] = make_pair(x, y);               pre[i] = tmp;             }           }       }     }     if (dp[(1 << n) - 1] == 0x3f3f3f3f) {       printf( -1 n );     } else {       printf( %d n , dp[(1 << n) - 1]);       int now = (1 << n) - 1;       while (!v[now]) {         int x = last_pair[now].first, y = last_pair[now].second;         int tmp = now ^ pre[now];         while (tmp) {           int tmp1 = last[x][y][tmp];           printf( %d %d n , y + 1, tmp1 + 1);           y = tmp1;           tmp ^= (1 << tmp1);         }         printf( %d %d n , x + 1, y + 1);         now = pre[now];       }     }   }
#include <bits/stdc++.h>   using namespace std;   void err(istream_iterator<string> it) {}   template <typename T, typename... Args>   void err(istream_iterator<string> it, T a, Args... args) {     cerr << *it <<   =   << a << endl;     err(++it, args...);   }   void faster() {     ios::sync_with_stdio(false);     cin.tie(nullptr);   }   long long n, m;   vector<long long> vst;   vector<long long> dis;   long long bfs(long long u, vector<set<long long> > &adj) {     queue<pair<long long, long long> > q;     q.push(make_pair(u, 0));     while (!q.empty()) {       long long v, d;       tie(v, d) = q.front();       q.pop();       vst[v] = 1;       dis[v - 1] = d;       for (auto e : adj[v]) {         if (!vst[e]) {           q.push(make_pair(e, d + 1));           vst[e] = 1;         }       }     }     return dis[n - 1];   }   void solve() {     cin >> n >> m;     vector<set<long long> > adj(n + 1);     vst.resize(n + 1);     dis.resize(n);     fill((dis).begin(), (dis).end(), 1000);     bool flag = true;     for (__typeof(m) i = (0) - ((0) > (m)); i != (m) - ((0) > (m));          i += 1 - 2 * ((0) > (m))) {       long long x, y;       cin >> x >> y;       if (min(x, y) == 1 && max(x, y) == n) flag = false;       adj[x].insert(y);       adj[y].insert(x);     }     if (flag) {       long long dist = bfs(1, adj);       if (dist == 1000) dist = -1;       cout << dist << endl;     } else {       vector<set<long long> > adjp(n + 1);       for (long long i = 1; i < n + 1; i++) {         for (long long j = 1; j < n + 1; j++) {           if (j != i && !adj[i].count(j)) adjp[i].insert(j);         }       }       long long dist = bfs(1, adjp);       if (dist == 1000) dist = -1;       cout << dist << endl;     }   }   signed main() {     faster();     long long t = 1;     while (t--) solve();   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 5;   int n, k;   vector<pair<int, int> > g[maxn];   int d[maxn], par[maxn];   void dfs1(int u, int fa) {     par[u] = fa;     for (auto p : g[u]) {       int v = p.first;       if (v == fa) continue;       d[v] = d[u] + p.second;       dfs1(v, u);     }   }   int a[maxn];   bool f[maxn];   int c[maxn];   void dfs(int u, int fa) {     d[u] = 0;     par[u] = fa;     for (auto p : g[u]) {       int v = p.first;       if (v == fa) continue;       dfs(v, u);       c[v] = p.second;       if (!f[v]) d[u] = max(d[u], d[v] + p.second);     }   }   int l[maxn], r[maxn], t[maxn], tail = 1;   int main() {     scanf( %d%d , &n, &k);     int u, v, w;     for (int i = 1; i <= n - 1; i++)       scanf( %d%d%d , &u, &v, &w), g[u].push_back(pair<int, int>(v, w)),           g[v].push_back(pair<int, int>(u, w));     dfs1(1, -1);     d[1] = 0;     int rt = 1;     for (int i = 1; i <= n; i++)       if (d[i] > d[rt]) rt = i;     d[rt] = 0;     dfs1(rt, -1);     int y = rt;     for (int i = 1; i <= n; i++)       if (d[i] > d[y]) y = i;     int p = y;     int m = 0;     while (p > 0) a[++m] = p, p = par[p];     dfs(rt, -1);     for (int i = 1; i <= n; i++) l[i] = d[i];     dfs(y, -1);     for (int i = 1; i <= n; i++) r[i] = d[i];     for (int i = 1; i <= m; i++) f[a[i]] = 1;     dfs(rt, -1);     tail = 1;     int head = 1;     int ans = 1e9;     for (int i = 1; i <= m; i++) {       while (tail > head && d[a[t[tail - 1]]] <= d[a[i]]) tail--;       t[tail++] = i;       int q = d[a[t[head]]];       q = max(q, (i - k + 1 > 0 ? l[a[i - k + 1]] : 0));       q = max(q, r[a[i]]);       ans = min(ans, q);       if (t[head] == i - k) head++;     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   int main() {     static char cc[100000 + 1];     int n, k, a, i;     scanf( %d%d , &n, &k);     a = (n - k) / 2;     for (i = 0; i < n; i++) cc[i] =  0  + (i % (a + 1) == a);     printf( %s n , cc);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, l, r, ar[110], ubah;   int main() {     cin >> n >> m;     for (int i = 1; i <= m; i++) {       cin >> l >> r;       ar[l]++;       ar[r + 1]--;     }     for (int i = 1; i <= n; i++) {       ubah += ar[i];       if (ubah != 1) {         cout << i <<     << ubah <<   n ;         return 0;       }     }     cout <<  OK n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   unsigned long long lvl_len(int lvl) {     static long long len[64] = {0};     if (len[lvl])       return len[lvl];     else {       len[1] = 1;       for (int i = 2; i < 64; ++i) len[i] = len[i - 1] * 2 + 1;     }     return len[lvl];   }   void rec(int lvl, unsigned long long pos) {     if (pos < lvl_len(lvl - 1))       rec(lvl - 1, pos);     else if ((pos -= lvl_len(lvl - 1)) < 1)       cout << lvl;     else       rec(lvl - 1, pos - 1);   };   int main(int, char **) {     ios::sync_with_stdio(false);     unsigned long long n, p;     cin >> n >> p;     rec(n, p - 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     cin >> n >> k;     vector<vector<int> > A(n, vector<int>(n));     int counter = 0;     int sum = 0;     for (int i = 0; i < n; i++) {       for (int j = 0; j < k - 1; j++) {         A[i][j] = ++counter;       }     }     for (int i = 0; i < n; i++) {       for (int j = k - 1; j < n; j++) {         A[i][j] = ++counter;       }     }     for (int i = 0; i < n; i++) {       sum += A[i][k - 1];     }     cout << sum << endl;     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         cout << A[i][j] <<    ;       }       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #define ll long long int   #define ff first   #define ss second   #define pb push_back   #define mp make_pair   #define deb(x) cout<< #x <<     << x <<   n ;   #define MAX 9223372036854775807   #define MIN -9223372036854775807   #define setbits(n) __builtin_popcountll(n)   #define mkunique(a) sort(a.begin(),a.end()); a.resize(unique(a.begin(),a.end())-a.begin());   #define print(s) for(auto u: s) cout<<u<<   ; cout<<  n ;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   const ll mod=998244353;           const int N=501;   ll dp[N][N][2], n;   vector<ll> a;   ll inc, id;       ll go(ll pos, ll diff, ll f){       if(pos==n){           if(f) return 1;           return 0;       }       if(dp[pos][diff][f]!=-1)           return dp[pos][diff][f];       ll ans = go(pos+1,diff,f);       if(a[pos]>0){           ll val = a[pos];           if(pos == id)               ans = (ans + go(pos+1,diff+1,1))%mod;           else{               if(val<inc || (val==inc && pos<id))                   ans = (ans + go(pos+1,diff+1,f))%mod;               else                   ans = (ans + go(pos+1,diff,f))%mod;           }       }       else{           if(diff-1 < 1)               ans = (ans + go(pos+1,0,0))%mod;           else               ans = (ans + go(pos+1,diff-1,f))%mod;       }       return dp[pos][diff][f] = ans;   }       int main(){           ios_base::sync_with_stdio(false);       cin.tie(NULL);       cout.tie(NULL);       ll TT=clock();           cin>>n;       for(ll i=0;i<n;i++){           char c;           cin>>c;           if(c== + ){               ll num;               cin>>num;               a.pb(num);           }           else{               a.pb(-1);           }       }       ll ans=0;       for(ll i=0;i<n;i++){           if(a[i]>0){               inc = a[i]; id = i;               memset(dp,-1,sizeof(dp));               ll mul = go(0,0,0);               ans = (ans + inc*mul%mod)%mod;           }       }       cout<<ans;               cerr<<  n nTIME:  <<(long double)(clock()-TT)/CLOCKS_PER_SEC<<  sec n ;       TT = clock();       return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     map<string, string> mp;     set<string> s;     for (int i = 0; i < n; i++) {       string old, edg;       cin >> old >> edg;       mp[old] = edg;       s.insert(edg);     }     map<string, string>::iterator p;     p = mp.begin();     vector<pair<string, string>> a;     for (p; p != mp.end(); p++) {       if (s.count(p->first)) continue;       string cur;       cur = p->first;       while (mp.count(cur)) {         cur = mp[cur];       }       a.push_back(make_pair(p->first, cur));     }     cout << a.size() <<   n ;     for (int i = 0; i < a.size(); i++)       cout << a[i].first <<     << a[i].second <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   long long add(long long x, long long y) {     x += y;     while (x >= 998244353) x -= 998244353;     while (x < 0) x += 998244353;     return x;   }   long long mul(long long x, long long y) { return (x * 1ll * y) % 998244353; }   long long binpow(long long x, long long y) {     long long z = 1;     while (y > 0) {       if (y % 2 == 1) z = mul(z, x);       x = mul(x, x);       y /= 2;     }     return z;   }   long long inv(long long x) { return binpow(x, 998244353 - 2); }   long long divide(long long x, long long y) { return mul(x, inv(y)); }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long n, k;     cin >> n >> k;     vector<long long> a(k);     for (long long i = 0; i < (long long)k; ++i) cin >> a[i];     vector<long long> last(n + 1, -1), fst(n + 1, k);     for (long long i = 1; i <= k; i++) {       last[a[i - 1]] = i;     }     for (long long i = k; i >= 1; i--) {       fst[a[i - 1]] = i;     }     long long ans = 0;     for (long long i = 1; i <= n; i++) {       for (long long j = max(1ll, i - 1); j <= min(i + 1, n); j++) {         if (j == i) {           if (last[i] == -1) ans += 1;         } else           ans += (last[i] <= fst[j]);       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 5;   long long T[N];   long long sum[5];   multiset<long long, greater<long long>> ms[5];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n, k, b, c;     cin >> n >> k >> b >> c;     for (int i = 1; i <= n; i++) {       cin >> T[i];     }     sort(T + 1, T + n + 1);     if (T[1] < 0) {       long long val = -T[1];       for (int i = 1; i <= n; i++) {         T[i] += val;       }     }     if (5 * c <= b) {       long long ans = 9e18;       long long sum = 0;       for (int i = 1; i <= n; i++) {         sum += T[i];         if (i >= k) {           ans = min(ans, T[i] * k - sum);           sum -= T[i - k + 1];         }       }       cout << ans <<   n ;       exit(0);     }     long long ans = 9e18;     for (int i = 1; i <= n; i++) {       for (int j = 0; j < 5; j++) {         long long cnt = -((T[i] + j) / 5) * b + j * c;         int mm = (T[i] + j) % 5;         sum[mm] += cnt;         ms[mm].insert(cnt);       }       if (i > k) {         for (int j = 0; j < 5; j++) {           sum[j] -= *ms[j].begin();           ms[j].erase(ms[j].begin());         }       }       if (i >= k) {         for (int j = 0; j < 5; j++) {           int mm = (T[i] + j) % 5;           ans = min(ans, ((T[i] + j) / 5) * b * k + sum[mm]);         }       }     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   long long int mod = 1000000007;   using namespace std;   void solve() {     long long int n, k;     cin >> n >> k;     char ans[4][n];     int nval = n - 2;     for (int i = 0; i < 4; i++) {       for (int j = 0; j < n; j++) {         ans[i][j] =  . ;       }     }     int mid = nval / 2;     mid++;     if (k % 2 == 1) {       for (int i = 1; i < 3; i++) {         if (k <= 0) break;         for (int j = mid; j >= 1; j--) {           if (i > 1 && k % 2 == 0 && k < nval) {             ans[i][1] =  # ;             ans[i][n - 2] =  # ;             k--;             k--;           }           if (k > 0) {             ans[i][j] =  # ;             k--;             if (k <= 0) break;             ans[i][mid + (mid - j)] =  # ;             if (j != mid) k--;           } else             break;         }       }     } else {       for (int i = 1; i < n - 1; i++) {         for (int j = 1; j < 3; j++) {           if (k) {             ans[j][i] =  # ;             k--;           }         }       }     }     cout <<  YES  << endl;     for (int i = 0; i < 4; i++) {       for (int j = 0; j < n; j++) {         cout << ans[i][j];       }       cout << endl;     }   }   int main() {     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 300005;   const long long mod = 998244353;   long long fac[maxn], invfac[maxn];   int a[maxn];   long long qp(long long x, long long p, long long MOD) {     long long res = 1;     while (p) {       if (p & 1) res = res * x % MOD;       x = x * x % MOD;       p >>= 1;     }     return res;   }   void init() {     fac[0] = 1;     invfac[0] = 1;     for (int i = 1; i < maxn; i++) fac[i] = fac[i - 1] * 1ll * i % mod;     invfac[maxn - 1] = qp(fac[maxn - 1], mod - 2, mod);     for (int i = maxn - 2; i >= 1; i--)       invfac[i] = invfac[i + 1] * 1ll * (i + 1) % mod;   }   long long C(int n, int k) {     return fac[n] * invfac[n - k] % mod * invfac[k] % mod;   }   int main() {     init();     int n;     scanf( %d , &n);     for (int i = 1; i <= n + n; i++) scanf( %d , &a[i]);     sort(a + 1, a + n * 2 + 1);     long long ans = 0;     for (int i = 1; i <= n * 2; i++) {       if (i <= n) {         ans = (ans - C(n * 2, n) * a[i] % mod) % mod;       } else {         ans = (ans + C(n * 2, n) * a[i] % mod + mod) % mod;       }     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int f3(int n) { return n * (n - 1) * (n - 2) / 6; }   int main() {     int K;     cin >> K;     int N = 3;     while (f3(N + 1) <= K) N++;     int MN = N * (N - 1) / 2;     int TN = 100;     vector<string> E(TN, string(TN,  0 ));     for (int i = 0; i < N; i++) {       for (int j = i + 1; j < N; j++) {         E[i][j] = E[j][i] =  1 ;       }     }     int GK = f3(N);     for (int i = N; i < TN; i++) {       for (int j = 0; j < N && GK + j <= K; j++) {         E[i][j] = E[j][i] =  1 ;         GK += j;       }     }     cout << TN << endl;     for (int i = 0; i < E.size(); i++) cout << E[i] << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int up = 1e6 + 6;   int n, m, k, pos;   int cost[up], p[up], last[up];   int main() {     scanf( %d , &n);     scanf( %d , &m);     scanf( %d , &k);     for (int i = 1; i <= m; i++) {       scanf( %d , &pos);       p[pos] = 1;     }     if (p[0]) {       printf( %d n , -1);       return 0;     }     for (int i = 0; i <= n; i++) {       if (!p[i])         last[i] = i;       else         last[i] = last[i - 1];     }     for (int i = 1; i <= k; i++) {       scanf( %d , &cost[i]);     }     long long res = 1ll * up * up;     for (int i = 1; i <= k; i++) {       int cnt = 1;       for (int j = i; j < n; j += i) {         if (j - last[j] >= i) {           cnt = n + 10;           break;         } else {           j = last[j];           cnt++;         }       }       if (cnt <= n) {         res = min(res, 1ll * cnt * cost[i]);       }     }     if (res == 1ll * up * up) {       res = -1ll;     }     printf( %I64d n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   mt19937_64 rang(       chrono::high_resolution_clock::now().time_since_epoch().count());   int rng(int lim) {     uniform_int_distribution<int> uid(0, lim - 1);     return uid(rang);   }   void solution() {     int y;     cin >> y;     while (true) {       y = y + 1;       int a = y / 1000;       int b = y / 100 % 10;       int c = y / 10 % 10;       int d = y % 10;       if (a != b && a != c && a != d && b != c && b != d && c != d) {         break;       }     }     cout << y << endl;   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     srand(chrono::high_resolution_clock::now().time_since_epoch().count());     int test = 1;     while (test--) {       solution();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<char, char> q;   int main() {     char a[30], b[30];     scanf( %s , a);     scanf( %s , b);     q.clear();     for (int i = 0; i < 26; i++) {       q[a[i]] = b[i];       q[a[i] - 32] = b[i] - 32;     }     char aim[2000];     scanf( %s , aim);     for (int i = 0; aim[i]; i++) {       if (q[aim[i]])         printf( %c , q[aim[i]]);       else         printf( %c , aim[i]);     }     printf(  n );   }
#include <bits/stdc++.h>   const double EPS = 1e-7;   const double PI = 3.1415926535897932384626;   const int MAXN = 100001;   int n, a[MAXN];   int main() {     std::cin >> n;     for (int i = 1; i <= n; i++) {       std::cin >> a[i];     }     long long answer = 0;     for (int i = 1; i <= n; i++) {       answer += a[i];     }     std::sort(a + 1, a + n + 1);     if (answer & 1) {       for (int i = 1; i <= n; i++)         if (a[i] & 1) {           answer -= a[i];           break;         }     }     std::cout << answer << std::endl;     return 0;   }