malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e18;   long long prime[16] = {2,  3,  5,  7,  11, 13, 17, 19,                          23, 29, 31, 37, 41, 43, 47, 53};   long long n, ans;   void DFS(int x, int limit, long long num, long long cnt) {     if (cnt > n) return;     if (cnt == n && num < ans) ans = num;     for (int i = 1; i <= limit; i++) {       if (ans / prime[x] < num) break;       num *= prime[x];       DFS(x + 1, i, num, cnt * (i + 1));     }   }   int main() {     scanf( %lld , &n);     ans = INF;     DFS(0, 64, 1, 1);     printf( %lld n , ans);   }
#include<bits/stdc++.h>           using namespace std;              #define ios ios_base::sync_with_stdio(false);cin.tie(NULL);           #define ll long long int           #define max3(a,b,c) max(max((a),(b)),(c))           #define max4(a,b,c,d) max(max((a),(b)),max((c),(d)))           #define min3(a,b,c) min(min((a),(b)),(c))           #define min4(a,b,c,d) min(min((a),(b)),min((c),(d)))           #define all(v) v.begin(),v.end()           #define rall(v) v.rbegin(),v.rend()           typedef pair<int,int> pii;           typedef pair<ll,ll> pll;           const long double PI = 3.14159265358979323846264338;           const long long INF = 1000000000000000000;           const long long INF1 = 1000000000;           const long long MOD = 1000000007;       //    int v[INF],m[INF];           ll fun(ll n){      int b=0;      while(n>0){          b+=n%10;          n/=10;      }      return b;    }           int main(){         ios         int t;         cin>>t;         while(t--){         ll n;         cin>>n;         if(n%2050==0){                 ll sum=n/2050;                 ll ans = fun(sum);                 cout<<ans<<endl;         }         else{             cout<<-1<<endl;         }                  }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     long long n;     cin >> n;     long long k1 = 0, k2 = 1023;     for (long long i = 0; i < n; i++) {       long long k;       char c;       cin >> c >> k;       if (c ==  | ) {         k1 |= k;         k2 |= k;       }       if (c ==  ^ ) {         k1 ^= k;         k2 ^= k;       }       if (c ==  & ) {         k1 &= k;         k2 &= k;       }     }     cout << 2 << endl;     cout <<  |   << (k1 ^ (k2 ^ 1023)) << endl <<  ^   << (k2 ^ 1023);     return 0;   }
#include <bits/stdc++.h>   template <typename Arg1>   void __f(const char* name, Arg1&& arg1) {     std::cout << name <<   :   << arg1 <<   n ;   }   template <typename Arg1, typename... Args>   void __f(const char* names, Arg1&& arg1, Args&&... args) {     const char* comma = strchr(names + 1,  , );     std::cout.write(names, comma - names) <<   :   << arg1 <<   |  ;     __f(comma + 1, args...);   }   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long i, j, n, m, k, cnt = 0, ans = 0, t = 1;     cin >> n;     long long a[n];     for (i = 0; i < n; i++) cin >> a[i];     priority_queue<long long, vector<long long>, greater<long long> > pq;     for (i = 0; i < n; i++) {       if (!pq.empty() && pq.top() < a[i]) {         ans += (a[i] - pq.top());         pq.pop();         pq.push(a[i]);       }       pq.push(a[i]);     }     return cout << ans, 0;     return 0;   }
#include <bits/stdc++.h>   bool pr[3001];   int prm[3001];   using namespace std;   void primes() {     int i, j;     for (i = 0; i < 3001; i++) pr[i] = true;     pr[0] = false;     pr[1] = false;     for (i = 2; i <= sqrt(3000); i++) {       if (pr[i]) {         for (j = i; i * j <= 3001; j += 1) {           pr[i * j] = false;         }       }     }   }   int main() {     primes();     int n, i, k = 0, j, ans = 0;     cin >> n;     for (i = 0; i < 3001; i++) {       if (pr[i]) prm[k++] = i;     }     for (j = 6; j <= n; j++) {       int ct = 0;       for (i = 0; prm[i] <= j; i++) {         if (i >= k) break;         if (j % prm[i] == 0) ct++;       }       if (ct == 2) ans++;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int chk[300004][3];   int visit[300004];   vector<int> vec[300004];   vector<pair<int, int>> vecp;   void dfs(int x) {     visit[x] = 1;     for (int i = 0; i < vec[x].size(); i++) {       if (visit[vec[x][i]] == 0) {         dfs(vec[x][i]);         chk[x][0] += chk[vec[x][i]][0];         chk[x][1] += chk[vec[x][i]][1];         chk[x][2] += chk[vec[x][i]][2];         vecp.push_back({chk[vec[x][i]][1], chk[vec[x][i]][2]});       }     }   }   int main() {     int a, b, c, d, e, m = 0;     cin >> a;     int r = 0, bl = 0;     for (int i = 1; i <= a; i++) {       cin >> b;       if (b == 1)         r++;       else if (b == 2)         bl++;       chk[i][b]++;     }     for (int i = 1; i < a; i++) {       cin >> b >> c;       vec[b].push_back(c);       vec[c].push_back(b);     }     dfs(1);     for (int i = 0; i < vecp.size(); i++) {       int red = vecp[i].first;       int blue = vecp[i].second;       int redo = r - red;       int blueo = bl - blue;       if (red >= 1 && blue == 0 && blueo >= 1 && redo == 0) {         m++;       } else if (red == 0 && blue >= 1 && blueo == 0 && redo >= 1) {         m++;       }     }     cout << m << endl;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 1011;   const long long INF = 5e16;   namespace IO {   inline long long read() {     long long x = 0;     bool f = 0;     char ch = getchar();     for (; !isdigit(ch); ch = getchar()) f ^= (ch ==  - );     for (; isdigit(ch); ch = getchar()) x = x * 10 + (ch ^ 48);     return f ? -x : x;   }   inline void write(long long x) {     if (x < 0) putchar( - ), x = -x;     if (x > 9) write(x / 10);     putchar(x % 10 | 48);   }   inline void wrn(long long x) {     write(x);     putchar(   );   }   inline void wln(long long x) {     write(x);     putchar(  n );   }   inline void wlnn(long long x, long long y) {     wrn(x);     wln(y);   }   }  // namespace IO   using namespace IO;   namespace Cesare {   long long x, k, p;   double Ans = 0, f[N][N];   int main() {     x = read(), k = read(), p = read();     double Mul = p * 0.01, Add = 1.0 - Mul;     for (register int i = 0; i <= k; ++i)       for (register int j = x + i; !(j & 1); j >>= 1) ++f[0][i];     for (register int i = (1); i <= (k); ++i)       for (register int j = (0); j <= (k); ++j) {         if (j) f[i][j - 1] += f[i - 1][j] * Add;         if (k >= (j << 1)) f[i][j << 1] += (f[i - 1][j] + 1) * Mul;       }     return printf( %.12lf n , f[k][0]), 0;   }   }  // namespace Cesare   int main() { return Cesare::main(); }
#include <bits/stdc++.h>   using namespace std;   int main() {     int q, l, k, n, m, a, b, c, sum = 0;     cin >> l >> k;     a = l * 2;     b = l * 5;     c = l * 8;     sum = ((a / k) + (b / k) + (c / k));     if (a % k != 0) sum++;     if (b % k != 0) sum++;     if (c % k != 0) sum++;     cout << sum << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int sum[1000100];   int main() {     string a, b;     cin >> a >> b;     int cnt = 0;     for (int i = 0; i < b.size(); i++) {       if (b[i] ==  1 ) cnt++;     }     sum[0] = a[0] -  0 ;     for (int i = 1; i < a.size(); i++) {       sum[i] = sum[i - 1] + a[i] -  0 ;     }     int l = 0, r = b.size() - 1;     int ans = 0;     while (r < a.size()) {       if (cnt % 2 == 0 && (sum[r] - sum[l] + a[l] -  0 ) % 2 == 0) {         ans++;       } else if (cnt % 2 != 0 && (sum[r] - sum[l] + a[l] -  0 ) % 2 != 0) {         ans++;       }       l++;       r++;     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   char a[1000][1001], s[] =  DIMA ;   bool b = 0, f[1000][1000];   int q, w, d[1000][1000];   void l(short int r, short int t, short int e) {     int y = 0;     if ((f[r][t]) || (b)) {       b = 1;       return;     }     f[r][t] = 1;     e %= 4;     if ((r) && (a[r - 1][t] == s[e])) {       if (d[r - 1][t] == -1) l(r - 1, t, e + 1);       if (y < d[r - 1][t]) y = d[r - 1][t];     }     if ((r < q - 1) && (a[r + 1][t] == s[e])) {       if (d[r + 1][t] == -1) l(r + 1, t, e + 1);       if (y < d[r + 1][t]) y = d[r + 1][t];     }     if ((t) && (a[r][t - 1] == s[e])) {       if (d[r][t - 1] == -1) l(r, t - 1, e + 1);       if (y < d[r][t - 1]) y = d[r][t - 1];     }     if ((t < w - 1) && (a[r][t + 1] == s[e])) {       if (d[r][t + 1] == -1) l(r, t + 1, e + 1);       if (y < d[r][t + 1]) y = d[r][t + 1];     }     if (e == 0) y++;     d[r][t] = y;   }   int main() {     int e, r, t = 0, c;     scanf( %d%d , &q, &w);     for (e = 0; e < q; e++) {       scanf( %s , a[e]);       for (r = 0; r < w; r++) {         d[e][r] = -1;         f[e][r] = 0;       }     }     for (e = 0; e < q; e++)       for (r = 0; r < w; r++)         if (a[e][r] ==  D ) {           if (d[e][r] == -1) l(e, r, 1);           if (b) goto stop;           if (t < d[e][r]) t = d[e][r];         }   stop:     if (b)       printf( Poor Inna! );     else if (t == 0)       printf( Poor Dima! );     else       printf( %d , t);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[100010], b[100010];   int main(int argc, char *argv[]) {     int n;     long long t, Sum = 0;     scanf( %d , &n);     for (int i = 1; i <= n; ++i) {       scanf( %lld , &t);       Sum += t;     }     for (int i = 1; i <= n; ++i) scanf( %lld , &b[i]);     sort(b + 1, b + 1 + n);     if (Sum <= (b[n] + b[n - 1]))       puts( YES );     else       puts( NO );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long infl = 0x3f3f3f3f3f3f3f3fLL;   const long long infi = 0x3f3f3f3f;   const long long mod = infl;   long long mygcd(long long a, long long b) {     if (b == 0) {       return a;     }     return mygcd(b, a % b);   }   long long mypow(long long a, long long b) {     long long res = 1;     while (b) {       if (b & 1) res = (res * a) % mod;       a = (a * a) % mod;       b >>= 1;     }     return res;   }   void solve() {     long long n, d;     cin >> n >> d;     vector<long long> pro(n);     for (long long i = 1; i < n - 1; i++) {       cin >> pro[i];     }     vector<vector<long long>> gr(n);     for (long long i = 0; i < n; i++) {       long long x, y;       cin >> x >> y;       gr[i] = {x, y};     }     auto isok = [&](long long x) {       vector<long long> best(n, -1);       best[0] = x;       queue<long long> q;       q.push(0);       while (q.size()) {         long long front = q.front();         q.pop();         for (long long i = 1; i < n; i++) {           if (i == front) {             continue;           }           long long need =               d * (abs(gr[front][0] - gr[i][0]) + abs(gr[front][1] - gr[i][1]));           if (need > best[front]) {             continue;           }           long long new_best = best[front] - need + pro[i];           if (new_best > best[i]) {             best[i] = new_best;             q.push(i);           }         }       }       if (best[n - 1] == -1) {         return false;       }       return true;     };     long long l = 0;     long long r = infi;     while (l < r) {       long long m = (l + r) / 2;       if (isok(m)) {         r = m;       } else {         l = m + 1;       }     }     cout << r <<   n ;   }   signed main() {     ios_base::sync_with_stdio(false);     cout << fixed << setprecision(20);     cin.tie(NULL);     long long t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double inf = 1.0 / 0.0;   const double pi = 2 * acos(0.0);   map<char, int> tab, tab1;   char x;   int main() {     tab1[ Q ] = 9;     tab[ q ] = 9;     tab1[ R ] = 5;     tab[ r ] = 5;     tab1[ B ] = 3;     tab[ b ] = 3;     tab1[ P ] = 1;     tab[ p ] = 1;     tab1[ N ] = 3;     tab[ n ] = 3;     tab1[ K ] = 0;     tab[ k ] = 0;     ios_base::sync_with_stdio(false);     int b = 0, w = 0;     for (int i = 0; i < 8; i++) {       for (int j = 0; j < 8; j++) {         x = getchar();         if (tab.count(x) != 0) {           b += tab[x];         } else if (tab1.count(x) != 0) {           w += tab1[x];         }       }       getchar();     }     if (b > w)       cout <<  Black n ;     else if (w > b)       cout <<  White n ;     else       cout <<  Draw n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double pi =       3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;   const int MR = 1e5 + 10;   const long long inf = 1e18;   long long dp[21][MR];   int A[21][MR];   int a[MR];   int freq[MR], gp, gk;   long long cost;   long long ile(int b, int e) {     while (gp > b) {       cost += freq[a[gp - 1]];       freq[a[gp - 1]]++;       gp--;     }     while (gp < b) {       freq[a[gp]]--;       cost -= freq[a[gp]];       gp++;     }     while (gk > e) {       freq[a[gk - 1]]--;       cost -= freq[a[gk - 1]];       gk--;     }     while (gk < e) {       cost += freq[a[gk]];       freq[a[gk]]++;       gk++;     }     return cost;   }   void compute(int k, int l, int r, int Al, int Ar) {     if (l >= r) return;     assert(Al <= Ar);     int m = (l + r) / 2;     dp[k][m] = inf;     for (int i = (max(Al, A[k - 1][m])); i < (min(Ar + 1, m)); ++i) {       long long cnt = ile(i + 1, m + 1);       if (dp[k][m] > dp[k - 1][i] + cnt) {         dp[k][m] = dp[k - 1][i] + cnt;         A[k][m] = i;       }     }     compute(k, l, m, Al, A[k][m]);     compute(k, m + 1, r, A[k][m], Ar);   }   int main() {     int n, k;     scanf( %d%d , &n, &k);     for (int i = (1); i <= (n); ++i) scanf( %d , &a[i]);     gp = 1;     gk = 1;     for (int i = (1); i <= (n); ++i) {       dp[1][i] = ile(1, i + 1);       A[1][i] = 0;     }     for (int i = (2); i <= (k); ++i) compute(i, i, n + 1, i - 1, n);     cout << dp[k][n] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long read() {     long long x = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = (x * 10) + (ch -  0 );       ch = getchar();     }     return x * f;   }   long long Pow[25][505], n, V, ans, B;   long long val[505];   void dfs2(long long i, long long b, long long a) {     if ((double)b * b > V / a) {       return;     }     if (i > n) {       B = max(B, b);       return;     }     for (register long long j = val[i]; j >= 0; --j) {       dfs2(i + 1, b * Pow[i][j], a);     }   }   long long ansA, ansB, ansC;   void dfs1(long long i, long long a) {     if ((double)a * a * a > V) {       return;     }     if (i > n) {       const long long t = V / a;       long long Smax = 4 * a * sqrt(t) + 2 * t;       if (Smax >= ans) return;       B = 0, dfs2(1, 1, a);       long long c = V / a / B, Ans = (a * B + B * c + c * a) << 1;       if (Ans < ans) {         ans = Ans;         ansA = a, ansB = B, ansC = c;       }       return;     }     for (register long long j = val[i]; j >= 0; --j) {       val[i] -= j;       dfs1(i + 1, a * Pow[i][j]);       val[i] += j;     }   }   int main() {     long long T;     cin >> T;     while (T--) {       cin >> n;       V = 1;       for (register long long i = 1; i <= n; ++i) {         long long a, b;         cin >> a >> b;         val[i] = b;         Pow[i][0] = 1;         for (register long long j = 1; j <= b; ++j) {           Pow[i][j] = Pow[i][j - 1] * a;         }         V *= Pow[i][b];       }       ans = 1ll << 62;       dfs1(1, 1);       cout << ans <<     << ansA <<     << ansB <<     << ansC << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ii = pair<int, int>;   using vi = vector<int>;   const double PI = acos(-1);   const double EPS = 1e-9;   int main() {     ios_base::sync_with_stdio(0);     int n, m;     cin >> n >> m;     int mt[n][m];     int ans = 0;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         cin >> mt[i][j];         if (j == 0) {           ans ^= mt[i][j];         }       }     }     if (ans > 0) {       cout <<  TAK n ;       for (int i = 0; i < n; i++) {         cout << 1;         if (i == n - 1)           cout << endl;         else           cout <<    ;       }     } else {       ii res(-1, -1);       for (int i = 0; i < n; i++) {         for (int j = 1; j < m; j++) {           int kk = ans ^ mt[i][0] ^ mt[i][j];           if (kk > 0) {             res.first = i;             res.second = j;           }         }       }       int aa = ans ^ 1 ^ 0;       if (res.first >= 0)         ans = ans ^ mt[res.first][0] ^ mt[res.first][res.second];       if (ans > 0) {         cout <<  TAK n ;         for (int i = 0; i < n; i++) {           if (i == res.first)             cout << res.second + 1;           else             cout << 1;           if (i == n - 1)             cout << endl;           else             cout <<    ;         }       } else {         cout <<  NIE n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   vector<long long int> prm(1000010, 1);   long long int P = 1e9 + 7;   long long int M = 998244353;   char adjlist[1001][1001];   bool visited[1000001] = {false};   long double pi = 3.14159265358979323846264338327950;   map<int, int> visit;   map<int, set<int>> g;   int cc = 0;   vector<pair<int, int>> moves = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};   int lps[1000000];   vector<pair<int, int>> final_set;   bool comp(const pair<long long int, long long int> &a,             const pair<long long int, long long int> &b) {     if (a.first == b.first) return a.second > b.second;     return a.first < b.first;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long int n, m, s, f;     cin >> n >> m >> s >> f;     bool flag = true;     long long int curr = s;     if (s > f) flag = false;     long long int i, j;     long long int t, x, y;     bool mflag = false;     long long int back = 0;     string str =   ;     for (i = 0; i < m; i++) {       if (i == 0)         back = 0;       else         back = t;       cin >> t >> x >> y;       if (curr == f) continue;       if (t - 1 != back) {         while (back + 1 < t) {           if (flag == false) {             str.push_back( L );             curr--;           } else {             str.push_back( R );             curr++;           }           if (curr == f) break;           back++;         }       }       if (curr == f) continue;       if (flag == false) {         if (curr < x || curr - 1 > y) {           str.push_back( L );           curr--;           continue;         } else {           str.push_back( X );           continue;         }       } else {         if (curr > y || curr + 1 < x) {           str.push_back( R );           curr++;           continue;         } else {           str.push_back( X );           continue;         }       }     }     if (curr != f) {       if (flag == false) {         for (i = curr; i > f; i--) str.push_back( L );       } else {         for (i = curr; i < f; i++) str.push_back( R );       }     }     cout << str <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   mt19937 rnd;   const long long maxn = 2e6 + 5;   const long long mod = 1e9 + 7;   long long fac[maxn];   long long inv[maxn];   vector<char> prime(maxn, true);   long long spf[maxn];   long long binpow(long long a, long long b) {     if (b == 0) return 1;     if (b == 1) return a % mod;     if (b == 2) return (a * a) % mod;     if (b % 2 == 0) return binpow((a * a) % mod, b / 2);     if (b % 2 == 1) return (a * binpow((a * a) % mod, b / 2)) % mod;   }   void buildprimes() {     prime[0] = prime[1] = false;     for (long long i = 2; i < maxn; ++i) {       if (prime[i]) {         spf[i] = i;         if (i * 1ll * i < maxn) {           for (long long j = i * i; j < maxn; j += i) {             prime[j] = false;             spf[j] = i;           }         }       }     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     fac[1] = fac[0] = 1;     for (long long i = 2; i < maxn; i++) {       fac[i] = (fac[i - 1] * i) % mod;     }     for (long long i = 1; i < maxn; i++) {       inv[i] = binpow(fac[i], mod - 2);     }     buildprimes();     int q;     cin >> q;     while (q--) {       int x, y;       cin >> x >> y;       if (y == 1) {         cout <<  1 n ;         continue;       }       long long ans = 1;       ans = binpow(2, y - 1);       while (x > 1) {         long long cur = 0;         long long p = spf[x];         while (x % p == 0) {           x /= p;           cur++;         }         long long C = (((fac[cur + y - 1] * inv[y - 1]) % mod) * inv[cur]) % mod;         ans = (ans * C) % mod;       }       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     string t =   ;     for (int i = 0; i < s.length(); i++) {       if (s[i] !=  a  && s[i] !=  e  && s[i] !=  i  && s[i] !=  o  &&           s[i] !=  u  && s[i] !=  y  && s[i] !=  Y  && s[i] !=  A  &&           s[i] !=  E  && s[i] !=  I  && s[i] !=  O  && s[i] !=  U ) {         t += s[i];       }     }     string p =   ;     for (int i = 0; i < t.length(); i++) {       char c = t[i];       if (isupper(c)) {         p += tolower(c);       } else {         p += c;       }     }     string l =   ;     for (int i = 0; i < p.length(); i++) {       l +=  . ;       l += p[i];     }     cout << l;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     string s;     for (int i = 1; i < 1000000 && s.size() < 1000; i++) {       char val[20];       sprintf(val,  %d , i);       s += val;     }     int n;     cin >> n;     cout << s[n - 1];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e5;   const double EPS = 1e-8;   int a[MAXN], b[MAXN];   int n, p;   bool f(double T) {     double have = p * T;     for (int i = 0; i < n; ++i) {       if (a[i] * T > b[i] + EPS) have += b[i] - a[i] * T;     }     return have > 0.0 + EPS;   }   int main() {     cin >> n >> p;     long long sum = 0;     for (int i = 0; i < n; ++i) {       cin >> a[i] >> b[i];       sum += a[i];     }     if (sum <= p) {       cout << -1;       return 0;     }     double left = 0, right = 1e10;     for (int i = 0; i < 80; ++i) {       double middle = (left + right) / 2;       if (f(middle))         left = middle;       else         right = middle;     }     cout << fixed;     cout.precision(10);     cout << left;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     long long mn, mx, n, m;     cin >> n >> m;     mx = n - m;     mx++;     mx = (mx * (mx - 1)) / 2;     mn = n / m;     long long temp = n / m;     if (n % m != 0) {       mn = (n % m) * ((mn * (mn + 1)) / 2);       m -= (n % m);       mn += m * ((temp * (temp - 1)) / 2);     } else       mn = m * ((temp * (temp - 1)) / 2);     cout << mn <<     << mx << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   using namespace std;   mt19937 rnd(chrono::steady_clock().now().time_since_epoch().count());   const int N = 765;   const long long inf = (long long)4e18;   long long dp[N][N];   long long f[N];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     int n, m;     cin >> n >> m;     long long a[n];     for (int i = 0; i < n; i++) {       cin >> a[i];     }     for (int i = 0; i < N; i++) {       for (int j = 0; j < N; j++) {         dp[i][j] = -inf;       }     }     dp[n][0] = 0;     for (int i = n - 1; i >= 0; i--) {       for (int j = 0; j <= n; j++) {         dp[i][j] = min(a[i] + dp[i + 1][j], a[i]);         if (j > 0) {           dp[i][j] = max(dp[i][j], dp[i + 1][j - 1]);         }       }     }     for (int j = 0; j <= n; j++) f[j] = dp[0][j];     long long b;     for (int i = 1; i <= m; i++) {       cin >> b;       for (int i = 0; i <= n; i++) {         if (b + f[i] >= 0) {           cout << i <<   n ;           break;         }       }     }     return 0;   }