malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   double p[210];   int a[210];   double dp[210][210][210];   int main(void) {     int N, L, K, i, j, k;     cin >> N >> L >> K;     for ((i) = 0; (i) < (int)(N); (i)++) cin >> p[i];     for ((i) = 0; (i) < (int)(N); (i)++) cin >> a[i];     for ((i) = 0; (i) < (int)(N); (i)++) p[i] /= 100.0;     dp[0][0][0] = 1.0;     for ((i) = 0; (i) < (int)(N); (i)++)       for ((j) = 0; (j) < (int)(i + 1); (j)++)         for ((k) = 0; (k) < (int)(N + 1); (k)++) {           int c = a[i] + 1;           dp[i + 1][j + 1][min(k + c, N)] += dp[i][j][k] * p[i];           dp[i + 1][j][k] += dp[i][j][k] * (1.0 - p[i]);         }     double ans = 0.0;     for ((i) = 0; (i) < (int)(N + 1); (i)++)       for ((j) = 0; (j) < (int)(N + 1); (j)++)         if (i >= L && K + j - i >= 0) ans += dp[N][i][j];     printf( %.9f n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool F = true;   long long sum = 0;   void DFS(int v, int par, vector<vector<int>> &g, vector<long long> &s,            vector<long long> &a) {     if (s[v] == -1) {       if (g[v].size() == 0) return;       long long m = 2e9;       for (int u : g[v]) m = min(s[u], m);       a[v] = m - s[par];       if (a[v] < 0) {         F = false;       }       for (int u : g[v]) a[u] = s[u] - m;     }     sum += a[v];     for (int u : g[v]) DFS(u, v, g, s, a);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     int n;     cin >> n;     vector<vector<int>> g(n);     vector<long long> s(n), a(n);     for (int i = 1; i < n; ++i) {       int p;       cin >> p;       g[p - 1].push_back(i);     }     for (int i = 0; i < n; ++i) {       cin >> s[i];     }     a[0] = s[0];     DFS(0, 0, g, s, a);     if (!F) {       cout << -1 <<   n ;     } else {       cout << sum <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline void remax(T& A, T B) {     if (A < B) A = B;   }   template <class T>   inline void remin(T& A, T B) {     if (A > B) A = B;   }   string ToString(long long num) {     string ret;     do {       ret += ((num % 10) +  0 );       num /= 10;     } while (num);     reverse(ret.begin(), ret.end());     return ret;   }   long long ToNumber(string s) {     long long r = 0, p = 1;     for (int i = s.size() - 1; i >= 0; --i) r += (s[i] -  0 ) * p, p *= 10;     return r;   }   long long Gcd(long long a, long long b) {     while (a %= b ^= a ^= b ^= a)       ;     return b;   }   long long Power(long long base, long long power) {     long long ret = 1;     while (power) {       if (power & 1) ret *= base;       power >>= 1;       base *= base;     }     return ret;   }   long long PowerMod(long long base, long long power, long long mod) {     if (!power) return 1;     if (power & 1) return (base * PowerMod(base, power - 1, mod)) % mod;     return PowerMod((base * base) % mod, power >> 1, mod);   }   int Log(long long num, long long base) {     int ret = 0;     while (num) {       ++ret;       num /= base;     }     return ret;   }   int Count(long long mask) {     int ret = 0;     while (mask) {       if (mask & 1) ++ret;       mask >>= 1;     }     return ret;   }   inline void run() {     int n, k, ans, sum;     scanf( %d%d , &n, &k);     ans = n, sum = (n << 1);     while (true) {       if (sum >= k) break;       if (!n) break;       --ans, ++sum, --n;     }     printf( %d n , ans);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr), cout.tie(nullptr);     run();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 1005;   map<pair<int, int>, int> mapa;   int main() {     int n, h, m;     scanf( %d , &n);     int c = 0;     for (int i = 0; i < n; i++) {       scanf( %d%d , &h, &m);       int x = ++mapa[make_pair(h, m)];       if (x > c) c = x;     }     printf( %d n , c);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1001000;   int n;   void add(long long* a, int x, long long y) {     for (; x <= n; x += x & -x) a[x] += y;   }   long long gsm(long long* a, int x) {     long long ret = 0;     for (; x; x &= x - 1) ret += a[x];     return ret;   }   long long sum0[N], sum1[N];   void mdf(int x, int y) {     add(sum0, x, y);     add(sum1, x, (long long)(1 - x) * y);   }   void modify(int l, int r, int x) {     mdf(l, x);     if (r < n) mdf(r + 1, -x);   }   long long query(int x) { return gsm(sum0, x) * x + gsm(sum1, x); }   vector<int> vec[N];   int q[N], l[N], r[N], a[N], m;   long long ans[N];   void solve() {     for (int i = 1; i <= m; ++i) vec[l[i]].push_back(i);     q[0] = n + 1;     for (int i = n, j = 0; i; --i) {       for (; j && a[q[j]] < a[i]; --j)         ;       modify(i, q[j] - 1, 1);       q[++j] = i;       for (int t : vec[i]) ans[t] += query(r[t]);     }     for (int i = 1; i <= n; ++i) vec[i].clear(), sum0[i] = sum1[i] = 0;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> m;     for (int i = 1; i <= n; ++i) cin >> a[i];     for (int i = 1; i <= m; ++i) cin >> l[i];     for (int i = 1; i <= m; ++i) cin >> r[i];     solve();     for (int i = 1; i <= m; ++i)       l[i] = n + 1 - l[i], r[i] = n + 1 - r[i], swap(l[i], r[i]);     reverse(a + 1, a + n + 1);     solve();     for (int i = 1; i <= m; ++i)       ans[i] -= r[i] - l[i] + 1, cout << ans[i] <<    n [i == m];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int const MAXN = 5e5 + 10;   int n, a[MAXN], ans;   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     for (int i = 1; i < n; i++) {       if (a[i] != a[i + 1]) {         int pt = i + 1, tam = 1;         while (a[pt] != a[pt + 1] && pt != n) pt++, tam++;         if (a[i] == a[pt])           for (int j = i; j <= pt; j++) a[j] = a[i];         else {           tam--;           for (int j = i; j <= i + tam / 2; j++) a[j] = a[i];           for (int j = i + tam / 2 + 1; j <= pt; j++) a[j] = a[pt];         }         ans = max(ans, tam / 2);       }     }     printf( %d n , ans);     for (int i = 1; i <= n; i++) printf( %d  , a[i]);     printf(  n );   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     cin.sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     long long n, m;     cin >> n >> m;     vector<long long> v(n);     for (long long i = 0; i < n; i++) cin >> v[i];     vector<long long> dp(n);     dp[0] = v[0];     for (long long i = 1; i < dp.size(); i++) {       dp[i] = v[i] + dp[i - 1];     }     for (long long i = 0; i < n; i++) {       vector<long long> temp;       long long ans = 0;       for (long long j = 0; j < i; j++) {         temp.push_back(v[j]);       }       if (temp.size() > 0) {         sort(temp.rbegin(), temp.rend());       }       long long timereq = v[i];       long long timeleft = m;       long long in = 0;       if (i > 0) {         timeleft = m - dp[i - 1];       }       while (true) {         if (timeleft >= timereq) break;         timeleft = timeleft + temp[in];         in++;         ans++;       }       cout << ans <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   int n, m, i, j, k, use[200010], culoare[200010], v[200010], x, y, a;   vector<int> v2[200010];   vector<pair<int, int> > G[200010];   void DF(int nod) {     use[nod] = 1;     for (auto it : G[nod]) {       if (!use[it.first]) {         if (it.second == 1) {           culoare[it.first] = culoare[nod];         } else {           culoare[it.first] = 1 - culoare[nod];         }         DF(it.first);       } else {         if (it.second == 1) {           if (culoare[it.first] != culoare[nod]) {             cout <<  NO ;             exit(0);           }         } else {           if (culoare[it.first] != 1 - culoare[nod]) {             cout <<  NO ;             exit(0);           }         }       }     }   }   int main() {     cin >> n >> m;     for (i = 1; i <= n; i++) cin >> v[i];     for (i = 1; i <= m; i++) {       cin >> x;       for (j = 1; j <= x; j++) {         cin >> a;         v2[a].push_back(i);       }     }     for (i = 1; i <= n; i++) {       G[v2[i][0]].push_back({v2[i][1], v[i]});       G[v2[i][1]].push_back({v2[i][0], v[i]});     }     for (i = 1; i <= m; i++) {       if (!use[i]) {         culoare[i] = 1;         DF(i);       }     }     cout <<  YES ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct Tans {     long a;     long b;   };   struct mstr {     long num;     long val;   };   bool operator<(mstr a, mstr b) { return a.val < b.val; }   bool operator>(mstr a, mstr b) { return a.val > b.val; }   bool operator==(mstr a, mstr b) { return a.val == b.val; }   int main() {     long n, s;     cin >> n >> s;     vector<mstr> cards(n);     vector<Tans> ress;     priority_queue<mstr> q;     ress.reserve(n);     for (long i = 0; i < n; i++) {       cin >> cards[i].val;       cards[i].num = i + 1;       if (cards[i].val) q.push(cards[i]);     }     bool f = true;     vector<mstr> temp;     while (q.size() != 0 && f) {       temp.resize(0);       temp.reserve(q.size());       mstr now = q.top();       q.pop();       if (q.size() < now.val)         f = false;       else {         mstr tt;         Tans ttt;         ttt.a = now.num;         while (now.val != 0) {           tt = q.top();           q.pop();           now.val--;           tt.val--;           ttt.b = tt.num;           temp.push_back(tt);           ress.push_back(ttt);         }         for (long j = 0; j < temp.size(); j++)           if (temp[j].val > 0) q.push(temp[j]);       }     }     if (f == false)       cout <<  No ;     else {       cout <<  Yes n  << ress.size() <<   n ;       for (long i = 0; i < ress.size(); i++)         cout << ress[i].a <<     << ress[i].b <<   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, i, sum = 0;     cin >> n;     long long int a[n];     for (i = 0; i < n; i++) {       cin >> a[i];       sum = sum + a[i];     }     sort(a, a + n);     i = 0;     while (1) {       if (sum % 2 == 0) {         cout << sum;         break;       } else {         if (a[i] % 2 == 1) {           sum = sum - a[i];         } else {           i++;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, *animals, i, j, temp;     bool turn = 0;     cin >> n;     animals = new int[n];     for (i = 0; i < n; i++) cin >> animals[i];     vector<pair<int, int> > segmant;     pair<int, int> seg;     for (i = 0; i < (n - 1); i++) {       if (animals[i] > animals[i + 1]) {         turn = 1;         seg.first = (i + 1);         temp = animals[i];         animals[i] = animals[i + 1];         animals[i + 1] = temp;         i += 2;         for (j = i; j < n - 1; j++) {           if (animals[j] > animals[j + 1]) {             temp = animals[j];             animals[j] = animals[j + 1];             animals[j + 1] = temp;             j++;             continue;           } else {             break;           }         }         seg.second = j;       }       if (turn == true) {         segmant.push_back(seg);         i = -1;         turn = 0;       }     }     for (i = 0; i < segmant.size(); i++) {       cout << segmant[i].first <<     << segmant[i].second << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long LLINF = 1e18 + 7;   const long long INF = 1e9 + 7;   const long long EPS = 1e-9 - 7;   const long long MAX = 1e2 + 7;   const long long MOD = 1e9 + 7;   int n, d, dp[MAX];   string s;   bool can[MAX], flag = false;   int main() {     memset(dp, MAX, sizeof dp);     cin >> n >> d >> s;     for (int i = 0; i < n; i++) {       if (s[i] ==  1 ) {         can[i + 1] = true;       }     }     for (int i = n - 1; i >= 1; i--) {       if (n - i <= d && can[i]) {         flag = true;         dp[i] = 1;       }     }     if (!flag) {       cout << -1 << endl;       return 0;     }     for (int i = n - 1; i >= 1; i--) {       for (int j = i - 1; j >= 1; j--) {         if (i - j <= d && can[j] && can[i]) {           dp[j] = min(dp[j], dp[i] + 1);         }       }     }     if (dp[1] >= n) {       cout << -1 << endl;       return 0;     }     cout << dp[1] << endl;     return 0;   }
/*       Mbak Sana Dong       Mbak Chaeyoung Dong       Mbak Eunha Dong       Mbak Seulgi Dong       Mbak Wendy Dong       Stream https://www.youtube.com/watch?v=LmBYPXGqtss   */   #pragma GCC optimize( Ofast )   #pragma GCC target( avx,avx2,fma )   #pragma GCC optimization ( unroll-loops,O3 )   #include<bits/stdc++.h>   #define ll long long   using namespace std;   int main()   {       int n,m,i,j,k,x,y,ans,curr,temp,q;       int tc;       cin >> tc;       while(tc--) {           string s;           cin >> s;           n = s.length();           s =     + s;           vector<int> cnt(30, 0), vis(30, 0);           for(i=1;i<=n;i++) {               cnt[s[i] -  a ]++;           }              stack<char> st;              for(i=1;i<=n;i++) {               curr = s[i] -  a ;               if(vis[curr]) {                   cnt[curr]--;                   continue;               }                  while(!st.empty() && cnt[st.top() -  a ] > 0 && st.top() < s[i]) {                   vis[st.top() -  a ] = 0;                   st.pop();               }                  st.push(s[i]);               cnt[curr]--;               vis[curr] = 1;           }              string eunha =   ;           while(!st.empty()) {               eunha += st.top();               st.pop();           }              reverse(eunha.begin(), eunha.end());           cout << eunha << endl;       }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   int min(int a, int b) { return a > b ? b : a; }   int main() {     int n, m;     cin >> n >> m;     cout << min(n, m) + 1 << endl;     for (int i = 0; i <= min(n, m); i++)       cout << i <<     << min(n, m) - i << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize(2)   using namespace std;   const int inf = 0x3f3f3f3f;   const long long INF = 0x3f3f3f3f3f3f3f3f;   char buf[1 << 21], *p1 = buf, *p2 = buf;   inline int gc() {     return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2)                ? EOF                : *p1++;   }   inline int read() {     int ret = 0, f = 0;     char c = gc();     while (!isdigit(c)) {       if (c ==  - ) f = 1;       c = gc();     }     while (isdigit(c)) {       ret = ret * 10 + c - 48;       c = gc();     }     if (f) return -ret;     return ret;   }   int sign(double x) {     if (x > 1e8)       return 1;     else if (x < -1e8)       return -1;     else       return 0;   }   const int maxn = 1e6 + 10;   int a[maxn];   pair<double, int> st[maxn];   double pre[maxn];   int precnt[maxn];   int top;   int erfen(int l, int r, double val) {     while (l + 1 < r) {       int mid = l + r >> 1;       if ((pre[top] - pre[mid - 1] + val) * 1.0 /               (precnt[top] - precnt[mid - 1] + 1) <=           st[mid].first)         r = mid;       else         l = mid;     }     return r;   }   int main() {     int n;     scanf( %d , &n);     for (int i = (1); i <= (n); i++) {       scanf( %d , &a[i]);     }     st[++top] = make_pair(a[1] * 1.0, 1);     pre[top] = a[1];     precnt[top] = 1;     for (int i = (2); i <= (n); i++) {       if (a[i] * 1.0 == st[top].first) {         st[top].second++;         pre[top] += a[i];         precnt[top]++;       } else if (a[i] * 1.0 > st[top].first) {         st[++top] = make_pair(a[i] * 1.0, 1);         pre[top] = pre[top - 1] + a[i];         precnt[top] = precnt[top - 1] + 1;       } else {         int id = erfen(0, top + 1, a[i]);         int cnt = (precnt[top] - precnt[id - 1] + 1);         double tmp = pre[top] - pre[id - 1] + a[i];         double evenly = (pre[top] - pre[id - 1] + a[i]) * 1.0 /                         (precnt[top] - precnt[id - 1] + 1);         top = id;         st[top].first = evenly;         st[top].second = cnt;         pre[top] = pre[top - 1] + tmp;         precnt[top] = precnt[top - 1] + cnt;       }     }     for (int i = (1); i <= (top); i++) {       for (int j = (1); j <= (st[i].second); j++) {         printf( %.9f n , st[i].first);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, a, b;   int x[205], y[205], c[205], siz[75], ans[75];   int info[75], Prev[205 << 1], to[205 << 1], cst[205 << 1], cnt_e;   void Node(int u, int v, int ct) {     Prev[++cnt_e] = info[u], info[u] = cnt_e, to[cnt_e] = v, cst[cnt_e] = ct;   }   int F[75], bl[75], cnt;   int Find(int now) {     return (!F[now] || F[now] == now) ? now : F[now] = Find(F[now]);   }   int dp[1 << 18][75];   int main() {     scanf( %d%d%d%d , &n, &m, &a, &b);     for (int i = 1; i <= n; i++) siz[i] = 1;     for (int i = 1; i <= m; i++) {       scanf( %d%d%d , &x[i], &y[i], &c[i]);       if (c[i] == a)         if (Find(x[i]) != Find(y[i])) {           siz[Find(y[i])] += siz[Find(x[i])];           F[Find(x[i])] = Find(y[i]);         }       Node(x[i], y[i], c[i]), Node(y[i], x[i], c[i]);     }     for (int i = 1; i <= n; i++)       if (siz[i] > 3 && Find(i) == i)         bl[i] = cnt++;       else if (Find(i) == i)         bl[i] = -1;     for (int i = 1; i <= n; i++)       if (Find(i) != i) bl[i] = bl[Find(i)];     memset(dp, 0x3f, sizeof dp);     memset(ans, 0x3f, sizeof ans);     dp[bl[1] >= 0 ? 1 << bl[1] : 0][1] = 0;     queue<int> q;     for (int i = 0; i < (1 << cnt); i++) {       for (int j = 1; j <= n; j++)         if (dp[i][j] < 0x3f3f3f3f) q.push(j);       for (int now; !q.empty();) {         now = q.front(), q.pop();         for (int j = info[now]; j; j = Prev[j])           if (cst[j] == a ||               (cst[j] == b && bl[to[j]] == -1 && Find(now) != Find(to[j]))) {             if (dp[i][to[j]] > dp[i][now] + cst[j]) {               dp[i][to[j]] = dp[i][now] + cst[j];               q.push(to[j]);             }           } else if (Find(now) != Find(to[j]) && !(i >> bl[to[j]] & 1))             dp[i | (1 << bl[to[j]])][to[j]] =                 min(dp[i | (1 << bl[to[j]])][to[j]], dp[i][now] + cst[j]);       }       for (int j = 1; j <= n; j++)         if (dp[i][j] < 0x3f3f3f3f) ans[j] = min(ans[j], dp[i][j]);     }     for (int i = 1; i <= n; i++) printf( %d%c , ans[i], i == n ?   n  :    );   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     vector<pair<int, int>> v(n);     for (auto &x : v) cin >> x.first >> x.second;     if (is_sorted(v.rbegin(), v.rend())) {       bool ok = true;       for (auto x : v)         if (x.first != x.second) ok = false;       if (ok) {         cout <<  maybe n ;         return 0;       }     }     for (auto x : v)       if (x.first != x.second) {         cout <<  rated n ;         return 0;       }     cout <<  unrated n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int inf = (1 << 29) - 1;   int n, m, S, T, ans;   int a[20000], b[20];   struct edge {     int b, len;     edge *nxt, *op;   } e[100000], *le(e);   edge *head[20000];   void add(int u, int v, int w) {     le->b = v, le->len = w, le->nxt = head[u], le->op = le + 1, head[u] = le++;     le->b = u, le->len = 0, le->nxt = head[v], le->op = le - 1, head[v] = le++;   }   edge *cur[20000], *pre[20000];   int low[20000], dis[20000], gap[20000];   void init() {     int g, v, w, k, p, q;     scanf( %d%d%d , &n, &m, &g);     S = 0, T = n + m + 1;     for (int i = 1; i <= (n); ++i) scanf( %d , &a[i]);     for (int i = 1; i <= (n); ++i) {       scanf( %d , &v);       if (a[i])         add(i, T, v);       else         add(S, i, v);     }     for (int i = 1; i <= (m); ++i) {       scanf( %d%d%d , &p, &w, &k);       for (int j = 1; j <= (k); ++j) scanf( %d , &b[j]);       scanf( %d , &q);       ans += w;       if (q) w += g;       if (p) {         for (int j = 1; j <= (k); ++j) add(b[j], n + i, inf);         add(n + i, T, w);       } else {         add(S, n + i, w);         for (int j = 1; j <= (k); ++j) add(n + i, b[j], inf);       }     }   }   int SAP() {     int flow(0);     low[S] = inf, gap[0] = T + 1;     for (int i = (S); i <= (T); ++i) dis[i] = 0, cur[i] = head[i];     edge *i;     int u(S), v;     while (dis[S] < T + 5) {       for (i = cur[u]; i; i = i->nxt)         if (i->len && dis[v = i->b] + 1 == dis[u]) break;       if (i) {         cur[u] = i;         pre[v] = i;         low[v] = min(low[u], i->len);         if ((u = v) == T) {           for (; u != S; u = pre[u]->op->b) {             pre[u]->len -= low[T];             pre[u]->op->len += low[T];           }           flow += low[T];         }       } else {         cur[u] = head[u];         if (--gap[dis[u]] == 0) break;         dis[u] = T + 5;         for (i = cur[u]; i; i = i->nxt)           if (i->len && dis[i->b] + 1 < dis[u]) dis[u] = dis[i->b] + 1;         ++gap[dis[u]];         if (u != S) u = pre[u]->op->b;       }     }     return flow;   }   int main() {     init();     ans -= SAP();     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dist[2005][2005];   char f[2005][2005];   int n, m, r, c, x, y;   int main() {     scanf( %d%d%d%d%d%d , &n, &m, &r, &c, &x, &y);     x = min(x, 10000000);     y = min(y, 10000000);     r--;     c--;     for (int i = 0; i < n; i++) scanf( %s , &f[i]);     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) dist[i][j] = 1000000000;     dist[r][c] = 0;     deque<pair<int, pair<int, int> > > que;     que.push_back(make_pair(0, make_pair(r, c)));     while (!que.empty()) {       pair<int, pair<int, int> > p = que.front();       que.pop_front();       if (p.first != dist[p.second.first][p.second.second]) continue;       int X = p.second.first, Y = p.second.second;       int dx[4] = {0, 1, 0, -1};       int dy[4] = {1, 0, -1, 0};       for (int k = 0; k < 4; k++) {         int nx = X + dx[k], ny = Y + dy[k];         if (!(0 <= nx && nx < n && 0 <= ny && ny < m)) continue;         if (f[nx][ny] ==  * ) continue;         int add = (k == 2);         if (dist[nx][ny] > p.first + add) {           dist[nx][ny] = p.first + add;           if (add == 0)             que.push_front(make_pair(p.first + add, make_pair(nx, ny)));           else             que.push_back(make_pair(p.first + add, make_pair(nx, ny)));         }       }     }     int ans = 0;     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) {         int mnx = dist[i][j];         int mny = j + dist[i][j] - c;         if (mnx <= x && mny <= y) ans++;       }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long judge(long long mid) {     long long b;     long long cnt = 0;     for (b = 2;; b++) {       cnt += mid / b / b / b;       if (mid / b / b / b == 0) break;     }     return cnt;   }   int main() {     long long m;     cin >> m;     long long r = 1e16, l = 0;     while (l < r - 1) {       long long mid = (l + r) / 2;       if (judge(mid) >= m)         r = mid;       else         l = mid;     }     if (judge(l) == m)       cout << l << endl;     else if (judge(r) == m)       cout << r << endl;     else       cout <<  -1  << endl;     return 0;   }