malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int mod = (int)1e9;   const long long inf = (long long)3e18;   const int base = 1000 * 1000 * 1000;   const int maxn = 20;   const long double pi = acosl(-1.0);   const long double eps = 1e-5;   void error() { exit(1); }   int n;   bool flag = true;   long long A, cf, cm, m;   vector<long long> d;   long long ans = 0, minans;   long long predmin, curmin, people;   unordered_map<long long, long long> st;   set<long long> val;   set<pair<long long, int> > powerans;   set<pair<long long, int> > power, nopower;   void solve() {     scanf( %d %I64d %I64d %I64d %I64d , &n, &A, &cf, &cm, &m);     d.resize(n);     for (int i = 0; i < n; i++) {       scanf( %I64d , &d[i]);       nopower.insert(make_pair((-1) * d[i], i));       st[d[i]]++;       val.insert(d[i]);     }     val.insert(A);     val.insert(A + 1);     while ((int)nopower.size() && (A + (*nopower.begin()).first) <= m) {       pair<long long, int> v = (*nopower.begin());       nopower.erase(nopower.begin());       st[(-1) * v.first]--;       st[A]++;       m -= (A + v.first);       power.insert(make_pair((-1) * v.first, v.second));       ans += cf;     }     predmin = (*val.begin());     val.erase(val.begin());     curmin = (*val.begin());     val.erase(*val.begin());     people = st[predmin];     ans += predmin * cm;     minans = predmin;     powerans = power;     while ((int)power.size() || flag) {       if (predmin == A || (int)power.size() == n) {         ans = A * cm + n * cf;         break;       }       if ((int)power.size() && (m <= 0 || !flag)) {         pair<long long, int> v = (*power.begin());         power.erase(power.begin());         if (predmin >= v.first)           m += (A - predmin);         else           m += (A - v.first);         if (v.first <= predmin)           people++;         else           st[v.first]++;       }       flag = false;       long long del = m / people;       if (m > 0 && del > 0) {         flag = true;         if (curmin <= predmin + del) {           m -= (curmin - predmin) * people;           people += st[curmin];           predmin = curmin;           curmin = (*val.begin());           val.erase(*val.begin());         } else {           predmin += del;           m -= del * people;         }         long long curans = predmin * cm + (int)power.size() * cf;         if (predmin == A) curans += (people - (int)power.size()) * cf;         if (ans < curans) {           ans = curans;           minans = predmin;           while ((int)powerans.size() != (int)power.size()) {             powerans.erase(*powerans.begin());           }         }       }     }     printf( %I64d n , ans);     while ((int)powerans.size()) {       pair<long long, int> v = (*powerans.begin());       powerans.erase(powerans.begin());       d[v.second] = A;     }     for (int i = 0; i < n; i++)       if (d[i] < minans) d[i] = minans;     for (int i = 0; i < n; i++) printf( %I64d  , d[i]);   }   int main() {     solve();     return 0;   }
#include <bits/stdc++.h>   const int MAXN = 1000001;   int n, m, a[MAXN], b[MAXN];   int box[MAXN], axi[MAXN];   int n1, n2;   int main() {     std::cin >> n >> m;     for (int i = 1; i <= n; i++) {       std::scanf( %d , a + i);       if (a[i] <= m) {         b[++n1] = a[i];         box[a[i]]++;       }     }     if (!n1) {       std::puts( 1 0 );       return 0;     }     std::sort(b + 1, b + 1 + n1);     int n2 = std::unique(b + 1, b + 1 + n1) - b - 1;     for (int i = 1; i <= n2; i++)       for (int j = 1; j <= m / b[i]; j++) axi[b[i] * j] += box[b[i]];     int sum = 0, lcm;     for (int i = 1; i <= m; i++) {       if (axi[i] > sum) sum = axi[i], lcm = i;     }     std::printf( %d %d n , lcm, sum);     for (int i = 1; i <= n; i++)       if (!(lcm % a[i])) std::printf( %d  , i);     std::putchar(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 100;   const int mod = 1e9 + 7;   mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());   int n, trie[maxn][26], en[maxn], nxt;   string s;   void ins(int cur, int i) {     if (i == (int)s.size())       en[cur] = 1;     else {       int le = (s[i] -  a );       if (!trie[cur][le]) trie[cur][le] = ++nxt;       ins(trie[cur][le], i + 1);     }   }   multiset<int> merge(multiset<int> a, multiset<int> b) {     if ((int)a.size() < (int)b.size()) swap(a, b);     for (auto aa : b) a.insert(aa);     return a;   }   multiset<int> dfs(int cur, int dep) {     multiset<int> ret;     for (int i = 0; i < 26; i++)       if (trie[cur][i]) ret = merge(ret, dfs(trie[cur][i], dep + 1));     if (en[cur])       ret.insert(dep);     else if (cur != 0) {       int a = *prev(ret.end());       ret.erase(prev(ret.end()));       ret.insert(dep);     }     return ret;   }   int main() {     ios_base::sync_with_stdio(false), cin.tie(0);     cin >> n;     for (int i = 0; i < n; i++) {       cin >> s;       ins(0, 0);     }     multiset<int> res = dfs(0, 0);     long long ans = 0;     for (auto a : res) ans += a;     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 2e5 + 10;   long long arr[MAX], arr2[MAX];   int n;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n;     for (int i = 0; i < n; ++i) cin >> arr[i];     for (int i = 0; i < n; ++i) cin >> arr2[i];     vector<pair<long long, long long> > vp;     for (int i = 0; i < n; ++i) vp.push_back({arr[i], arr2[i]});     sort(vp.begin(), vp.end());     for (int i = 0; i < n; ++i) arr[i] = vp[i].first, arr2[i] = vp[i].second;     int idx = 0;     int cur = arr[0];     long long ans = 0, sum = 0;     priority_queue<long long> q;     while (1) {       ans += sum;       while (idx < n && cur == arr[idx]) {         sum += arr2[idx];         q.push(arr2[idx]);         idx++;       }       if (q.size() == 0) {         if (idx == n) break;         cur = arr[idx];       } else {         long long x = q.top();         q.pop();         sum -= x;         cur++;       }     }     return cout << ans <<   n , 0;   }
#include <bits/stdc++.h>   using namespace std;   using ld = long double;   ld sq(ld x) { return x * x; }   int main() {     size_t n;     cin >> n;     vector<ld> mn(n), mx(n), mnk(n), mxk(n);     for (size_t i = 0; i != n; ++i) {       cin >> mx[i];     }     for (size_t i = 0; i != n; ++i) {       cin >> mn[i];     }     mnk[0] = mn[0];     mxk[0] = mx[0];     for (size_t i = 1; i != n; ++i) {       mnk[i] = mnk[i - 1] + mn[i];       mxk[i] = mxk[i - 1] + mx[i];     }     vector<ld> a(n), b(n), ak(n), bk(n);     ak[n - 1] = 1;     bk[n - 1] = 1;     for (size_t i = 0; i < n - 1; ++i) {       ld u = mxk[i];       ld v = mnk[i];       ld D = sqrt(sq(u + v) - 4 * u);       ld x1 = (u + v + D) / 2;       ld x2 = (u + v - D) / 2;       ak[i] = x1;       bk[i] = x2;     }     a[0] = ak[0];     b[0] = bk[0];     for (size_t i = 1; i != n; ++i) {       a[i] = ak[i] - ak[i - 1];       b[i] = bk[i] - bk[i - 1];     }     for (size_t i = 0; i != n; ++i) cout << a[i] <<    ;     cout << endl;     for (size_t i = 0; i != n; ++i) cout << b[i] <<    ;     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long MOD = 1000000007;   long long binary_exp(long long a, long long b) {     long long ans = 1;     while (b > 0) {       if (b & 1) {         ans = (ans * a);       }       a = (a * a);       b = b >> 1;     }     return ans;   }   int fn(int low, vector<int> &a, int p) {     int k = low;     for (int i = 0; i < a.size(); i++) {       k = low + i;       int j = upper_bound(a.begin(), a.end(), k) - a.begin();       if ((j - i) % p == 0) {         return 0;       }     }     return 1;   }   map<long long, long long> mp;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     long long T;     T = 1;     while (T--) {       int n, p;       cin >> n >> p;       vector<int> a(n);       for (int i = 0; i < n; i++) {         cin >> a[i];       }       sort(a.begin(), a.end());       int low = max(a[0], a[n - 1] - n + 1);       for (int i = 0; i < n; i++) {         low = max(low, a[i] - i);       }       int high = a[n - 1];       if (!fn(low, a, p)) {         cout << 0 << endl;         cout << endl;         continue;       }       int z = low;       while (low < high) {         int mid = (low + high) / 2;         mid++;         if (fn(mid, a, p)) {           low = mid;         } else {           high = mid - 1;         }       }       cout << low - z + 1 << endl;       for (int i = z; i <= low; i++) {         cout << i <<    ;       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = 1e18;   const long long M = 1e9 + 9;   long long axm(long long a, long long x, long long m) {     a %= m;     long long r = 1;     while (x > 0) {       if (x & 1) r = r * a % m;       a = a * a % m;       x /= 2;     }     return r;   }   long long inv(long long a, long long m) { return axm(a, m - 2, m); }   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   struct P {     long long x, y;   };   long long dist(P a, P b) {     return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);   }   long long test(P p1, P p2, P p3, P p4) {     long long d2 = dist(p1, p2);     long long d3 = dist(p1, p3);     long long d4 = dist(p1, p4);     if (d2 == 0 || d3 == 0 || d4 == 0) return 0;     if (d2 == d3 && 2 * d2 == d4 && 2 * dist(p2, p4) == dist(p2, p3)) {       return 1;     }     if (d3 == d4 && 2 * d3 == d2 && 2 * dist(p3, p2) == dist(p3, p4)) {       return 1;     }     if (d2 == d4 && 2 * d2 == d3 && 2 * dist(p2, p3) == dist(p2, p4)) {       return 1;     }     return 0;   }   P p[4][4];   int main(int argc, char **argv) {     ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);     ;     long long n;     cin >> n;     for (long long tt = 0; tt < n; tt++) {       for (long long i = 0; i < 4; i++) {         long long xx, yy, aa, bb;         cin >> xx >> yy >> aa >> bb;         p[i][0].x = xx;         p[i][0].y = yy;         for (long long j = 1; j < 4; j++) {           p[i][j].x = aa - (p[i][j - 1].y - bb);           p[i][j].y = bb + (p[i][j - 1].x - aa);         }       }       long long ans = inf;       for (long long i = 0; i < 4; i++) {         for (long long j = 0; j < 4; j++) {           for (long long k = 0; k < 4; k++) {             for (long long l = 0; l < 4; l++) {               long long s = i + j + k + l;               if (s < ans && test(p[0][i], p[1][j], p[2][k], p[3][l])) {                 ans = s;               }             }           }         }       }       if (ans == inf) ans = -1;       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double pi = acos(-1.0);   const int inf = (int)1e9;   const long long int infll = (long long int)1e18;   const double inf1 = 1e-9;   const int ss = (int)1e6 + 3;   const int base = inf;   bool pred(const pair<int, int>& i, const pair<int, int>& j) {     if (i.first == j.first)       return i.second > j.second;     else       return i.first > j.first;   }   bool pred2(const int& i, const int& j) { return i > j; }   int main() {     int n;     scanf( %d , &n);     vector<int> a(n);     int k = 100001;     vector<vector<int> > b(k);     int mx = -1;     for (int i = 0; i < n; ++i) {       scanf( %d , &a[i]);       b[a[i]].push_back(i);       mx = max(a[i], mx);     }     if (mx == 1) {       cout << b[1].size() << endl;       for (int i = 0; i < n; ++i) cout << i + 1 <<    ;       return 0;     }     bool t = true;     for (int j = 2; j <= mx; ++j) {       if (b[j].size() > b[j - 1].size()) {         t = false;         break;       }     }     if (!t) {       cout <<  -1 ;       return 0;     }     cout << b[1].size() << endl;     vector<int> c(n);     for (int i = 1; i <= mx; ++i) {       for (int j = 0; j < b[i].size(); ++j) c[b[i][j]] = j + 1;     }     for (int i = 0; i < n; ++i) cout << c[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int x, y, a, b;     scanf( %d %d %d %d , &x, &y, &a, &b);     int minV = max(a, b + 1);     int maxP = min(y, x - 1);     vector<pair<int, int> > output;     int total = 0;     for (int v = minV; v <= x; v++) {       for (int p = b; p <= min(v - 1, maxP); p++) {         output.push_back(pair<int, int>(v, p));         ++total;       }     }     printf( %d n , total);     for (int k = 0; k < output.size(); k++) {       printf( %d %d n , output[k].first, output[k].second);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long A[1 << 20];   long long B[1 << 20];   long long getIP() {     int a[4];     scanf( %d.%d.%d.%d , &a[0], &a[1], &a[2], &a[3]);     int i;     long long res = 0;     for (i = (0); i < (4); ++i) res = (res << 8) | a[i];     return res;   }   void printIP(long long res) {     int a[4];     int i;     for (i = (0); i < (4); ++i) {       a[i] = int(res & 255);       res >>= 8;     }     printf( %d.%d.%d.%d n , a[3], a[2], a[1], a[0]);   }   int main() {     int n, k;     scanf( %d%d , &n, &k);     int i, j;     for (i = (0); i < (n); ++i) A[i] = getIP();     long long mask = 0;     for (i = (32) - 1; i >= (1); --i) {       if (i != 32) mask |= 1LL << i;       for (j = (0); j < (n); ++j) B[j] = A[j] & mask;       sort(B, B + n);       if (k == unique(B, B + n) - B) {         printIP(mask);         return 0;       }     }     printf( -1 n );     return 0;   };
#include <bits/stdc++.h>   #pragma comment(linker,  /stack:200000000 )   #pragma GCC optimize( Ofast )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native )   using namespace std;   const int mod = 1e9 + 7;   const int N = 1e6 + 10;   const long long INF = 1e18;   const long double EPS = 1e-12;   int d, s;   bool vis[5105][515];   int pa[5105][515];   int parem[5105][515];   vector<int> ans;   vector<pair<int, vector<int> > > fin;   void go(int sum, int rem, int dig, int len) {     if (len == 0) {       reverse(ans.begin(), ans.end());       fin.push_back(make_pair(ans.size(), ans));       return;     }     ans.push_back(dig);     int dd = pa[sum][rem];     int remm = parem[sum][rem];     go(sum - dig, remm, dd, len - 1);   }   queue<vector<int> > qu;   void solve(int dii) {     while (not qu.empty()) qu.pop();     vis[dii][dii % d] = 1;     qu.push({dii, dii % d, dii, 0});     while (not qu.empty()) {       auto vec = qu.front();       qu.pop();       int sum = vec[0], rem = vec[1], dig = vec[2], len = vec[3];       if (sum > s) continue;       if (sum > 5001) continue;       if (len > 50001) continue;       for (int i = 0; i <= 9; i++) {         if (sum == 0 && i == 0) continue;         int sumi = sum + i;         int remi = (rem * 10 + i) % d;         if (not vis[sumi][remi]) {           pa[sumi][remi] = dig;           parem[sumi][remi] = rem;           vis[sumi][remi] = 1;           qu.push({sumi, remi, i, len + 1});         }         if (sumi == s && remi == 0) {           ans.clear();           go(sumi, remi, i, len + 1);           return;         }       }     }   }   int main() {     scanf( %d%d , &d, &s);     vis[0][0] = 1;     solve(0);     if (not fin.empty()) {       sort(fin.begin(), fin.end());       for (int i = 0; i < fin[0].first; i++) {         printf( %d , fin[0].second[i]);       }       printf(  n );       return 0;     }     cout <<  -1  << endl;     return 0;   }
#include <bits/stdc++.h>   int main() {     int x, y, xlast, ylast, n, k, i;     double sum = 0.0f;     scanf( %d%d , &n, &k);     scanf( %d%d , &xlast, &ylast);     for (i = 0; i < n - 1; i++) {       scanf( %d%d , &x, &y);       sum += sqrt(pow((double)x - xlast, 2) + pow((double)y - ylast, 2));       xlast = x;       ylast = y;     }     printf( %0.9lf , sum / 50 * k);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long md = 1000000007;   long long ans, f[2002][2002];   int n, m;   inline void solve() {     scanf( %d%d , &n, &m);     for (register int i = 1; i <= m; ++i) f[1][i] = 1;     for (register int i = 2; i <= n; ++i) {       int t = 0;       f[i][1] = 1;       for (register int j = 2; j <= m; ++j) {         (t += f[i - 1][j]) %= md;         f[i][j] = (f[i][j - 1] + t) % md;       }     }     for (register int i = 1; i <= n; ++i)       for (register int j = 2; j <= m; ++j)         (ans += (m - j + 1) * (f[i][j] - f[i - 1][j] + md) % md *                 f[n - i + 1][j] % md) %= md;     printf( %lld n , ans);   }   int main() {     ios_base::sync_with_stdio(false);     int T = 1;     for (; T--;) solve();   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n;     cin >> n;     string s;     cin >> s;     vector<int> vec(n);     vector<int> kactane(30, 0);     vector<int> harfmax(30, 0);     int res = 0;     for (int i = 0; i < n; i++) {       int cnt = 0;       kactane[s[i] -  a ]++;       for (int u = s[i] -  a  + 1; u <=  z  -  a ; u++) {         if (kactane[u]) {           cnt = max(cnt, harfmax[u]);         }       }       harfmax[s[i] -  a ] = max(harfmax[s[i] -  a ], cnt + 1);       vec[i] = cnt;       res = max(res, vec[i]);       if (res > 1) {         cout <<  NO ;         return 0;       }     }     cout <<  YES n ;     for (auto& x : vec) cout << x;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string str;     cin >> str;     if (str.size() % 2 == 1) {       cout <<  No  << endl;       return 0;     }     stack<char> sta;     for (int i = 0; i < str.size(); i++) {       if (!sta.empty() && sta.top() == str[i])         sta.pop();       else         sta.push(str[i]);     }     puts(sta.empty() ?  Yes  :  No );   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1.0e-11;   const double pi = acos(-1.0);   int main() {     string s;     cin >> s;     int n = s.size();     vector<int> points;     for (long long i = 0; i < (int)(s).size(); i++) {       if (s[i] ==  . ) {         points.push_back(i);       }     }     if (points.empty() || points.front() == 0 || points.front() > 8 ||         points.back() == n - 1 || n - 1 - points.back() > 3) {       cout <<  NO n ;       return 0;     }     vector<bool> sep((int)(s).size(), false);     for (long long i = 1; i <= (int)(points).size() - 1; i++) {       if (points[i] - points[i - 1] - 1 < 2 ||           points[i] - points[i - 1] - 1 > 11) {         cout <<  NO n ;         return 0;       }       int d = points[i] - points[i - 1] - 1;       if (d > 8) {         sep[points[i] - 8] = true;         continue;       }       sep[points[i - 1] + 2] = true;     }     cout <<  YES n ;     for (long long i = 0; i < (int)(s).size(); i++) {       if (sep[i]) {         cout << endl;       }       cout << s[i];     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using pii = pair<int, int>;   template <typename T, typename S>   ostream& operator<<(ostream& os, pair<T, S> a) {     os <<  (  << a.first <<  ,  << a.second <<  ) ;     return os;   }   template <typename T>   ostream& operator<<(ostream& os, vector<T> v) {     for (auto x : v) os << x <<    ;     return os;   }   void debug() { cerr <<   n ; }   template <typename H, typename... T>   void debug(H a, T... b) {     cerr << a;     if (sizeof...(b)) cerr <<  ,  ;     debug(b...);   }   vector<bool> get_prime(int n) {     vector<bool> prime(n + 1, true);     if (n >= 0) prime[0] = false;     if (n >= 1) prime[1] = false;     for (int i = 2; i * i <= n; i++) {       if (prime[i]) {         for (int j = i + i; j <= n; j += i) prime[j] = false;       }     }     return (prime);   }   int main() {     cin.tie(nullptr);     ios::sync_with_stdio(false);     auto p = get_prime(2000000);     vector<ll> d;     for (int i = 0; i < (int)(1000000); ++i)       if (p[i]) d.push_back(i);     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       ll a = sqrt(n);       int ans2 = 1;       ans2 +=           upper_bound(d.begin(), d.end(), n) - lower_bound(d.begin(), d.end(), a);       if (p[a]) ans2--;       cout << ans2 <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAX_N = 1050;   const int MAX_M = 1050;   int n, m, q;   int matrix[MAX_N][MAX_M];   int l[MAX_M][MAX_N];   int r[MAX_M][MAX_N];   int u[MAX_N][MAX_M];   int d[MAX_N][MAX_M];   void modify(int x, int y) {     matrix[x][y] ^= 1;     for (int j = 1; j <= m; j++) {       if (matrix[x][j] == 1) {         l[j][x] = l[j - 1][x] + 1;       } else {         l[j][x] = 0;       }     }     for (int j = m; j >= 1; j--) {       if (matrix[x][j] == 1) {         r[j][x] = r[j + 1][x] + 1;       } else {         r[j][x] = 0;       }     }     for (int i = 1; i <= n; i++) {       if (matrix[i][y] == 1) {         u[i][y] = u[i - 1][y] + 1;       } else {         u[i][y] = 0;       }     }     for (int i = n; i >= 1; i--) {       if (matrix[i][y] == 1) {         d[i][y] = d[i + 1][y] + 1;       } else {         d[i][y] = 0;       }     }   }   int query(int f[], int pos, int bound) {     int l = pos;     int r = pos;     int ret = f[pos];     int min_height = f[pos];     while (l > 1 || r < bound) {       if (r == bound || f[l - 1] > f[r + 1]) {         l--;         min_height = min(min_height, f[l]);       } else {         r++;         min_height = min(min_height, f[r]);       }       ret = max(ret, (r - l + 1) * min_height);     }     return ret;   }   int main() {     scanf( %d%d%d , &n, &m, &q);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) scanf( %d , matrix[i] + j);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) {         if (matrix[i][j] == 1) {           l[j][i] = l[j - 1][i] + 1;           u[i][j] = u[i - 1][j] + 1;         } else {           l[j][i] = u[i][j] = 0;         }       }     for (int i = n; i >= 1; i--)       for (int j = m; j >= 1; j--) {         if (matrix[i][j] == 1) {           r[j][i] = r[j + 1][i] + 1;           d[i][j] = d[i + 1][j] + 1;         } else {           d[i][j] = r[j][i] = 0;         }       }     while (q--) {       int a, x, y;       scanf( %d%d%d , &a, &x, &y);       if (a == 1) {         modify(x, y);         continue;       }       int ans = 0;       ans = max(ans, query(l[y], x, n));       ans = max(ans, query(r[y], x, n));       ans = max(ans, query(u[x], y, m));       ans = max(ans, query(d[x], y, m));       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int i, N, minim, maxim;     long long M;     scanf( %d %I64d , &N, &M);     maxim = 0;     if (2 * M < N)       minim = N - 2 * M;     else       minim = 0;     if (M == 0)       maxim = N;     else       for (i = 1; i <= N; ++i)         if (1LL * i * (i - 1) / 2 >= M) {           maxim = N - i;           break;         }     printf( %d %d n , minim, maxim);     return 0;   }