malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   template <typename T_key, typename T_value, bool maximum_mode = false>   struct online_prefix_max {     map<T_key, T_value> optimal;     bool better(T_value a, T_value b) { return (a < b) ^ maximum_mode; }     pair<T_key, T_value> query(T_key key_limit) const {       auto it = optimal.lower_bound(key_limit);       if (it == optimal.begin()) return {0, -1};       it--;       return *it;     }     void insert(T_key key, T_value value) {       auto it = optimal.lower_bound(key);       if (it != optimal.end() && it->first == key) {         if (!better(value, it->second)) return;       } else if (it != optimal.begin()) {         auto prev_it = it;         prev_it--;         if (!better(value, prev_it->second)) return;       }       while (it != optimal.end() && !better(it->second, value))         it = optimal.erase(it);       optimal.insert(it, {key, value});     }   };   int main() {     int n, i, j, t;     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     online_prefix_max<long long int, int> ds;     map<pair<int, long long int>, pair<int, int> > mp;     long long int l, r;     cin >> n >> t;     for (i = 0; i < n; i++) {       cin >> l >> r;       r += l;       mp[{l, r}] = {i, 0};       ds.insert(-r, l);     }     int pos, siz;     pair<long long int, int> p;     multiset<pair<int, int> > not_eaten;     while (t--) {       cin >> pos >> siz;       p = ds.query(-pos + 1);       if (p.second == -1 || p.second > pos) {         not_eaten.insert({pos, siz});       } else {         l = p.second;         r = -p.first;         pair<int, int> val = mp[{l, r}];         mp.erase({l, r});         r += siz;         val.second++;         while (1) {           auto it = not_eaten.lower_bound({l, -1});           if (it == not_eaten.end() || it->first > r) break;           r += it->second;           val.second++;           not_eaten.erase(it);         }         ds.insert(-r, l);         mp[{l, r}] = val;       }     }     pair<int, int> ans[n];     for (auto &z : mp) {       ans[z.second.first] = {z.second.second, z.first.second - z.first.first};     }     for (i = 0; i < n; i++) cout << ans[i].first <<     << ans[i].second <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       int arr[n], vis[200005] = {0};       for (int i = 0; i < n; i++) {         cin >> arr[i];         if (arr[i] <= n) vis[arr[i]]++;       }       sort(arr, arr + n);       vector<int> v;       for (int i = 1; i <= n; i++) {         if (!vis[i]) v.push_back(i);       }       int m = v.size(), l = 0;       int ans = 0;       for (int i = 0; i < n; i++) {         int x = arr[i];         if (x <= n && vis[x] > 1) {           int r = vis[x], k = 1;           while (r > 1) {             if (l < m && (2 * v[l]) < x) {               ans++;               l++;             } else {               ans = -1;               k = 0;               break;             }             r--;             i++;           }           if (!k) break;         }         if (x > n) {           if (l < m && (2 * v[l]) < x) {             ans++;             l++;           } else {             ans = -1;             break;           }         }       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n;     cin >> n;     vector<long long> V;     for (long long i = 1; i * i <= n; ++i) {       if (!(n % i)) {         V.push_back(i);         V.push_back(n / i);       }     }     sort(V.begin(), V.end());     for (long long i = V.size() - 1; i >= 0; --i)       if (i == V.size() - 1 || V[i + 1] != V[i])         cout << n * (2 + V[i] * (n / V[i] - 1)) / 2 / V[i] <<    ;     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1.0);   int n, h, a[100005];   pair<int, int> A[100005];   void solve() {     sort(A, A + n);     for (int i = (0); i < (n); i++) a[i] = A[i].first;     int res = a[n - 1] + a[n - 2] - a[0] - a[1], ind = n - 1;     if (n >= 3) {       int v = max(a[n - 1] + a[n - 2], a[n - 1] + a[0] + h) -               min(a[1] + a[2], a[1] + a[0] + h);       if (res > v) {         res = v;         ind = 0;       }       v = max(a[n - 3] + a[n - 2], a[n - 1] + a[n - 2] + h) - (a[0] + a[1]);       if (res > v) {         res = v;         ind = n - 2;       }     }     for (int i = 1; i + 2 < n; i++) {       int v = max(a[n - 1] + a[n - 2], a[n - 1] + a[i] + h) - (a[0] + a[1]);       if (res > v) {         res = v;         ind = i;       }     }     cout << res << endl;     set<int> L;     for (int i = (0); i < (ind + 1); i++) L.insert(A[i].second);     for (int i = (0); i < (n); i++) {       printf( %d  , (L.find(i) == L.end()) + 1);     }     cout << endl;   }   int main() {     while (cin >> n >> h) {       for (int i = (0); i < (n); i++) {         scanf( %d , &A[i].first);         A[i].second = i;       }       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   const long long maxx = 1e6 + 7;   const long long maxn = 5000 + 7;   const long long mod = 998244853;   const long long maxs = 5 * (1E5) + 7;   const long long maxm = 4e5 + 7;   const long long maxk = 1008 + 7;   const long long maxw = 100 + 7;   const long long maxh = 100 + 7;   const double pi = 3.1415926;   const long long ten = 10;   const int ooi = 1234567;   const long long ool = 1e18 + 7;   const long double eps = 1e-8;   const int apsz = 26;   vector<int> can[2][2];   int a[maxn];   int c[maxn];   int n;   void init() {     cin >> n;     for (long long i = (0); i < (n); i++) {       char ch;       cin >> ch;       c[i] = ch -  0 ;     }     for (long long i = (0); i < (n); i++) {       char ch;       cin >> ch;       a[i] = ch -  0 ;     }     for (long long i = (0); i < (n); i++) {       if (a[i] == 1 && c[i] == 1) can[1][1].push_back(i);       if (c[i] == 1 && a[i] == 0) can[1][0].push_back(i);       if (c[i] == 0 && a[i] == 0) can[0][0].push_back(i);       if (c[i] == 0 && a[i] == 1) can[0][1].push_back(i);     }   }   void solve() {     int nn = can[0][0].size();     int nc = can[1][0].size();     int na = can[0][1].size();     int nb = can[1][1].size();     int ans = -1;     int a, b, c, d;     for (b = 0; b <= nc; b++) {       for (c = 0; c <= na; c++) {         if ((nb + na - c - b) % 2) continue;         d = (nb + na - c - b) / 2;         a = n / 2 - b - c - d;         if (a <= nn && d <= nb && a >= 0 && d >= 0) {           ans = 1;           goto ED;         }       }     }   ED:     if (ans == -1) {       cout << ans << endl;       return;     }     vector<int> ta;     for (long long i = (0); i < (a); i++) ta.push_back(can[0][0][i]);     for (long long i = (0); i < (b); i++) ta.push_back(can[1][0][i]);     for (long long i = (0); i < (c); i++) ta.push_back(can[0][1][i]);     for (long long i = (0); i < (d); i++) ta.push_back(can[1][1][i]);     for (long long i = (0); i < (n / 2); i++) {       if (i) cout <<    ;       cout << ta[i] + 1;     }     cout << endl;   }   int main(void) {     ios::sync_with_stdio(false);     cout.tie(0);     cin.tie(0);     init();     solve();     return 0;   }
#include <bits/stdc++.h>   int n;   int tot;   int top;   int tot1;   int a[2005][2005];   int stack[2005];   int instack[2005];   int visit[2005];   int dfn[2005];   int low[2005];   inline void tarjan(int u) {     if (visit[u]) return;     int v;     dfn[u] = low[u] = ++tot;     stack[++top] = u;     instack[u] = 1;     visit[u] = 1;     int i;     for (i = 1; i <= n; i++) {       if (a[u][i]) {         if (!visit[i]) {           tarjan(i);           if (low[i] < low[u]) low[u] = low[i];         } else {           if (instack[i])             if (dfn[i] < low[u]) low[u] = dfn[i];         };       };     };     if (dfn[u] == low[u]) {       ++tot1;       while (1) {         v = stack[top--];         instack[v] = 0;         if (v == u) break;       };     };   };   int main() {     scanf( %d , &n);     int i, j;     for (i = 1; i <= n; i++) {       for (j = 1; j <= n; j++) {         scanf( %d , a[i] + j);       };     };     for (i = 1; i <= n; i++) tarjan(i);     puts(tot1 == 1 ?  YES  :  NO );   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:256000000 )   #pragma gcc optimize(O3)   using namespace std;   const double eps = 1e-9;   const double pi = acos(-1.0);   const double dinf = 1e250;   const long long INF = static_cast<long long>(2e18);   const unsigned long long inf = static_cast<unsigned long long>(1e9 + 7);   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   template <class T>   void OUT(T a) {     cout << a;     exit(0);   }   template <typename T>   bool amax(T& a, T b) {     if (b > a) {       a = b;       return true;     }     return false;   }   template <typename T>   bool amin(T& a, T b) {     if (b < a) {       a = b;       return true;     }     return false;   }   mt19937 rng(static_cast<uint32_t>(       chrono::steady_clock::now().time_since_epoch().count()));   chrono::time_point<chrono::steady_clock> cl;   double time_since_start() {     return (chrono::steady_clock::now() - cl).count() / 1e9;   }   void get_time();   vector<long long> precalc;   void rec(unsigned long long n, unsigned long long cur, unsigned long long& k,            map<unsigned long long, unsigned long long>& s,            unsigned long long& w) {     w = n;     if (!n) return;     if (!k) return;     if (k >= 2 * cur - 1) {       k -= 2 * cur - 1;       rec(n - 1, cur * 2, k, s, w);       s[n - 1] += 2 * cur - 3;     }   }   void solve() {     map<unsigned long long, unsigned long long> m;     unsigned long long n, k;     cin >> n >> k;     unsigned long long cur = 1;     while (k >= cur * cur && n) {       k -= cur * cur;       cur *= 2;       n -= 1;     }     if (!n && k) {       cout <<  NO  << endl;       return;     }     unsigned long long w;     rec(n, cur, k, m, w);     m[n] += (cur - 1) * (cur - 1);     for (unsigned long long i = n; i > 0; --i) {       if (k >= m[i]) {         k -= m[i];         m[i - 1] += 4 * m[i];       }       if (k < m[i]) {         cout <<  YES   << w << endl;         return;       }     }     if (!k) {       cout <<  YES   << n << endl;       return;     }     if (k) {       cout <<  NO  << endl;       return;     }   }   int32_t main() {     ios_base::sync_with_stdio(0);     cout << fixed << setprecision(10);     cl = chrono::steady_clock::now();     cin.tie(0);     unsigned long long cur = 1;     for (unsigned long long i = 0; i < 32; ++i) {       precalc.push_back(cur);       cur *= 4;     }     for (unsigned long long i = 1; i < 32; ++i) {       precalc[i] += precalc[i - 1];     }     unsigned long long q;     cin >> q;     while (q--) {       solve();     }     return 0;   }   void get_time() {}
#include <bits/stdc++.h>   using namespace std;   int pre[30], g[2000100], f[2000100];   char s[2000100];   int n, m, k, ans;   int main() {     scanf( %d%d , &n, &k);     scanf( %s , s + 1);     m = strlen(s + 1);     for (int i = 1; i <= m; i++) pre[s[i] -  a  + 1] = i;     n = n + m;     pre[27] = 2000000;     for (int i = m + 1; i <= n; i++) {       int mn = 27;       for (int j = 1; j <= k; j++)         if (pre[j] < pre[mn]) mn = j;       s[i] =  a  + mn - 1;       pre[mn] = i;     }     memset(pre, 0, sizeof(pre));     for (int i = 1; i <= n; i++) {       g[i] = (f[i - 1] + 1) % 1000000007;       f[i] =           ((f[i - 1] + g[i]) % 1000000007 - g[pre[s[i] -  a  + 1]] + 1000000007) %           1000000007;       pre[s[i] -  a  + 1] = i;     }     printf( %d n , (f[n] + 1) % 1000000007);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 2010;   const int MAXM = 4100000;   int F[MAXN];   struct node {     long long x, y, c;   } a[MAXN];   struct Edge {     long long u, v, w;   } edge[MAXM];   int tol;   vector<long long> vec1;   vector<pair<long long, long long> > vec2;   void addedge(long long u, long long v, long long w) {     edge[tol].u = u;     edge[tol].v = v;     edge[tol++].w = w;   }   bool cmp(Edge a, Edge b) { return a.w < b.w; }   long long Find(long long x) {     if (F[x] == -1)       return x;     else       return F[x] = Find(F[x]);   }   long long Kruskal(int n) {     memset(F, -1, sizeof(F));     sort(edge, edge + tol, cmp);     long long cnt = 0;     long long ans = 0;     for (int i = 0; i < tol; i++) {       long long u = edge[i].u;       long long v = edge[i].v;       long long w = edge[i].w;       long long t1 = Find(u);       long long t2 = Find(v);       if (t1 != t2) {         if (u == 0)           vec1.push_back(v);         else if (v == 0)           vec1.push_back(u);         else           vec2.push_back(make_pair(u, v));         ans += w;         F[t1] = t2;         cnt++;       }       if (cnt == n) break;     }     if (cnt < n)       return -1;     else       return ans;   }   int main() {     int n;     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i].x >> a[i].y;     for (int i = 1; i <= n; i++) {       long long c;       cin >> c;       addedge(0, i, c);       addedge(i, 0, c);     }     for (int i = 1; i <= n; i++) cin >> a[i].c;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         if (j == i) continue;         long long ww =             (a[i].c + a[j].c) * (abs(a[i].x - a[j].x) + abs(a[i].y - a[j].y));         addedge(i, j, ww);       }     }     long long ans = Kruskal(n);     cout << ans << endl;     cout << vec1.size() << endl;     for (int i = 0; i < vec1.size(); i++) {       if (i != 0) cout <<    ;       cout << vec1[i];     }     cout << endl;     cout << vec2.size() << endl;     for (int i = 0; i < vec2.size(); i++) {       cout << vec2[i].first <<     << vec2[i].second << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 30;   const int M = 110;   const int LIT = 2500;   const int INF = 1 << 28;   string s;   int n, m;   int val[N][N];   void init() {     cin >> n;     memset(val, 0, sizeof(val));     for (int i = 1; i <= n; i++) {       string a, b;       int v;       cin >> a >> b >> v;       int aa = a[0] -  a ;       int bb = b[0] -  a ;       val[aa][bb] = v;     }   }   int dp[M][M][N];   void solve() {     memset(dp, 0, sizeof(dp));     for (int i = 0; i < 26; i++) {       int ch = s[0] -  a ;       dp[0][1][i] = 0;       dp[0][0][i] = -INF;       if (i == ch) dp[0][0][i] = 0;     }     for (int i = 1; i < s.size(); i++) {       int ch = s[i] -  a ;       for (int j = 0; j <= i + 1; j++) {         for (int k = 0; k < 26; k++) {           int Max = -INF;           if (ch == k && j <= i) {             for (int p = 0; p < 26; p++) {               int tmp = dp[i - 1][j][p] + val[p][k];               Max = max(Max, tmp);             }           } else {             for (int p = 0; j && p < 26; p++) {               int tmp = dp[i - 1][j - 1][p] + val[p][k];               Max = max(Max, tmp);             }           }           dp[i][j][k] = Max;         }       }     }     int out = s.size() - 1, res = -INF;     for (int i = 0; i <= min(out + 1, m); i++) {       for (int k = 0; k < 26; k++) {         res = max(res, dp[out][i][k]);       }     }     cout << res << endl;   }   int main() {     while (cin >> s >> m) {       init();       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   long long a[200000 + 1], b[200000 + 1];   int c[200000 + 1], t[200000 + 1];   int n, m, k, s;   vector<pair<long long, int> > v;   inline int check(int p) {     int i;     v.clear();     long long mna = (1LL << 62), mnb = (1LL << 62);     for (i = 1; i <= p; i++) {       mna = min(mna, a[i]);       mnb = min(mnb, b[i]);     }     for (i = 1; i <= m; i++) {       if (t[i] == 1)         v.push_back({1LL * mna * c[i], i});       else         v.push_back({1LL * mnb * c[i], i});     }     sort(v.begin(), v.end());     int cnt = 0;     long long aux = s;     for (i = 0; i < m; i++) {       if (aux >= v[i].first) {         aux -= v[i].first;         cnt++;       }     }     return cnt;   }   int main() {     int i;     ios::sync_with_stdio(false);     cin >> n >> m >> k >> s;     for (i = 1; i <= n; i++) cin >> a[i];     for (i = 1; i <= n; i++) cin >> b[i];     for (i = 1; i <= m; i++) cin >> t[i] >> c[i];     int rez = 0;     for (int pas = 1 << 17; pas; pas >>= 1)       if (rez + pas <= n && check(rez + pas) < k) rez += pas;     if (rez == n) {       cout << -1;       return 0;     }     rez++;     cout << rez << endl;     v.clear();     long long mna = (1LL << 62), mnb = (1LL << 62);     int pa, pb;     for (i = 1; i <= rez; i++) {       mna = min(mna, a[i]);       if (mna == a[i]) pa = i;       mnb = min(mnb, b[i]);       if (mnb == b[i]) pb = i;     }     for (i = 1; i <= m; i++) {       if (t[i] == 1)         v.push_back({1LL * mna * c[i], i});       else         v.push_back({1LL * mnb * c[i], i});     }     sort(v.begin(), v.end());     int cnt = 0;     for (i = 0; i < m && cnt < k; i++) {       if (s >= v[i].first) {         s -= v[i].first;         cnt++;         if (t[v[i].second] == 1)           cout << v[i].second <<     << pa << endl;         else           cout << v[i].second <<     << pb << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, zz;   string s;   int a[28];   int main(void) {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int ntest;     cin >> ntest;     while (ntest--) {       cin >> n >> m >> zz >> s;       for (int i = 0; i < 28; ++i) a[i] = 0;       for (int i = 0; i < s.size(); ++i) ++a[s[i] -  A ];       int ans = 1e9;       for (int i = 0; i < 27; ++i) {         vector<bool> can(zz - a[i] + 1, 0);         can[0] = 1;         for (int j = 0; j < 26; ++j)           if (j != i) {             for (int k = zz - a[i]; k >= 0; --k)               if (can[k]) can[k + a[j]] = 1;           }         for (int j = 0; j <= zz - a[i]; ++j)           if (can[j]) {             int need_n = max(0, n - j);             int need_m = max(0, m - (zz - a[i] - j));             if (need_n + need_m > a[i]) continue;             ans = min(ans, need_n * need_m);           }       }       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a[5], sum = 0;     for (int i = 0; i < 5; i++) {       cin >> a[i];       sum += a[i];     }     if (sum % 5 == 0 && sum != 0)       cout << (sum / 5);     else       cout << -1;   }
#include <bits/stdc++.h>   using namespace std;   const int LIM = 1e+5 + 100;   int n, m, k;   int get_rd(int i, int j) {     if (i == j) {       return n;     } else if (i < j) {       return n + (j - i);     } else {       return n - (i - j);     }   }   int get_ld(int i, int j) {     if (i + j == n) {       return n;     } else if (i + j < n) {       return i + j;     } else {       return i + j;     }   }   struct detector {     int i, j, id;     detector(int i, int j, int id) : i(i), j(j), id(id) {}     int get_rd() { return ::get_rd(i, j); }     int get_ld() { return ::get_ld(i, j); }   };   vector<bool> used(LIM, false);   vector<long long> ans(LIM, -1);   vector<vector<detector>> ld(2 * LIM);   vector<vector<detector>> rd(2 * LIM);   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cin >> n >> m >> k;     for (int i = 0; i < k; ++i) {       int pi, pj;       cin >> pi >> pj;       detector newbie(pi, pj, i);       rd[newbie.get_rd()].push_back(newbie);       ld[newbie.get_ld()].push_back(newbie);     }     int i = 0, j = 0;     int di = 1, dj = 1;     long long time = 0;     while (true) {       int d = -1;       if (di == dj) {         d = get_rd(i, j);         for (const detector& det : rd[d]) {           int id = det.id;           if (!used[id]) {             ans[id] = time + abs(i - det.i);             used[id] = true;           }         }       } else {         d = get_ld(i, j);         for (const detector& det : ld[d]) {           int id = det.id;           if (!used[id]) {             ans[id] = time + abs(i - det.i);             used[id] = true;           }         }       }       if (di == 1 && dj == 1) {         int delta = min(n - i, m - j);         time += delta;         i += delta;         j += delta;         if (i == n && j == m) {           break;         }         if (i == n)           di = -1;         else           dj = -1;       } else if (di == -1 && dj == -1) {         int delta = min(i, j);         time += delta;         i -= delta;         j -= delta;         if (i == 0 && j == 0) break;         if (i == 0)           di = 1;         else           dj = 1;       } else if (di == 1 && dj == -1) {         int delta = min(n - i, j);         time += delta;         i += delta;         j -= delta;         if (i == n && j == 0) break;         if (i == n)           di = -1;         else           dj = 1;       } else {         int delta = min(i, m - j);         time += delta;         i -= delta;         j += delta;         if (i == 0 && j == m) break;         if (i == 0)           di = 1;         else           dj = -1;       }     }     for (int i = 0; i < k; ++i) cout << ans[i] <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int v[100001];   int acum[100001];   long long cnt = 0, ans[100001];   struct Q {     int i, j, p;     Q(int a, int b, int c) : i(a), j(b), p(c){};     Q() {}     bool operator<(const Q &other) const {       if (i / 300 == other.i / 300) return j < other.j;       return i / 300 < other.i / 300;     }   };   vector<Q> queries;   int freq[(1 << 20) - 1 + 1];   int main() {     int n, m, k;     scanf( %d %d %d , &n, &m, &k);     for (int i = 1; i <= n; i++) {       scanf( %d , v + i);       acum[i] = v[i] ^ acum[i - 1];     }     for (int k = 0; k < m; k++) {       int i, j;       scanf( %d %d , &i, &j);       queries.push_back(Q(i - 1, j, k));     }     sort(queries.begin(), queries.end());     int l = 0, r = 0;     freq[0] = 1;     for (int q = 0; q < m; q++) {       int i = queries[q].i, j = queries[q].j, p = queries[q].p;       while (l < i) {         freq[acum[l]]--;         cnt -= freq[acum[l] ^ k];         l++;       }       while (l > i) {         --l;         cnt += freq[acum[l] ^ k];         freq[acum[l]]++;       }       while (r < j) {         r++;         cnt += freq[acum[r] ^ k];         freq[acum[r]]++;       }       while (r > j) {         freq[acum[r]]--;         cnt -= freq[acum[r] ^ k];         r--;       }       ans[p] = cnt;     }     for (int i = 0; i < m; i++) printf( %lld n , ans[i]);     return 0;   }
#include <bits/stdc++.h>   const int mod = 1000000007;   const int inf = 1000000009;   const long long INF = 1000000000000000009;   const long long big = 1000000000000000;   const long double eps = 0.0000000001;   using namespace std;   int DP[2005][2005], T[2005];   int main() {     ios::sync_with_stdio(false);     cin.tie();     cout.tie();     int n, h;     cin >> n >> h;     for (int i = 1; i <= n; i++) cin >> T[i];     DP[0][0] = 1;     for (int i = 1; i <= n; i++) {       int j = h - T[i];       if (j < 0) continue;       DP[i][j] = (DP[i][j] + DP[i - 1][j]) % mod;       DP[i][j] %= mod;       if (j > 0) {         DP[i][j] = (DP[i][j] + DP[i - 1][j - 1]) % mod;         DP[i][j - 1] = ((long long int)DP[i][j - 1] + DP[i - 1][j - 1] +                         (long long int)DP[i - 1][j] * j) %                        mod;         DP[i][j - 1] =             (DP[i][j - 1] + (long long int)DP[i - 1][j - 1] * (j - 1)) % mod;       }     }     cout << DP[n][0];     return 0;   }