malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 212345;   int seg[4 * N], v[N], tin[N], tout[N], ans[N];   int a, b, n, q;   void init(int r, int i, int j) {     if (i == j) {       seg[r] = v[i];     } else {       init(2 * r, i, (i + j) / 2);       init(2 * r + 1, (i + j) / 2 + 1, j);       seg[r] = min(seg[2 * r], seg[2 * r + 1]);     }   }   int query(int r, int i, int j) {     if (b < i || a > j) return 0x3f3f3f3f;     if (i >= a && j <= b) {       return seg[r];     } else {       int L = query(2 * r, i, (i + j) / 2);       int R = query(2 * r + 1, (i + j) / 2 + 1, j);       return min(L, R);     }   }   void update(int r, int i, int j, int pos, int val) {     if (pos < i || pos > j) return;     if (i == j) {       seg[r] = val;     } else {       update(2 * r, i, (i + j) / 2, pos, val);       update(2 * r + 1, (i + j) / 2 + 1, j, pos, val);       seg[r] = min(seg[2 * r], seg[2 * r + 1]);     }   }   set<int> zeros;   int main(void) {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> n >> q;     int mx = 0;     for (int i = 1; i <= n; i++) {       cin >> v[i];       if (v[i] == 0) {         zeros.emplace(i);         v[i] = 0x3f3f3f3f;       } else {         if (tin[v[i]] == 0) tin[v[i]] = i;         tout[v[i]] = i;         mx = max(mx, v[i]);       }     }     if (zeros.size() == n) {       cout <<  YES  << endl;       for (int i = 1; i <= n; i++) cout << q <<    ;       cout << endl;       return 0;     }     if (mx != q and zeros.size() == 0) {       cout <<  NO  << endl;       return 0;     }     init(1, 1, n);     if (mx != q and zeros.size()) {       auto it = zeros.begin();       update(1, 1, n, *it, q);       zeros.erase(it);     }     for (int i = q; i >= 1; i--) {       if (tin[i] == 0) continue;       a = tin[i];       b = tout[i];       if (query(1, 1, n) < i) {         cout <<  NO  << endl;         return 0;       }       auto it = zeros.lower_bound(tin[i]);       while (it != zeros.end() and *it <= tout[i]) {         update(1, 1, n, *it, i);         it = zeros.erase(it);       }     }     for (int i = 1; i <= n; i++) {       a = i;       b = i;       ans[i] = query(1, 1, n);     }     for (int i = 2; i <= n; i++) {       if (ans[i] == 0x3f3f3f3f and ans[i - 1] != 0x3f3f3f3f) ans[i] = ans[i - 1];     }     for (int i = n - 1; i >= 1; i--) {       if (ans[i] == 0x3f3f3f3f and ans[i + 1] != 0x3f3f3f3f) ans[i] = ans[i + 1];     }     cout <<  YES  << endl;     for (int i = 1; i <= n; i++) {       assert(ans[i] != 0x3f3f3f3f);       cout << ans[i] <<    ;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long maxn = 2e6 + 7;   const long long mod = 1e9 + 7;   const long long INF = 3e18 + 315;   vector<pair<long long, long long> > va, vb;   long long n, s, ans, na, nb, ta, tb;   int32_t main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     cin >> n >> s;     for (long long i = 0; i < n; i++) {       long long num, a, b;       cin >> num >> a >> b;       if (a > b) {         ans += num * a;         na += num;         va.push_back({a - b, num});       } else {         ans += num * b;         nb += num;         vb.push_back({b - a, num});       }     }     na %= s;     nb %= s;     sort(va.begin(), va.end());     sort(vb.begin(), vb.end());     if (na + nb > s) return cout << ans << endl, 0;     for (long long i = 0; i < ((long long)(va).size()); i++) {       ta += min(na, va[i].second) * va[i].first;       na -= min(na, va[i].second);     }     for (long long i = 0; i < ((long long)(vb).size()); i++) {       tb += min(nb, vb[i].second) * vb[i].first;       nb -= min(nb, vb[i].second);     }     ans -= min(ta, tb);     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 10001;   void solve() {}   int main() {     int a, b, c;     while (cin >> a >> b >> c) {       int t = a * c;       for (int i = 0; i <= 1005 * 1005; i++) {         if (b * i + c * b >= a * c) {           cout << i << endl;           break;         }       }     }     fclose(stdin);     fclose(stdout);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     cin >> n >> k;     int arr[200007];     map<int, bool> vis;     queue<int> q;     for (int i = 1; i <= n; i++) {       cin >> arr[i];       if (vis[arr[i]]) continue;       vis[arr[i]] = true;       if (q.size() == k) {         vis[q.front()] = false;         q.pop();       }       q.push(arr[i]);     }     vector<int> v;     while (!q.empty()) {       v.push_back(q.front());       q.pop();     }     cout << (int)v.size() << endl;     for (int i = (int)v.size() - 1; i >= 0; i--) {       cout << v[i] <<    ;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-10;   int n, m, Q, a[300006][2], fa[300006], dep[300006], siz[300006], b[300006], D;   bool vis[300006];   map<int, int> mp[300006];   vector<int> v[300006], s[300006];   const double pi = acos(-1.0);   void df5(int te, int la) {     vis[te] = 1;     siz[te] = 1;     for (int i = 0; i < v[te].size(); i++) {       int j = v[te][i];       if (j == la) continue;       if (vis[j]) continue;       dep[j] = dep[te] + 1;       fa[j] = te;       df5(j, te);       siz[te] += siz[j];     }   }   inline double getde(int x, int y) {     double ret = atan2(1.0 * a[y][1] - a[x][1], 1.0 * a[y][0] - a[x][0]);     if (ret < 0) ret += 2.0 * pi;     return ret;   }   inline bool cmp(int x, int y) { return getde(D, x) < getde(D, y); }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; i++) {       int x, y;       scanf( %d%d , &x, &y);       v[x].push_back(y), v[y].push_back(x);     }     for (int i = 1; i <= n; i++) scanf( %d%d , &a[i][0], &a[i][1]);     df5(1, 1);     for (int i = 1; i <= n; i++) {       D = i;       sort(v[i].begin(), v[i].end(), cmp);       for (int j = 0; j < v[i].size(); j++) mp[i][v[i][j]] = j;       if (!v[i].empty()) {         if (v[i][0] == fa[i])           s[i].push_back(-siz[i]);         else if (fa[v[i][0]] == i)           s[i].push_back(siz[v[i][0]]);         else           s[i].push_back(0);       }       for (int j = 1; j < v[i].size(); j++) {         int x = v[i][j], la = s[i][j - 1];         if (x == fa[i])           s[i].push_back(la - siz[i]);         else if (fa[x] == i)           s[i].push_back(la + siz[x]);         else           s[i].push_back(la);       }     }     scanf( %d , &Q);     while (Q--) {       int k;       scanf( %d , &k);       bool hv1 = false;       for (int i = 1; i <= k; i++) scanf( %d , &b[i]);       for (int i = 1; i <= k; i++)         if (b[i] == 1) {           hv1 = true;           break;         }       long long sum = 0;       bool flag = false;       for (int i = 1; i <= k; i++) {         int ii = i % k + 1;         sum += (1ll * (a[b[i]][0] - a[b[ii]][0]) * a[b[i]][1] -                 1ll * a[b[i]][0] * (a[b[i]][1] - a[b[ii]][1]));       }       if (sum > 0) flag = true;       long long ans = 0;       if (!flag) {         for (int i = 2, j = k; i < j; i++, j--) swap(b[i], b[j]);       }       for (int i = 1; i <= k; i++) {         int la = i - 1;         if (!la) la = k;         int nx = i % k + 1;         int ts1 = mp[b[i]][b[la]], ts2 = mp[b[i]][b[nx]],             tt = ((int)v[b[i]].size()) - 1;         if (ts1 >= ts2) {           if (ts1) ans += s[b[i]][ts1];           if (ts2) ans -= s[b[i]][ts2 - 1];         } else {           ans += s[b[i]][ts1];           if (ts2) ans += s[b[i]][tt] - s[b[i]][ts2 - 1];         }       }       ans += k;       if (ans <= 0) ans += n;       printf( %lld n , ans);     }   }
#include <bits/stdc++.h>   int main() {     using namespace std;     int c, m, i;     cin >> c >> m;     int a = 0;     for (i = 1; i <= 9; i++) {       if (i * c % 10 == 0) {         cout << i;         break;       }       if (c == m) {         cout << i;         break;       }       if (i * c % 10 == m) {         cout << i;         break;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const long long mx = 105;   const long long mod = 998244353;   vector<vector<int>> adj;   void solve() {     long long n, i, j, k;     cin >> n;     long long a[n];     for (i = 0; i < n; i++) cin >> a[i];     long long res = 0, su = 0;     for (i = 0; i < n; i++) {       su += a[i];     }     long long mm = su / n;     for (i = 0; i < n; i++) {       res += abs(a[i] - mm);       a[i + 1] += a[i] - mm;     }     cout << res <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     long long t = 1;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long a, b;     scanf( %I64d %I64d , &a, &b);     long long t = 0;     while (b) {       t *= 10;       t += b % 10;       b /= 10;     }     printf( %I64d n , a + t);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long double pi = acos(-1);   const long long int mod = 1000000007;   const double epsilon = 1e-9;   template <class T>   ostream &operator<<(ostream &out, vector<T> &A) {     for (auto x : A) out << x <<    ;     return out;   }   template <class T>   ostream &operator<<(ostream &out, set<T> &A) {     for (auto x : A) out << x <<    ;     return out;   }   template <class T>   ostream &operator<<(ostream &out, unordered_set<T> &A) {     for (auto x : A) out << x <<    ;     return out;   }   template <class T1, class T2>   T1 powr(T1 a, T2 b) {     T1 res = 1;     for (long long int i = 1; i < b + 1; i++) res = res * a;     return res;   }   long long int binpow(long long int a, long long int b) {     a = a % mod;     long long int res = 1;     while (b > 0) {       if (b & 1) res = (res * a) % mod;       a = (a * a) % mod;       b >>= 1;     }     return (res + mod) % mod;   }   const long long int N = 10000025;   long long int prime[10000000];   void SieveOfEratosthenes() {     for (long long int i = 0; i < N; i++) prime[i] = 1;     prime[0] = 0;     prime[1] = 0;     for (long long int p = 2; p * p <= 10000000; p++) {       if (prime[p] == 1) {         for (long long int i = p * p; i <= 10000000; i += p) prime[i] = 0;       }     }   }   int32_t main() {     std::ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     long long int t;     cin >> t;     while (t--) {       long long int n;       cin >> n;       long long int sum = 0, cnt = 0;       for (long long int i = 1; i < 100000; i++) {         long long int x = pow(2, i) - 1;         if (n - (x * (x + 1)) / 2 >= 0) {           n -= (x * (x + 1) / 2);           cnt++;         } else {           break;         }       }       cout << cnt <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int d, n, m, b[200005];   int mn[200005 << 2];   long long ans;   struct node {     int x;     long long p;     bool operator<(const node &a) const { return x < a.x; }   } a[200005];   int check(int x, int y) { return a[x].p < a[y].p ? x : y; }   void build(int l, int r, int rt) {     if (l == r) {       mn[rt] = l;       return;     }     int mid = (l + r) >> 1;     build(l, mid, rt << 1);     build(mid + 1, r, rt << 1 | 1);     mn[rt] = check(mn[rt << 1], mn[rt << 1 | 1]);   }   int get_mn(int l, int r, int rt, int L, int R) {     if (L == l && R == r) return mn[rt];     int mid = (l + r) >> 1;     if (R <= mid)       return get_mn(l, mid, rt << 1, L, R);     else if (L > mid)       return get_mn(mid + 1, r, rt << 1 | 1, L, R);     else       return check(get_mn(l, mid, rt << 1, L, mid),                    get_mn(mid + 1, r, rt << 1 | 1, mid + 1, R));   }   int main() {     cin >> d >> n >> m;     for (int i = 1; i <= m; i++) scanf( %d%I64d , &a[i].x, &a[i].p);     sort(a + 1, a + m + 1);     a[++m].x = d;     a[0].p = 0x3f3f3f3f;     build(1, m, 1);     for (int i = 1; i <= m; i++) b[i] = a[i].x;     int now = n, i = 0, j = 1, t, k;     while (i < m) {       t = upper_bound(b + 1, b + m + 1, a[i].x + n) - b - 1;       if (t == i) {         puts( -1 );         return 0;       }       t = upper_bound(b + 1, b + m + 1, a[i].x + now) - b - 1;       k = (t > i ? get_mn(1, m, 1, i + 1, t) : 0);       if (a[k].p <= a[i].p) {         now -= (a[k].x - a[i].x);         i = k;       } else {         t++;         while (t <= m && a[t].x - a[i].x <= n) {           if (a[t].p <= a[i].p) {             ans = (ans + (a[t].x - a[i].x - now) * a[i].p);             now = 0;             i = t;             break;           }           t++;         }         if (a[t].x - a[i].x > n) {           t = upper_bound(b + 1, b + m + 1, a[i].x + n) - b - 1;           k = get_mn(1, m, 1, i + 1, t);           ans = (ans + (n - now) * a[i].p);           now = (n - (a[k].x - a[i].x));           i = k;         }       }     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, i, s = 0, s2 = 0;     cin >> n;     char a[n];     cin >> a;     for (i = 0; i < n; i++) {       if (a[i] ==  0 )         s++;       else         s2++;     }     if (s2 > 0) cout <<  1 ;     while (s--) cout <<  0 ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   const long long N = 1e5 + 1;   const long long INF = -1e17;   long long n;   long long ans, cnt, mx = 0;   string s;   int main() {     ios_base::sync_with_stdio(false);     cin >> n;     getline(cin, s);     getline(cin, s);     for (long long i = 0; i < s.size(); i++) {       if (s[i] > 64 and s[i] < 95) {         ans++;         mx = max(ans, mx);       } else if (s[i] ==    ) {         mx = max(ans, mx);         ans = 0;       }     }     cout << mx;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2000010;   vector<int> freqs;   int t, n, k, a[N], f[N], vis[N];   int main() {     cin >> t;     while (t--) {       scanf( %d , &n);       for (int i = 1; i <= n; ++i) {         f[i] = 0, vis[i] = 0;       }       for (int i = 1; i <= n; ++i) {         scanf( %d , a + i);         ++f[a[i]];       }       int minFreq = n + n;       for (int i = 1; i <= n; ++i) {         if (f[i]) ++vis[f[i]], minFreq = min(minFreq, f[i]);       }       freqs.clear();       for (int i = 1; i <= n; ++i)         if (vis[i]) {           freqs.emplace_back(i);         }       int ans = n;       for (int s = 1; s <= minFreq; ++s) {         int bad = 0, m = 0;         for (int it : freqs) {           int x = (it + s) / (s + 1);           if (x * s > it) {             bad = 1;             break;           }           m += vis[it] * x;         }         if (bad) continue;         ans = min(ans, m);       }       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   const double e = 1e-6;   int main() {     int T;     double n;     scanf( %d , &T);     while (T--) {       scanf( %lf , &n);       double a = 0, b = n;       bool flag = false;       for (int i = 0; i < 10000; i++) {         double m = (a + b) / 2, d = n - m;         if (m * d - m - d > 1e-9)           b = m;         else if (m + d - d * m > 1e-9)           a = m;       }       double m = (a + b) / 2, d = n - m;       if (m + d - n <= e && m + d - n >= -e && (m + d) - m * d <= e &&           (m + d) - m * d >= -e && m * d - n <= e && m * d - n >= -e)         printf( Y %.9lf %.9lf n , d, m);       else         puts( N );     }     return 0;   }
#include <bits/stdc++.h>   int n, a[444], s, p, q, ans;   int main() {     scanf( %d , &n);     ans = -1;     for (int i = 0; i < n; ++i) scanf( %d , a + i);     for (int i = 1; i < n; ++i)       for (int j = 0; j < n; ++j) {         p = a[i - 1] - 1;         for (int k = q = s = 0; k <= j;)           q += p / a[k], s += p / a[k] * a[k], p %= a[k++];         ++q, p = s += a[j];         for (int k = 0; k < n; ++k) q -= p / a[k], p %= a[k];         if (q < 0) ans = (unsigned)ans < s ? ans : s;       }     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100005;   int n, m, k;   set<int> a[maxn], b[maxn];   set<int, greater<int> > c[maxn], d[maxn];   int main() {     scanf( %d%d%d , &n, &m, &k);     int x, y, nx, ny, lx = 0, ly = 0, rx = n + 1, ry = m + 1, dir = 1;     long long ans = 1;     for (int i = 1; i <= k; i++) {       scanf( %d%d , &x, &y);       a[x].insert(y), c[x].insert(y);       b[y].insert(x), d[y].insert(x);     }     x = 1, y = 1;     for (int i = 1;; i++) {       nx = x, ny = y;       if (dir == 1) {         auto t = a[x].lower_bound(y);         ny = ((t == a[x].end()) ? ry : min(*t, ry)) - 1, lx = x;       }       if (dir == 2) {         auto t = b[y].lower_bound(x);         nx = ((t == b[y].end()) ? rx : min(*t, rx)) - 1, ry = y;       }       if (dir == 3) {         auto t = c[x].lower_bound(y);         ny = ((t == c[x].end()) ? ly : max(*t, ly)) + 1, rx = x;       }       if (dir == 4) {         auto t = d[y].lower_bound(x);         nx = ((t == d[y].end()) ? lx : max(*t, lx)) + 1, ly = y;       }       if (x == nx && y == ny && i > 1) break;       ans += abs(nx - x) + abs(ny - y), x = nx, y = ny,                                         dir = (dir < 4) ? dir + 1 : 1;     }     if (ans == (long long)n * m - k)       printf( Yes n );     else       printf( No n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 5;   int cnt, n, res;   int tin[maxn], tout[maxn], a[maxn + maxn], dp[maxn], f[maxn][17], st[maxn],       h[maxn], b[maxn];   bool need[maxn];   vector<int> adj[maxn];   void Input() {     int x, y;     cin >> n;     for (int i = (2); i <= (n); ++i) {       cin >> x >> y;       adj[x].push_back(y);       adj[y].push_back(x);     }   }   void DFS(int u) {     tin[u] = ++cnt;     for (int v : adj[u]) {       if (h[v] != 0) continue;       h[v] = h[u] + 1;       f[v][0] = u;       for (int i = (1); i <= (16); ++i) f[v][i] = f[f[v][i - 1]][i - 1];       DFS(v);     }     tout[u] = cnt;   }   int LCA(int u, int v) {     if (h[u] < h[v]) swap(u, v);     for (int i = (16); i >= (0); --i)       if (h[u] - (1 << i) >= h[v]) u = f[u][i];     if (u == v) return u;     for (int i = (16); i >= (0); --i)       if (f[u][i] != f[v][i]) u = f[u][i], v = f[v][i];     return f[u][0];   }   bool cmp(int u, int v) { return tin[u] < tin[v]; }   bool IsAnc(int u, int v) { return tin[u] < tin[v] && tout[v] <= tout[u]; }   bool canbuild(int k) {     sort(a + 1, a + 1 + k, cmp);     for (int i = (1); i <= (k - 1); ++i) a[k + i] = LCA(a[i], a[i + 1]);     k = k + k - 1;     sort(a + 1, a + 1 + k, cmp);     k = unique(a + 1, a + 1 + k) - a - 1;     for (int i = (1); i <= (k); ++i) adj[a[i]].clear();     int top = 1, u;     st[1] = a[1];     for (int i = (2); i <= (k); ++i) {       while (top >= 1 && !IsAnc(st[top], a[i])) --top;       if (top == 0) {         st[++top] = a[i];         continue;       }       u = st[top];       if (need[u] && need[a[i]] && f[a[i]][0] == u) return false;       adj[u].push_back(a[i]);       st[++top] = a[i];     }     return true;   }   void Calc(int u) {     int tmp = 0;     for (int v : adj[u]) {       Calc(v);       tmp += dp[v];     }     if (need[u]) {       res += tmp;       dp[u] = 1;     } else {       if (tmp >= 2)         dp[u] = 0, ++res;       else         dp[u] = tmp;     }   }   void Solve() {     h[1] = 1;     DFS(1);     int q, k;     cin >> q;     for (int i = (1); i <= (q); ++i) {       cin >> k;       for (int j = (1); j <= (k); ++j) {         cin >> a[j];         b[j] = a[j];         need[a[j]] = true;       }       if (!canbuild(k)) {         cout << -1 <<   n ;         for (int j = (1); j <= (k); ++j) need[b[j]] = false;         continue;       }       res = 0;       Calc(st[1]);       cout << res <<   n ;       for (int j = (1); j <= (k); ++j) need[b[j]] = false;     }   }   int main() {     iostream::sync_with_stdio(false);     cin.tie(0);     Input();     Solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   using maxpq = priority_queue<T, vector<T>, greater<T>>;   template <typename T>   using minpq = priority_queue<T>;   int n, TOT;   string a[305];   int HASH[305], len[305], p[100005];   inline int add(int a, int b) {     long long c = a + b;     if (c >= 1000000007) c -= 1000000007;     return c;   }   inline int sub(int a, int b) {     int c = a - b;     if (c < 0) c += 1000000007;     return c;   }   inline int mul(int a, int b) { return (a * 1ll * b) % 1000000007; }   int power(int a, int b, int m = 1000000007) {     int res = 1;     while (b > 0) {       if (b & 1) res = mul(res, a);       a = mul(a, a);       b >>= 1;     }     return res;   }   inline int Fermat(int a, int p = 1000000007) { return power(a, p - 2, p); }   inline int Div(int a, int b) { return mul(a, Fermat(b)); }   int base = 128;   inline int h(char c) { return c; }   inline int hsh(string s) {     int t = 0;     for (int i = (0); i < (s.size()); i++) {       t = mul(t, base);       t = add(t, h(s[i]));     }     return t;   }   int ans = 0;   vector<pair<int, int>> adj[305];   void pre() {     p[0] = 1;     for (int i = (1); i < (100005); i++) {       p[i] = mul(p[i - 1], base);     }   }   void solve() {     for (int l = (1); l < (n + 1); l++) {       for (int i = (0); i < (n - l + 1); i++) {         int j = i + l - 1;         int t = HASH[i], tot = len[i];         for (int k = (i + 1); k < (j + 1); k++) {           t = mul(t, p[len[k] + 1]);           t = add(t, mul(h(   ), p[len[k]]));           t = add(t, HASH[k]);           tot = tot + len[k] + 1;         }         adj[l].push_back({t, tot});       }     }     for (int l = (1); l < (n); l++) {       for (int i = (0); i < (n - l + 1); i++) {         bool b = 0;         int tmp = TOT;         for (int j = (i + l); j < (n - l + 1); j++) {           if (adj[l][i].first != adj[l][j].first ||               adj[l][j].second != adj[l][j].second)             continue;           tmp += -adj[l][i].second + l;           if (b == 0) b = 1, tmp += -adj[l][i].second + l;           j += l - 1;         }         ans = min(ans, tmp);       }     }   }   int main() {     clock_t clk = clock();     cerr <<  I will return... n ;     cin >> n;     for (int i = (0); i < (n); i++)       cin >> a[i], len[i] = a[i].size(), TOT += len[i], HASH[i] = hsh(a[i]);     TOT += n - 1;     ans = TOT;     pre();     solve();     cout << ans <<   n ;     cerr <<  ...don t you ever hang your head. n ;     cerr <<  Time (in ms):   << double(clock() - clk) * 1000.0 / CLOCKS_PER_SEC          <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   void __read(T& a) {     cin >> a;   }   template <typename T, typename... Args>   void __read(T& a, Args&... args) {     cin >> a;     __read(args...);   }   constexpr long long M7 = 1000000007ll;   constexpr long long M9 = 1000000009ll;   constexpr long long MFFT = 998244353ll;   template <class T>   void outv(T& a) {     for (auto& x : a) cout << x <<    ;   }   mt19937 rnd(static_cast<unsigned>(       chrono::steady_clock::now().time_since_epoch().count()));   template <class T>   void random_shuffle(T s, T e) {     shuffle(s, e, rnd);   };   static auto __super_speed__ = (ios_base::sync_with_stdio(0), cin.tie(0));   signed dp[30 + 1][30 + 1][51];   signed calc(signed n, signed m, signed k) {     signed& v = dp[n][m][k];     if (v != -1) return v;     if (n * m == k || k == 0) return v = 0;     v = M7;     for (signed i = 1; i < n; ++i)       for (signed nk = 0; nk < k; ++nk)         v = min(v, calc(i, m, nk) + calc(n - i, m, k - nk) + m * m);     for (signed i = 1; i < m; ++i)       for (signed nk = 0; nk < k; ++nk)         v = min(v, calc(n, i, nk) + calc(n, m - i, k - nk) + n * n);     return v;   }   int32_t main() {     memset(dp, -1, sizeof(dp));     signed t;     __read(t);     while (t--) {       signed n, m, k;       __read(n, m, k);       cout << calc(n, m, k) <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s, test =  hello ;     int c = 0;     cin >> s;     for (int i = 0; i < s.length(); i++) {       if (s[i] == test[c]) {         c++;       }       if (c == 5) {         break;       }     }     if (c == 5) {       cout <<  YES  << endl;     } else {       cout <<  NO  << endl;     }   }