malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long s[100007];   long long l[100007];   int main() {     long long n, k, r = 0;     cin >> n >> k;     map<int, int> m;     map<int, int> e[10];     long long ki = 0;     for (int i = 0; i < n; i++) {       scanf( %I64d , &s[i]);       r += s[i] / 10;       if (s[i] != 100) {         m[10 - (s[i] % 10)]++;       }       if ((s[i] % 10) == 0) {         ki += (10 - s[i] / 10);       }       if (s[i] / 10 <= 9) {         e[s[i] / 10][10 - (s[i] % 10)]++;       }     }     map<int, int>::iterator it;     for (it = m.begin(); it != m.end() && k > 0; it++) {       long long gap = it->first;       if (gap == 10) {         break;       }       long long tot = it->second;       if (gap * tot <= k) {         if (gap < 10) {           k -= gap * tot;           r += tot;           m[10] += tot;           m[gap] = 0;           for (int i = 9; i > 0; i--) {             e[i][10] += e[i - 1][gap];             ki += (10 - i) * e[i - 1][gap];           }           m[10] -= e[9][gap];         } else if (gap == 10) {           r += tot;         }       } else {         r += (k / gap);         m[10] += (k / gap);         k = 0;       }     }     if (it != m.end() && k > 0) {       long long gap = it->first;       long long tot = it->second;       if (gap * ki <= k) {         r += ki;       } else {         r += (k / gap);       }     }     cout << r;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, k, a[110];   int main() {     cin >> n >> m;     for (int i = 1; i <= m; ++i) {       cin >> k;       for (int j = k; j <= n; ++j)         if (a[j] == 0) a[j] = k;     }     for (int i = 1; i <= n; ++i) cout << a[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a[10000], b, c, d, e, f, i, j, k, l, t;     cin >> t;     while (t--) {       d = 0;       cin >> b >> c;       for (i = 0; i < b; i++) {         cin >> a[i];         d += a[i];       }       if (d < c) {         cout << d << endl;       } else if (d >= c) {         cout << c << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   string a, b;   void perform(int len) {     for (int i = 0; i < len / 2; ++i) {       if (a[i] == a[len - 1 - i]) {         a[i] =  0  +  1  - a[i];         a[len - 1 - i] =  0  +  1  - a[len - 1 - i];       }     }     if (len & 1) a[len / 2] =  0  +  1  - a[len / 2];   }   int main() {     int t;     cin >> t;     while (t--) {       cin >> n >> a >> b;       int k = 0;       vector<int> ops;       for (int i = n - 1; i >= 0; --i) {         if (a[i] != a[0]) perform(1), ++k, ops.push_back(1);         if (a[i] != b[i]) perform(i + 1), ++k, ops.push_back(i + 1);       }       cout << k <<    ;       for (int x : ops) cout << x <<    ;       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3,unroll-loops )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native )   using namespace std;   mt19937 rnd(time(nullptr));   const int N = 1e5 + 5;   unordered_set<int> g[N];   bool check(int v) {     for (auto i : g[v])       for (auto j : g[v])         if (i != j && !g[i].count(j)) return false;     cout <<  2 n  << v <<    ;     for (auto i : g[v]) cout << i <<    ;     cout <<   n ;     return true;   }   void solve() {     int n, m, k;     cin >> n >> m >> k;     for (int i = 1; i <= n; ++i) g[i].clear();     for (int i = 0; i < m; ++i) {       int u, v;       cin >> u >> v;       g[u].insert(v), g[v].insert(u);     }     set<pair<int, int> > st;     for (int i = 1; i <= n; ++i) {       st.insert({g[i].size(), i});     }     if ((long long)k * (k - 1) > 2 * m) {       cout <<  -1 n ;       return;     }     while (st.size()) {       pair<int, int> v = *st.begin();       if (v.first >= k) break;       if (v.first == k - 1 && check(v.second)) return;       st.erase(st.begin());       for (auto to : g[v.second]) {         st.erase({g[to].size(), to});         g[to].erase(v.second);         st.insert({g[to].size(), to});       }     }     if (st.size()) {       cout <<  1   << st.size() <<   n ;       for (auto v : st) cout << v.second <<    ;       cout <<   n ;     } else       cout <<  -1 n ;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t;     cin >> t;     while (t--) solve();   }
#include <bits/stdc++.h>   using namespace std;   int n, h, l, r, dp[2005][2005];   int main() {     scanf( %d%d%d%d , &n, &h, &l, &r);     memset(dp, 0xc0, sizeof(dp));     dp[0][0] = 0;     for (int i = 1, x; i <= n; i++) {       scanf( %d , &x);       for (int j = 0; j < h; j++) {         dp[i][j] = max(dp[i][j], dp[i - 1][(j - x + h) % h] + (j >= l && j <= r));         dp[i][j] =             max(dp[i][j], dp[i - 1][(j - x + 1 + h) % h] + (j >= l && j <= r));       }     }     int ans = 0;     for (int i = 0; i < h; i++) ans = max(ans, dp[n][i]);     printf( %d , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void File() {     freopen( output.txt ,  w , stdout);     freopen( input.txt ,  r , stdin);   }   int countDivisors(long long n) {     int cnt = 0;     for (long long i = 1; i <= sqrt(n); i++) {       if (n % i == 0) {         if (n / i == i)           cnt++;         else           cnt += 2;       }     }     return cnt;   }   int const N = 5e5 + 9, MOD = 1e9 + 7, oo = 1e9 + 7;   vector<vector<int>> adj(N);   vector<bool> visited(N);   vector<int> start(N), finish(N);   int n = 5;   long long arr[N];   int one, zero;   int main() {     cin >> n;     for (int i = 0; i < int(n); i++) cin >> arr[i];     sort(arr, arr + n);     for (int i = n - 1; i >= 0; i--) {       swap(arr[i], arr[n - 1]);       int l = i - 1;       int r = i + 1;       if (r == n) r = 0;       if (l == -1) l = n - 1;       if (arr[l] + arr[r] > arr[i]) {         cout <<  YES n ;         for (int i = 0; i < int(n); i++) cout << arr[i] <<    ;         return 0;       }       swap(arr[i], arr[n - 1]);     }     cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     scanf( %d , &n);     if (n % 3 == 0 || n % 3 == 1) {       cout << 1 <<     << 1 <<     << n - 2;     } else {       cout << 1 <<     << 2 <<     << n - 3;     }     return 0;   }
#ifdef LOCAL   #include <prettyprint.hpp>   #endif   #include<bits/stdc++.h>   #define endl   n    #define all(x) x.begin(), x.end()   #define rall(x) x.rbegin(), x.rend()   #define lg2(x) __lg(x)   #define rem_dupl(x) sort(all(x)); x.erase(unique(all(x)), x.end())   using namespace std;      typedef long long ll;   typedef double db;   typedef pair<int,int> ii;   #define x first   #define y second      mt19937 rand32(chrono::steady_clock::now().time_since_epoch().count());   mt19937_64 rand64(chrono::steady_clock::now().time_since_epoch().count());      const db eps = 1e-9;   const int maxn = (int)2e5 + 5;   const ll mod = (int)1e9 + 7; // 998244353      int main() {       ios_base::sync_with_stdio(0); cin.tie(0);       cout.setf(ios::fixed); cout.precision(0);          int n, m, p;       cin >> n >> m >> p;       vector<ll> a(n);       for(auto &x:a){           x = 0;           for(int i = 0; i < m; i++){               char j; cin >> j;               if(j ==  1 )                   x |= (1ll<<i);           }       }          ll ans = 0;          for(int iter = 0; iter < 50; iter++){              ll s = a[rand32() % n];           vector<int> bits;              for(int i = 0; i < m; i++)               if(s & (1ll<<i))                   bits.push_back(i);              int p = bits.size();               vector<int>cnt(1<<p, 0), cnt2(1<<p, 0);              for(auto &x:a){               int y = 0;               for(int i = 0; i < p; i++){                   if(x & (1ll<<bits[i]))                       y |= (1<<i);               }               cnt[y]++;           }              for(int mask = (1<<p) - 1; mask >= 0; mask--){                 for(int s = mask; s; s = (s - 1) & mask){                   cnt2[s] += cnt[mask];               }           }               for(int mask = 0; mask < (1<<p); mask++){               if(2*cnt2[mask] >= n){                   if(__builtin_popcountll(ans) < __builtin_popcount(mask)){                       ans = 0;                       for(int i = 0; i < p; i++)                           if(mask & (1ll<<i))                               ans |= (1ll<<bits[i]);                   }               }           }       }                for(int i = 0; i < m; i++)           cout << ((ans >> i) & 1);              return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a, b, x, y, cnt;   void RUL(int);   void DLU(int);   void LDR(int);   void URD(int);   void disp_res(int x, int y) {     printf( %d %d n , x, y);     exit(0);   }   void RUL(int n) {     if (cnt == b) {       disp_res(x, y);     };     if (n <= 0) return;     URD(n - 1);     x += 1;     cnt++;     RUL(n - 1);     y += 1;     cnt++;     RUL(n - 1);     x -= 1;     cnt++;     DLU(n - 1);   }   void DLU(int n) {     if (cnt == b) {       disp_res(x, y);     };     if (n <= 0) return;     LDR(n - 1);     y -= 1;     cnt++;     DLU(n - 1);     x -= 1;     cnt++;     DLU(n - 1);     y += 1;     cnt++;     RUL(n - 1);   }   void LDR(int n) {     if (cnt == b) {       disp_res(x, y);     };     if (n <= 0) return;     DLU(n - 1);     x -= 1;     cnt++;     LDR(n - 1);     y -= 1;     cnt++;     LDR(n - 1);     x += 1;     cnt++;     URD(n - 1);   }   void URD(int n) {     if (cnt == b) {       disp_res(x, y);     };     if (n <= 0) return;     RUL(n - 1);     y += 1;     cnt++;     URD(n - 1);     x += 1;     cnt++;     URD(n - 1);     y -= 1;     cnt++;     LDR(n - 1);   }   int main() {     cnt = 0;     x = 0, y = 0;     scanf( %d %d , &a, &b);     URD(a);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     long long int n;     cin >> n;     long long int a[n];     long long int mx = 0;     long long int sum = 0;     for (long long int i = 0; i < n; i++) {       cin >> a[i];       mx = max(mx, a[i]);       sum += a[i];     }     long long int aa = sum;     long long int bb = n - 1;     long long int ans = (aa + bb - 1) / (bb);     cout << max(ans, mx) <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};   int dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};   int dx4[] = {1, 0, -1, 0};   int dy4[] = {0, 1, 0, -1};   template <typename Arg1>   void __f(const char *name, Arg1 &&arg1) {     cerr << name <<   :   << arg1 <<   n ;     ;   }   template <typename Arg1, typename... Args>   void __f(const char *names, Arg1 &&arg1, Args &&...args) {     const char *comma = strchr(names + 1,  , );     cerr.write(names, comma - names) <<   :   << arg1 <<   |  ;     __f(comma + 1, args...);   }   template <class A, class B>   ostream &operator<<(ostream &out, const pair<A, B> &a) {     return out <<  (  << a.first <<  ,  << a.second <<  ) ;   }   template <class A>   ostream &operator<<(ostream &out, const vector<A> &a) {     for (const A &it : a) out << it <<    ;     return out;   }   template <class A, class B>   istream &operator>>(istream &in, pair<A, B> &a) {     return in >> a.first >> a.second;   }   template <class A>   istream &operator>>(istream &in, vector<A> &a) {     for (A &i : a) in >> i;     return in;   }   template <typename T, typename T1>   T amax(T &a, T1 b) {     if (b > a) a = b;     return a;   }   template <typename T, typename T1>   T amin(T &a, T1 b) {     if (b < a) a = b;     return a;   }   void solve() {     long long n, m, k;     cin >> n >> m >> k;     multiset<long long> mp;     vector<long long> v(n);     cin >> v;     vector<long long> t = v;     sort((t).begin(), (t).end(), greater<long long>());     long long sum = 0;     for (long long i = 0; i < m * k; i++) {       mp.insert(t[i]);       sum += t[i];     }     int i = 0;     vector<long long> res;     while (i < n) {       int j = i;       int cnt = 0;       while (j < n && cnt < m) {         if (mp.find(v[j]) != mp.end()) {           mp.erase(mp.find(v[j]));           cnt++;         }         j++;       }       res.push_back(j);       if ((int)((mp).size()) == m) {         break;       }       i = j;     }     cout << sum <<   n ;     ;     cout << res <<   n ;     ;   }   int main() {     ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);     int t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int const MAX_N = 100001;   int main() {     int n, m;     cin >> n >> m;     vector<int> v;     vector<int> u;     int t = m;     for (int i = 0; i < m; i++) {       v.push_back((i + 1));     }     for (int i = 0; i < m; i++) {       u.push_back(v[(int)((v.size() + 1) / 2) - 1]);       v.erase(v.begin() + (int)((v.size() + 1) / 2) - 1);     }     for (int i = 0; i < n; i++) {       cout << u[i - m * ((int)i / m)] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 2e9 + 10;   const int MOD = 1e9 + 7;   const int N = 1e3 + 10;   int n, k;   int a[N];   int main() {     ios_base::sync_with_stdio(0);     cout.tie(0);     cin.tie(0);     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     if ((a[1] & 1) && (a[n] & 1) && (n & 1))       cout <<  Yes ;     else       cout <<  No ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1000000007;   long long powmod(long long a, long long b) {     long long res = 1;     a %= mod;     assert(b >= 0);     for (; b; b >>= 1) {       if (b & 1) res = res * a % mod;       a = a * a % mod;     }     return res;   }   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   const int M = 1000000000;   char s[30];   bool answer(int x, int y) {     printf( %d %d n , x, y);     fflush(stdout);     scanf( %s , s);     return s[0] ==  b ;   }   int n;   int main() {     scanf( %d , &n);     bool ty = answer(0, M / 2);     int vl = 0, vr = M;     int l = 1, r = M;     for (int i = 1; i < n; i++) {       int mid = (l + r) >> 1;       bool ty2 = answer(mid, M / 2);       if (ty2 == ty) {         vl = max(vl, mid);         l = mid + 1;       } else {         vr = min(vr, mid);         r = mid - 1;       }     }     printf( %d %d %d %d n , vl, 0, vr, M);   }
#include <bits/stdc++.h>   using namespace std;   int sum[64];   long long a[200200];   long long calc() {     long long ans = 0;     for (int i = 0; i < 64; i++) {       ans += (1LL << i) * (sum[i] > 0);     }     return ans;   }   int main() {     int n, k, x;     cin >> n >> k >> x;     for (int i = 1; i <= n; i++) {       scanf( %I64d , a + i);       for (int j = 0; j < 32; j++) {         sum[j] += ((a[i] >> j) & 1LL);       }     }     long long ans = calc();     for (int i = 1; i <= n; i++) {       for (int j = 0; j < 32; j++) {         sum[j] -= ((a[i] >> j) & 1LL);       }       long long b = a[i];       for (int j = 0; j < k; j++) b *= x;       for (int j = 0; j < 64; j++) {         sum[j] += ((b >> j) & 1LL);       }       ans = max(ans, calc());       for (int j = 0; j < 32; j++) {         sum[j] += ((a[i] >> j) & 1LL);       }       for (int j = 0; j < 64; j++) {         sum[j] -= ((b >> j) & 1LL);       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k;   vector<int> v;   long long s[100100];   void init() {     scanf( %d , &n);     scanf( %d , &k);     v.resize(1 + n);     for (int i = 1; i <= n; i++) scanf( %d , &v[i]);     sort(v.begin() + 1, v.end());     v[0] = 0;     s[0] = v[0];     for (int i = 1; i <= n; i++) s[i] = s[i - 1] + v[i];     int pos = 1, sol = 1, best = 1, val = v[1];     for (int i = 2; i <= n; i++) {       while ((long long)(i - pos + 1) * v[i] - (s[i] - s[pos - 1]) > k) pos++;       if (i - pos + 1 > best) {         best = i - pos + 1;         val = v[i];       }     }     cout << best <<     << val << endl;   }   int main() {     init();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     ;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         if ((j + i) % 2 == 0)           printf( W );         else           printf( B );       }       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[60][60], b[60][60], n, m;   int main() {     cin >> n >> m;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         cin >> a[i][j];       }     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         cin >> b[i][j];       }     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         long long mn = min(a[i][j], b[i][j]);         long long mx = max(a[i][j], b[i][j]);         a[i][j] = mn;         b[i][j] = mx;       }     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         if (a[i][j] <= a[i][j - 1] || a[i][j] <= a[i - 1][j])           return cout <<  Impossible , 0;         if (b[i][j] <= b[i][j - 1] || b[i][j] <= b[i - 1][j])           return cout <<  Impossible , 0;       }     }     cout <<  Possible ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 1000007;   vector<int> edg[MAX];   int lvl[MAX];   multiset<int>* msets[MAX];   int k;   void mergesets(int frm, int to, int height) {     if (msets[frm]->size() > msets[to]->size()) {       swap(msets[frm], msets[to]);     }     height *= 2;     for (int x : *msets[frm]) {       int g = *(msets[to]->begin());       if (g + x - height > k) {         msets[to]->insert(x);         continue;       }       g = max(g, x);       msets[to]->erase(msets[to]->begin());       msets[to]->insert(g);     }     msets[frm]->clear();   }   void dfs(int u, int p = 0) {     lvl[u] = lvl[p] + 1;     msets[u] = new multiset<int>();     if (edg[u].size() == 1) {       msets[u]->insert(lvl[u]);     }     for (int v : edg[u]) {       if (v == p) continue;       dfs(v, u);       mergesets(v, u, lvl[u]);     }   }   int main() {     std::ios_base::sync_with_stdio(false);     cin.tie(0);     int n;     cin >> n >> k;     for (int i = 1; i < n; i++) {       int u, v;       cin >> u >> v;       edg[u].push_back(v);       edg[v].push_back(u);     }     int r = 1;     for (int i = 2; i <= n; i++) {       if (edg[i].size() > edg[r].size()) {         r = i;       }     }     dfs(r);     cout << msets[r]->size() << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k, cnt1 = 0;     cin >> n >> k;     int y = k + 1;     bool ab[y], a = false;     for (int i = 0; i < y; i++) ab[i] = false;     for (int i = 0; i < n; i++) {       string x;       cin >> x;       for (int j = 0; j < x.length(); j++) {         int h = x[j] -  0 ;         ab[h] = true;       }       for (int l = 0; l < k + 1; l++)         if (ab[l] == false) a = true;       if (!a) {         cnt1++;       }       if (a) a = false;       fill(ab, ab + y, false);     }     cout << cnt1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long double PI = 3.141592653589793238462643383279;   const long double EPS = 1e-6;   const int INF = 1e9 + 7;   const long long MOD = INF;   const long long maxn = 5e5 + 2;   const long long HASH_MODS[] = {1000000007333, 1000000009367, 1000000075747,                                  1000000158923, 1000000203119};   int n, m;   int num[maxn];   int f[maxn];   int child[maxn];   int tin[maxn];   int tout[maxn];   int cnt = 0;   int timer;   string s;   vector<pair<int, int> > hsh[maxn];   void add_edge(int a, int b) {     child[++cnt] = b;     num[cnt] = f[a];     f[a] = cnt;   }   void dfs(int v, int h) {     tin[v] = ++timer;     hsh[h].push_back({timer, hsh[h].back().second ^ (1 << (s[v] -  a ))});     for (int e = f[v]; e; e = num[e]) {       dfs(child[e], h + 1);     }     tout[v] = ++timer;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     cin >> n >> m;     for (int i = (0); i < (n); ++i) hsh[i].resize(1);     for (int i = (1); i < (n); ++i) {       int t;       cin >> t;       add_edge(t - 1, i);     }     cin >> s;     dfs(0, 0);     while (m--) {       int v, h;       cin >> v >> h;       v--;       h--;       int l = lower_bound(hsh[h].begin(), hsh[h].end(), make_pair(tin[v], -1)) -               hsh[h].begin() - 1;       int r = lower_bound(hsh[h].begin(), hsh[h].end(), make_pair(tout[v], -1)) -               hsh[h].begin() - 1;       int t = hsh[h][r].second ^ hsh[h][l].second;       bool ok = t - (t & -t);       if (!ok)         cout <<  Yes n ;       else         cout <<  No n ;     }   }
#include <bits/stdc++.h>   using namespace std;   char inp[5];   void try_catch(long long int l, long long int r) {     long long int mid = l + rand() % (r - l + 1);     printf( %lld %lld n , mid, mid);     fflush(stdout);     scanf( %s , inp);     if (inp[0] ==  Y ) exit(0);   }   int main() {     srand(time(NULL));     long long int n, k;     cin >> n >> k;     long long int l = 1, r = n;     while (1) {       while (r - l < 60) {         try_catch(max(1LL, l - k), min(n, r + k));         l = max(1LL, l - 2 * k);         r = min(n, r + 2 * k);       }       long long int mid = (l + r) / 2;       printf( %lld %lld n , l, mid);       fflush(stdout);       scanf( %s , inp);       if (inp[0] ==  Y ) {         if (l == mid) exit(0);         r = min(n, mid + k);         l = max(1LL, l - k);       } else {         l = max(1LL, mid - k);         r = min(n, r + k);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int M = 100000 + 10;   int d[M];   long long int pred[M];   long long int a[M];   long long int dp[110][M];   long long int pres[M];   long long int dq[M];   long long int yk(int i, int k) {     long long int val = dp[i][k] + pres[k];     return val;   }   int main() {     int n, m, p;     cin >> n >> m >> p;     for (int i = 2; i <= n; i++) {       cin >> d[i];       pred[i] = pred[i - 1] + d[i];     }     for (int i = 1; i <= m; i++) {       int h, t;       cin >> h >> t;       int val = t - pred[h];       a[i] = val;     }     sort(a + 1, a + m + 1);     for (int i = 1; i <= m; i++) {       pres[i] = pres[i - 1] + a[i];     }     for (int i = 1; i <= m; i++) {       dp[1][i] = (i - 0) * a[i] - (pres[i] - pres[0]);     }     for (int i = 2; i <= p; i++) {       int s = 0;       int t = 0;       for (int j = 1; j <= m; j++) {         while ((t - s) >= 2 &&                (yk(i - 1, dq[t - 1]) - yk(i - 1, dq[t - 2])) * (j - dq[t - 1]) >                    (yk(i - 1, j) - yk(i - 1, dq[t - 1])) *                        (dq[t - 1] - dq[t - 2])) {           t--;         }         dq[t] = j;         t++;         while ((t - s) >= 2 &&                dp[i - 1][dq[s]] - dq[s] * a[j] + pres[dq[s]] >                    dp[i - 1][dq[s + 1]] - dq[s + 1] * a[j] + pres[dq[s + 1]]) {           s++;         }         dp[i][j] =             dp[i - 1][dq[s]] + (j - dq[s]) * a[j] - (pres[j] - pres[dq[s]]);       }     }     cout << dp[p][m] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 10;   int n, t;   int TM[maxn], wait, ans;   priority_queue<int> in;   int main() {     scanf( %d%d , &n, &t);     for (int i = 1; i <= n; ++i) scanf( %d , &TM[i]);     for (int i = 1; i <= n + 1; ++i) {       wait = t - i;       if (wait < 0) break;       while (!in.empty() && in.top() > wait) in.pop();       ans = max(ans, (int)in.size());       in.push(TM[i] - i);     }     printf( %d n , ans);     return 0;   }