malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   void low(int n) {     switch (n) {       default:         cout <<  zero ;         break;       case 1:         cout <<  one ;         break;       case 2:         cout <<  two ;         break;       case 3:         cout <<  three ;         break;       case 4:         cout <<  four ;         break;       case 5:         cout <<  five ;         break;       case 6:         cout <<  six ;         break;       case 7:         cout <<  seven ;         break;       case 8:         cout <<  eight ;         break;       case 9:         cout <<  nine ;         break;       case 10:         cout <<  ten ;         break;       case 11:         cout <<  eleven ;         break;       case 12:         cout <<  twelve ;         break;       case 13:         cout <<  thirteen ;         break;       case 14:         cout <<  fourteen ;         break;       case 15:         cout <<  fifteen ;         break;       case 16:         cout <<  sixteen ;         break;       case 17:         cout <<  seventeen ;         break;       case 18:         cout <<  eighteen ;         break;       case 19:         cout <<  nineteen ;         break;     }   }   void high(int n) {     switch (n) {       case 2:         cout <<  twenty ;         break;       case 3:         cout <<  thirty ;         break;       case 4:         cout <<  forty ;         break;       case 5:         cout <<  fifty ;         break;       case 6:         cout <<  sixty ;         break;       case 7:         cout <<  seventy ;         break;       case 8:         cout <<  eighty ;         break;       default:         cout <<  ninety ;         break;     }   }   int main() {     int n;     cin >> n;     if (n < 20)       low(n);     else {       high(n / 10);       if (n % 10 != 0) {         cout <<  - ;         low(n % 10);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void ga(int N, int *A) {     for (int i(0); i < N; i++) scanf( %d , A + i);   }   char s[222222], r[222222];   int N, A, B;   int main(void) {     scanf( %s%s , s, r), N = strlen(s);     for (int i(0); i < N; i++)       if (s[i] ^ r[i]) A += s[i] == 52, B += s[i] != 52;     printf( %d n , max(A, B));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 5, mod = 1e9 + 7;   int add(int x, int y) {     x += y;     return x >= mod ? x - mod : x;   }   int c[maxn << 1], dp[maxn];   struct node {     int x, y, op;   } e[maxn];   bool cmp(node a, node b) {     if (a.x == b.x) return a.y < b.y;     return a.x < b.x;   }   void ins(int x, int k) {     while (x) {       c[x] = add(c[x], k);       x -= x & (-x);     }   }   int query(int x) {     int res = 0;     for (; x <= 400000; x += (x & (-x))) {       res = add(res, c[x]);     }     return res;   }   int main() {     int n, q, x;     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d%d , &e[i].y, &e[i].x);     }     scanf( %d , &q);     while (q--) {       scanf( %d , &x);       e[x].op = 1;     }     sort(e + 1, e + 1 + n, cmp);     ins(2 * n, 1);     for (int i = 1; i <= n; i++) {       dp[i] = query(e[i].y);       ins(e[i].y, dp[i]);     }     int pv = 1, ans = 0;     for (int i = n; i > 0; i--) {       ins(e[i].y, (mod - dp[i]) % mod);       if (e[i].op == 1 && e[i].y >= pv) {         ans = add(ans, query(pv));         pv = e[i].y;       }     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline bool ig(char c) { return c >=  0  && c <=  9 ; }   inline void read(int &oi) {     char c;     int f = 1, res = 0;     while (c = getchar(), (!ig(c)) && c !=  - )       ;     c ==  -  ? f = -1 : res = (c ^ 48);     while (c = getchar(), ig(c)) res = res * 10 + (c ^ 48);     oi = f * res;   }   inline void print(int oi) {     if (oi < 0) putchar( - ), oi = ~oi + 1;     if (oi > 9) print(oi / 10);     putchar(oi % 10 + 48);   }   int n, m, ans;   struct Edge {     int x, y, z;     bool operator<(const Edge &b) const { return z > b.z; }   } e[200005];   int fa[200005];   bool s[200005];   inline int gfa(int u) { return u ^ fa[u] ? fa[u] = gfa(fa[u]) : u; }   int main() {     read(n);     read(m);     for (int i = 1; i <= m; ++i) read(e[i].x), read(e[i].y), read(e[i].z);     sort(e + 1, e + 1 + m);     for (int i = 1; i <= n; ++i) fa[i] = i, s[i] = true;     for (int i = 1; i <= m; ++i) {       int fx = gfa(e[i].x), fy = gfa(e[i].y);       if ((fx ^ fy) && (s[fx] || s[fy]))         ans += e[i].z, fa[fx] = fy, s[fy] = s[fy] & s[fx];       else if (!(fx ^ fy) && s[fx])         s[fx] = false, ans += e[i].z;     }     print(ans);     putchar(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[200005];   unordered_map<long long, long long> f, done;   vector<long long> v;   int main() {     std::ios_base::sync_with_stdio(0);     cin.tie(0);     long long n;     long long ans = 0;     cin >> n;     for (long long i = 1; i <= n; i++) {       cin >> a[i];       f[a[i]]++;     }     for (int i = 1; i <= n; i++) {       if (f[i] == 0) {         ans++;         v.push_back(i);       }     }     cout << ans << endl;     long long ptr = 0;     for (long long i = 1; i <= n; i++) {       if (f[a[i]] == 1) {         if (done[a[i]] == 0) {           cout << a[i] <<    ;           done[a[i]]++;         } else {           cout << v[ptr] <<    ;           ptr++;         }       } else {         if (v[ptr] > a[i] && done[a[i]] == 0) {           cout << a[i] <<    ;           f[a[i]]--;           done[a[i]]++;         } else {           f[a[i]]--;           cout << v[ptr] <<    ;           done[v[ptr]]++;           ptr++;         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   int N, M, T, tb[100005];   long long a, b, c, co, x;   map<int, int> mp;   map<int, int>::iterator it;   int chk[100005];   int main() {     int i, j, k;     scanf( %d%I64d , &N, &co);     for (i = 1; i <= N; i++) {       scanf( %d , &tb[i]);       mp[tb[i]]++;       x += tb[i];     }     if (x < co) {       printf( -1 n );       scanf(   );       return 0;     } else if (x == co) {       printf(  n );       scanf(   );       return 0;     }     a = N;     b = 0;     for (it = mp.begin(); it != mp.end(); it++) {       k = (*it).first;       j = (*it).second;       if (c + a * (k - b) > co) break;       c += a * (k - b);       b = k;       a -= j;     }     a = k - b;     long long num = co - c;     int idx = 0;     for (i = 1; i <= N; i++) {       if (tb[i] >= k) {         chk[idx] = i;         idx++;       }     }     b = num / idx;     num %= idx;     i = num;     bool err = true;     for (int kk = 1; kk <= idx; kk++) {       if (b != a - 1 || ((b == a - 1 && tb[chk[i]] != k) || err))         printf( %d  , chk[i]);       i++;       if (i >= idx) {         i %= idx;         err = false;       }     }     scanf(   );   }
#include <bits/stdc++.h>   using namespace std;   int mida;   void update(vector<int>& T, int p, int x) {     T[mida + p] = x;     for (int i = (mida + p) / 2; i > 0; i /= 2) T[i] = T[2 * i] + T[2 * i + 1];   }   int suma(vector<int>& T, int a, int b, int c = 0, int d = mida - 1, int p = 1) {     if (a <= c and d <= b) return T[p];     if (d < a or c > b) return 0;     return suma(T, a, b, c, (c + d) / 2, 2 * p) +            suma(T, a, b, (c + d) / 2 + 1, d, 2 * p + 1);   }   int main() {     int k;     string r;     cin >> k >> r;     string s;     for (int i = 0; i < k; ++i) s += r;     int n = s.size();     mida = 1;     while (mida < n) mida *= 2;     vector<vector<int> > T( z  -  a  + 1, vector<int>(2 * mida, 0));     for (int i = 0; i < n; ++i) update(T[s[i] -  a ], i, 1);     int q;     cin >> q;     while (q--) {       int p;       char c;       cin >> p >> c;       int ini = 0, fin = n - 1;       while (ini <= fin) {         int m = (ini + fin) / 2;         if (suma(T[c -  a ], 0, m) >= p)           fin = m - 1;         else           ini = m + 1;       }       s[fin + 1] = 0;       update(T[c -  a ], fin + 1, 0);     }     for (int i = 0; i < n; ++i)       if (s[i] > 0) cout << s[i];     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   int r, c, s, e;   vector<int> adj[1000 * 1000 + 10];   int d[1000 * 1000 + 10];   char grid[1000][1000];   char access(int n) {     int x = n % c;     int y = n / c;     return grid[y][x];   }   void bfs(int n) {     queue<int> frontier;     frontier.push(n);     d[n] = 0;     while (!frontier.empty()) {       int u = frontier.front();       frontier.pop();       for (int i = 0; i < adj[u].size(); i++) {         int v = adj[u][i];         if (d[v] == -1) {           d[v] = d[u] + 1;           frontier.push(v);         }       }     }   }   int main() {     cin >> r >> c;     for (int i = 0; i < r; i++) {       for (int j = 0; j < c; j++) {         cin >> grid[i][j];       }     }     for (int i = 0; i < r; i++) {       for (int j = 0; j < c; j++) {         int cell = i * c + j;         if (grid[i][j] ==  T ) continue;         if (grid[i][j] ==  S )           s = cell;         else if (grid[i][j] ==  E )           e = cell;         if (grid[i - 1][j] !=  T  && i > 0) {           adj[cell].push_back(cell - c);           adj[cell - c].push_back(cell);         }         if (grid[i + 1][j] !=  T  && i < r - 1) {           adj[cell].push_back(cell + c);           adj[cell + c].push_back(cell);         }         if (grid[i][j - 1] !=  T  && j > 0) {           adj[cell].push_back(cell - 1);           adj[cell - 1].push_back(cell);         }         if (grid[i][j + 1] !=  T  && j < c - 1) {           adj[cell].push_back(cell + 1);           adj[cell + 1].push_back(cell);         }       }     }     memset(d, -1, sizeof(d));     bfs(e);     int shortest_path = d[s];     int ans = 0;     for (int i = 0; i < r * c; i++) {       char in = access(i);       if (in ==  T  || in ==  E  || in ==  S ) continue;       if (d[i] <= shortest_path && d[i] != -1) {         ans += in -  0 ;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   int in[100000 + 5];   bool doit() {     if (scanf( %d%d , &n, &m) != 2) return false;     for (int i = 0; i < n; ++i) in[i] = 0;     int x, y;     for (int i = 0; i < m; ++i) {       scanf( %d%d , &x, &y);       ++in[--x], ++in[--y];     }     sort(in, in + n);     if (in[0] == 1 && in[n - 2] == 1 && in[n - 1] == n - 1)       printf( star topology n );     else if (in[2] == 2 && in[n - 1] == 2) {       if (in[0] == 1 && in[1] == 1)         printf( bus topology n );       else if (in[0] == 2)         printf( ring topology n );       else         printf( unknown topology n );     } else       printf( unknown topology n );     return true;   }   int main() {     while (1)       if (!doit()) break;   }
#include <bits/stdc++.h>   using namespace std;   constexpr long long MOD = (long long)1e9 + 7;   long long fexp(long long a, long long n) {     a %= MOD;     if (n == 0) return 1;     long long ret = fexp(a * a % MOD, n / 2);     if (n % 2 == 1) ret = ret * a % MOD;     return ret;   }   long long blub(long long pa, long long pb) {     return pa * fexp((pa + pb) % MOD, MOD - 2) % MOD;   }   int main() {     long long k, pa, pb;     cin >> k >> pa >> pb;     long long ppa = blub(pa, pb);     long long ppb = blub(pb, pa);     vector<vector<long long>> dp(k + 1, vector<long long>(k, 0));     long long res = 0;     dp[1][0] = 1;     for (int i = 1; i < k; ++i) {       for (int j = 0; j < k; ++j) {         dp[i + 1][j] = (dp[i + 1][j] + dp[i][j] * ppa) % MOD;         if (j + i < k)           dp[i][j + i] = (dp[i][j + i] + dp[i][j] * ppb) % MOD;         else {           res = (res + (j + i) * dp[i][j] % MOD * ppb) % MOD;         }       }     }     for (int i = 0; i < k; ++i) {       res = (res + ppb * dp[k][i] % MOD *                        (ppa * fexp((1 - ppa) * (1 - ppa), MOD - 2) % MOD +                         (i + k) * fexp(1 - ppa, MOD - 2) % MOD)) %             MOD;     }     cout << (res % MOD + MOD) % MOD << endl;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> kmp(string &str) {     int n = str.size();     vector<int> res(n + 1);     res[0] = -1;     int ind = -1;     for (int i = 0; i < n; i++) {       while (ind >= 0 && str[i] != str[ind]) ind = res[ind];       ind++;       res[i + 1] = ind;     }     return res;   }   int nex(string &str, char ch, int i, vector<int> &kmp1) {     if (str[i] == ch) return i + 1;     int res = i;     while (res >= 0 && str[res] != ch) res = kmp1[res];     return res + 1;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     string s, s1, s2;     cin >> s >> s1 >> s2;     int n = s.size(), n1 = s1.size(), n2 = s2.size();     vector<int> kmp1 = kmp(s1), kmp2 = kmp(s2);     vector<vector<vector<int>>> dp(         n + 1, vector<vector<int>>(n1 + 1, vector<int>(n2 + 1, -(1 << 29))));     dp[0][0][0] = 0;     for (int i = 0; i < n; i++) {       if (s[i] ==  * ) {         for (char ch =  a ; ch <=  z ; ch++) {           for (int j = 0; j < n1; j++) {             for (int k = 0; k < n2; k++) {               int nj = nex(s1, ch, j, kmp1), nk = nex(s2, ch, k, kmp2);               dp[i + 1][nj][nk] = max(dp[i + 1][nj][nk], dp[i][j][k]);             }           }         }       } else {         char ch = s[i];         for (int j = 0; j < n1; j++) {           for (int k = 0; k < n2; k++) {             int nj = nex(s1, ch, j, kmp1), nk = nex(s2, ch, k, kmp2);             dp[i + 1][nj][nk] = max(dp[i + 1][nj][nk], dp[i][j][k]);           }         }       }       int nj = kmp1[n1], nk = kmp2[n2];       for (int j = 0; j < n1; j++) {         dp[i + 1][j][nk] = max(dp[i + 1][j][nk], dp[i + 1][j][n2] - 1);       }       for (int k = 0; k < n2; k++) {         dp[i + 1][nj][k] = max(dp[i + 1][nj][k], dp[i + 1][n1][k] + 1);       }       dp[i + 1][nj][nk] = max(dp[i + 1][nj][nk], dp[i + 1][n1][n2]);     }     int res = -(1 << 29);     for (int j = 0; j < n1; j++) {       for (int k = 0; k < n2; k++) {         res = max(res, dp[n][j][k]);       }     }     cout << res <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       int a[n];       for (int i = 0; i < n; i++) {         cin >> a[i];       }       sort(a, a + n, greater<int>());       for (int i = 0; i < n; i++) cout << a[i] <<    ;       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   int main() {     int n, d, t, x, y, z, m;     scanf( %d %d %d , &n, &d, &m);     z = n - d;     while (m--) {       scanf( %d %d , &x, &y);       if (x > n || y > n) {         printf( NO n );       } else {         if (y >= abs(x - d) && y <= n - (abs(z - x))) {           printf( YES n );         } else {           printf( NO n );         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 5e3 + 10, mod = 1e9 + 7;   int fact[N], invfact[N];   inline int add(int x, int y) {     x += y;     if (x >= mod) x -= mod;     return x;   }   inline int sub(int x, int y) {     x -= y;     if (x < 0) x += mod;     return x;   }   inline int mul(int x, int y) { return (((long long)x) * y) % mod; }   inline int powr(int a, long long b) {     int x = 1 % mod;     while (b) {       if (b & 1) x = mul(x, a);       a = mul(a, a);       b >>= 1;     }     return x;   }   inline int inv(int a) { return powr(a, mod - 2); }   void pre() {     fact[0] = invfact[0] = 1;     for (int i = 1; i < N; i++) fact[i] = mul(i, fact[i - 1]);     invfact[N - 1] = inv(fact[N - 1]);     for (int i = N - 2; i >= 1; i--) invfact[i] = mul(invfact[i + 1], i + 1);     assert(invfact[1] == 1);   }   inline int C(int n, int k) {     if (n < k || k < 0) return 0;     return mul(fact[n], mul(invfact[k], invfact[n - k]));   }   int n, k;   int C2[N + 10], A[N], E[N];   inline int getC2(int i) {     if (i > k) return 0;     return C2[i];   }   int F[N][N];   int main() {     pre();     cin >> n >> k;     F[0][0] = 1;     for (int i = 1; i <= n; i++) {       F[i][0] = 1;       cin >> A[i];       for (int j = 1; j <= i; j++) {         F[i][j] = add(F[i - 1][j], mul(A[i], F[i - 1][j - 1]));       }     }     C2[0] = 1;     for (int i = 1; i <= n + 10; i++)       C2[i] = mul(C2[i - 1], mul(k - i + 1, inv(i)));     int invn = inv(n);     int _div = 1;     for (int i = 0; i <= n - 1; i++) {       E[i] = mul(getC2(i + 1), _div);       _div = mul(_div, invn);       E[i] = mul(E[i], fact[i]);     }     int ans = 0;     for (int i = 0; i <= n - 1; i++) {       ans = add(           ans,           mul(F[n][i], mul(n - i, mul(powr(mod - 1, n - 1 - i), E[n - 1 - i]))));     }     ans = mul(ans, invn);     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline bool chmax(T &a, T b) {     if (a < b) {       a = b;       return true;     }     return false;   }   template <class T>   inline bool chmin(T &a, T b) {     if (a > b) {       a = b;       return true;     }     return false;   }   const long long INF = 1e18;   long long N;   long long a[1050];   vector<string> ans, trueans;   vector<vector<int>> Prev, Next;   void f(int item) {     int idx1 = 0;     int idx2 = 1;     Next.clear();     for (auto v : Prev) {       if (v.size() <= 1) continue;       idx1 = v[0];       idx2 = v[1];     }     ans[idx1][item] =  1 ;     ans[idx2][item] =  0 ;     long long one = a[item] - 1;     for (int i = 0; i <= N; i++) {       if (i == idx2 or i == idx1) continue;       if (one) {         one--;         ans[i][item] =  1 ;       } else {         ans[i][item] =  0 ;       }     }     for (auto v : Prev) {       vector<int> u[2];       for (auto tmp : v) {         if (ans[tmp][item] ==  0 )           u[0].push_back(tmp);         else           u[1].push_back(tmp);       }       for (int i = 0; i < 2; i++) {         if (u[i].size()) Next.push_back(u[i]);       }     }     swap(Prev, Next);   }   int main() {     cin >> N;     for (int i = 0; i < N; i++) cin >> a[i];     ans.resize(N + 1, string(N,  0 ));     Prev.push_back({});     for (int i = 0; i <= N; i++) {       Prev[0].push_back(i);     }     for (int i = 0; i < N; i++) f(i);     for (auto v : Prev) {       assert(v.size() == 1);     }     for (auto s : ans) {       if (s != string(N,  0 )) trueans.push_back(s);     }     cout << trueans.size() <<   n ;     for (auto s : trueans) {       cout << s <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int n;     cin >> n;     map<long long int, long long int> mp;     vector<long long int> v(n);     vector<long long int> cSum(n, 0);     for (long long int i = 0; i < n; i++) {       cin >> v[i];       mp[v[i]]++;     }     cSum[0] = v[0];     for (long long int i = 1; i < n; i++) {       cSum[i] = cSum[i - 1] + v[i];     }     if (cSum[n - 1] % 2 != 0) {       cout <<  NO ;     } else {       int flag2 = 0;       set<long long int> st;       for (long long int i = 0; i < n; i++) {         mp[v[i]]--;         long long int sum1 = cSum[i];         long long int sum2 = cSum[n - 1] - cSum[i];         long long int t = sum1 + sum2;         long long int each = t / 2;         if (each == sum1 && each == sum2) {           flag2 = 1;           break;         }         if (sum1 < sum2) {           long long int diff = each - sum1;           if (mp[diff] > 0) {             flag2 = 1;             break;           }         }         if (sum1 > sum2) {           long long int diff = each - sum2;           if (st.find(diff) != st.end()) {             flag2 = 1;             break;           }         }         st.insert(v[i]);       }       if (flag2 == 0) {         cout <<  NO ;       } else {         cout <<  YES ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n;   pair<string, long long> s[1000005];   long long m;   bool cmp(pair<string, long long> a, pair<string, long long> b) {     string s = a.first, t = b.first;     for (long long i = 0; i < (m); i++)       if (s[i] != t[i]) {         if (i & 1)           return s[i] > t[i];         else           return s[i] < t[i];       }     return a.second < b.second;   }   signed main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> m;     for (long long i = 0; i < (n); i++) cin >> s[i].first, s[i].second = i + 1;     sort(s, s + n, cmp);     for (long long i = 0; i < (n); i++) cout << s[i].second <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   bool umin(T& a, T b) {     if (a > b) {       a = b;       return 1;     }     return 0;   }   template <class T>   bool umax(T& a, T b) {     if (a < b) {       a = b;       return 1;     }     return 0;   }   char s[1000009], t[1000009];   int cnt[2];   int pw[1000009], par[1000009];   int wp[1000009], rap[1000009];   int mod(long long x) {     x %= 1000000007;     if (x < 0) x += 1000000007;     return x;   }   pair<int, int> get(int l, int r) {     return make_pair(mod(par[r] - (par[l - 1] * 1LL * pw[r - l + 1])),                      mod(rap[r] - (rap[l - 1] * 1LL * wp[r - l + 1])));   }   int main() {     scanf( %s , s);     int n = strlen(s);     scanf( %s , t + 1);     int m = strlen(t + 1);     pw[0] = wp[0] = 1;     for (int i = 1; i < 1000009; i++) {       pw[i] = mod(pw[i - 1] * 27LL);       wp[i] = mod(wp[i - 1] * 31LL);     }     for (int i = 1; i <= m; i++) {       par[i] = mod(par[i - 1] * 27LL + (t[i] -  a  + 1));       rap[i] = mod(rap[i - 1] * 31LL + (t[i] -  a  + 1));     }     for (int i = 0; i < n; i++) cnt[s[i] -  0 ]++;     int ans = 0;     for (int i = 1; i * cnt[0] < m and i < m; i++)       if ((m - i * cnt[0]) % cnt[1] == 0) {         int d = (m - i * cnt[0]) / cnt[1];         pair<int, int> a, b;         a.first = b.first = -1;         int cur = 1, f = 1;         for (int j = 0; j < n; j++) {           if (s[j] ==  0 ) {             if (a.first == -1)               a = get(cur, cur + i - 1);             else               f &= (a == get(cur, cur + i - 1));             cur += i;           } else {             if (b.first == -1)               b = get(cur, cur + d - 1);             else               f &= (b == get(cur, cur + d - 1));             cur += d;           }         }         if (f and d == i and a == b) f = 0;         ans += f;       }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   long long t, a, b, h, f[110];   using namespace std;   long long mi(long long n, long long m) {     long long res = 1;     for (int i = 1; i <= m; i++) res *= n;     return res;   }   void solve(long long a, long long b) {     for (int i = h; i; i--) {       long long t = mi(a, i);       f[i] = b / t;       b %= t;     }     f[0] = b;   }   int main() {     scanf( %lld%lld%lld , &t, &a, &b);     if (a == b && b == t) {       if (a == 1)         puts( inf );       else         puts( 2 );     } else if (a == b)       puts( 1 );     else {       if (t == 1) {         h = log(b) / log(a);         for (int i = 1; i <= h; i++)           if (mi(a, i) == b) {             puts( 1 );             return 0;           }       }       h = log(b) / log(a);       solve(a, b);       long long sum = 0;       for (int i = 0; i <= h; i++) sum += f[i] * mi(t, i);       if (sum != a)         puts( 0 );       else         puts( 1 );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long n;     cin >> n;     vector<pair<long long, long long>> arr(n);     for (long long i = 0; i < n; i++) {       long long a;       cin >> a;       if (a >= 0) a = (-1) * a - 1;       arr[i] = {a, i};     }     sort(arr.begin(), arr.end());     if (n % 2 == 1) {       long long f = 0;       for (long long i = 0; i < n; i++) {         if (arr[i].first != -1) {           arr[i].first = (-1) * arr[i].first - 1;           f++;           break;         }       }       if (f == 0) {         arr[0].first = 0;       }     }     vector<long long> ans(n);     for (long long i = 0; i < n; i++) {       ans[arr[i].second] = arr[i].first;     }     for (auto i : ans) cout << i <<    ;     cout << endl;   }