malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long long N = 2e5 + 5;   const long long MOD = 1e9 + 7;   long long n, a[55];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cin >> n;     for (long long i = 0; i < n; i++) cin >> a[i];     sort(a, a + n);     if (a[0] == a[n / 2])       cout <<  Bob ;     else       cout <<  Alice ;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int a[1005];   int main() {     cin >> n;     int x;     int ans = 0;     if (n == 1) {       cin >> x;       if (x)         cout <<  YES  << endl;       else         cout <<  NO  << endl;       return 0;     }     for (int i = 0; i < n; i++) {       cin >> x;       ans += x;     }     if (ans == n - 1)       cout <<  YES  << endl;     else       cout <<  NO  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double ex = 1e-6;   double pow(double x, int n) {     double ret = 1;     while (n) {       if (n % 2) ret *= x;       n >>= 1;       x *= x;     }     return ret;   }   int main() {     double n;     int m;     while (scanf( %lf %d , &n, &m) != EOF) {       double ans = n;       double i = n - 1;       double k;       for (i; i >= 1; i -= 1) {         k = pow(i / n, m);         if (k < ex) break;         ans -= k;       }       printf( %0.4lf n , ans);     }   }
#include <bits/stdc++.h>   using namespace std;   struct coord {     int c, f, v;   };   coord var, pos;   int n, m, i, x, cont, h;   int pasos[1001][1001];   bool ya[1001][1001], e;   char mapa[1001][1001];   queue<coord> cola;   stack<coord> pila;   int main() {     scanf( %d%d , &n, &m);     for (i = 0; i < n; i++) {       scanf( %s , mapa[i]);     }     for (i = 0; i < n; i++) {       for (x = 0; x < m; x++) {         if (mapa[i][x] ==  T )           ya[i][x] = true;         else if (mapa[i][x] ==  E ) {           ya[i][x] = true;           var.c = i;           var.f = x;           var.v = 0;           cola.push(var);         }       }     }     while (!cola.empty()) {       pos = cola.front();       cola.pop();       if (pos.c - 1 >= 0 && ya[pos.c - 1][pos.f] == false) {         pos.c--;         cola.push(pos);         ya[pos.c][pos.f] = true;         pasos[pos.c][pos.f] = pasos[pos.c + 1][pos.f] + 1;         if (mapa[pos.c][pos.f] ==  S ) {           h = pasos[pos.c][pos.f];         }         pos.c++;       }       if (pos.c + 1 < n && ya[pos.c + 1][pos.f] == false) {         pos.c++;         cola.push(pos);         ya[pos.c][pos.f] = true;         pasos[pos.c][pos.f] = pasos[pos.c - 1][pos.f] + 1;         if (mapa[pos.c][pos.f] ==  S ) {           h = pasos[pos.c][pos.f];         }         pos.c--;       }       if (pos.f - 1 >= 0 && ya[pos.c][pos.f - 1] == false) {         pos.f--;         cola.push(pos);         ya[pos.c][pos.f] = true;         pasos[pos.c][pos.f] = pasos[pos.c][pos.f + 1] + 1;         if (mapa[pos.c][pos.f] ==  S ) {           h = pasos[pos.c][pos.f];         }         pos.f++;       }       if (pos.f + 1 < m && ya[pos.c][pos.f + 1] == false) {         pos.f++;         cola.push(pos);         ya[pos.c][pos.f] = true;         pasos[pos.c][pos.f] = pasos[pos.c][pos.f - 1] + 1;         if (mapa[pos.c][pos.f] ==  S ) {           h = pasos[pos.c][pos.f];         }         pos.f--;       }     }     for (i = 0; i < n; i++) {       for (x = 0; x < m; x++) {         if (mapa[i][x] -  0  > 0 && mapa[i][x] -  0  < 10) {           if (pasos[i][x] <= h && ya[i][x] == true) cont += mapa[i][x] -  0 ;         }       }     }     printf( %d , cont);   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n, t;     while (cin >> n >> t) {       int x, y;       vector<pair<int, int> > a;       vector<pair<int, int> > v;       for (int i = 0; i < n; i++) {         cin >> x >> y;         a.push_back(make_pair(x, y));       }       for (int i = 0; i < n; i++) {         while (a[i].first < t) a[i].first += a[i].second;         v.push_back(make_pair(a[i].first, i));       }       sort(v.begin(), v.end());       cout << (v[0].second) + 1 << endl;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     solve();   }
#include <bits/stdc++.h>   using namespace std;   struct edge {     int y, stat;   };   struct query {     int curNode;     int curLength;     int curGood;   };   vector<edge> vec[100005];   pair<long long, long long> best[100005];   long long path[100005], pathStatus[100005];   int n, m;   queue<query> q;   set<pair<int, int> > badRoads;   map<pair<int, int>, int> goodRoads;   int main() {     scanf( %d %d , &n, &m);     for (int i = 0; i < m; i++) {       int x, y, z;       scanf( %d %d %d , &x, &y, &z);       if (z == 1) goodRoads[make_pair(min(x, y), max(x, y))]++;       x--, y--;       vec[x].push_back({y, z});       vec[y].push_back({x, z});     }     for (int i = 0; i < n; i++) best[i].first = 1e10;     q.push({0, 0, 0});     while (!q.empty()) {       query ab = q.front();       q.pop();       if (best[ab.curNode].first < ab.curLength ||           (best[ab.curNode].first == ab.curLength &&            best[ab.curNode].second > ab.curGood))         continue;       int vSize = vec[ab.curNode].size();       for (int i = 0; i < vSize; i++) {         int nextNode = vec[ab.curNode][i].y;         int nextGood = vec[ab.curNode][i].stat + ab.curGood;         if (ab.curLength + 1 < best[nextNode].first ||             (best[nextNode].first == ab.curLength + 1 &&              nextGood > best[nextNode].second)) {           best[nextNode].first = ab.curLength + 1;           best[nextNode].second = nextGood;           q.push({nextNode, ab.curLength + 1, nextGood});           path[nextNode] = ab.curNode;           pathStatus[nextNode] = vec[ab.curNode][i].stat;         }       }     }     int myNode = n - 1;     while (myNode) {       if (pathStatus[myNode]) {         int minVal = min(path[myNode] + 1, myNode + 1LL);         int maxVal = max(path[myNode] + 1, myNode + 1LL);         goodRoads[make_pair(minVal, maxVal)]--;       } else         badRoads.insert({path[myNode] + 1, myNode + 1});       myNode = path[myNode];     }     vector<pair<pair<int, int>, int> > ans;     for (auto it : badRoads)       ans.push_back(make_pair(make_pair(it.first, it.second), 1));     for (auto it : goodRoads) {       if (it.second == 0) continue;       for (int i = 0; i < it.second; i++)         ans.push_back(make_pair(make_pair(it.first.first, it.first.second), 0));     }     int curSize = ans.size();     printf( %d n , curSize);     for (int i = 0; i < curSize; i++)       printf( %d %d %d n , ans[i].first.first, ans[i].first.second,              ans[i].second);   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long int n, m;     cin >> n >> m;     long long int n1, m1;     cin >> n1 >> m1;     long long int a[n], b[m];     for (long long int i = 0; i < n; i++) cin >> a[i];     for (long long int i = 0; i < m; i++) cin >> b[i];     if (a[n1 - 1] < b[m - m1])       cout <<  YES  << endl;     else       cout <<  NO  << endl;   }   int32_t main() {     ios_base ::sync_with_stdio(false), cin.tie(NULL);     solve();     return 0;   }
#include <bits/stdc++.h>   const int INF_INT = 0x3f3f3f3f;   const long long INF_LL = 0x7f7f7f7f;   const int MOD = 1e9 + 7;   const double eps = 1e-10;   const double pi = acos(-1);   using namespace std;   vector<int> g[100010];   int n;   double ans;   void dfs(int fa, int u, int cnt) {     ans += 1.0 / cnt;     for (int i = 0; i < g[u].size(); i++) {       int v = g[u][i];       if (v == fa) continue;       dfs(u, v, cnt + 1);     }   }   int main(int argc, char const *argv[]) {     scanf( %d , &n);     for (int i = 1; i < n; i++) {       int u, v;       scanf( %d%d , &u, &v);       g[u].push_back(v);       g[v].push_back(u);     }     ans = 0.0;     dfs(0, 1, 1);     printf( %.12f n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = (int)1e9 + 7;   const int MAXN = 100100;   inline void add(int &a, int b) {     a += b;     if (a >= MOD) {       a -= MOD;     }   }   inline int mul(int a, int b) { return (a * 1LL * b) % MOD; }   inline int fastPow(int a, int b) {     int r = 1;     while (b) {       if (b & 1) {         r = mul(r, a);       }       a = mul(a, a);       b >>= 1;     }     return r;   }   inline int inverse(int a) { return fastPow(a, MOD - 2); }   int f[MAXN];   int invf[MAXN];   int ten[MAXN];   inline int c(int n, int k) {     if (k < 0) {       return 0;     }     if (n < k) {       return 0;     }     return mul(mul(f[n], invf[k]), invf[n - k]);   }   int main() {     clock_t start_time = clock();     f[0] = invf[0] = 1;     ten[0] = 1;     for (int i = 1; i < MAXN; i++) {       ten[i] = mul(ten[i - 1], 10);       f[i] = mul(f[i - 1], i);       invf[i] = inverse(f[i]);     }     int n, k;     while (scanf( %d%d , &n, &k) == 2) {       char ss[n + 1];       scanf( %s , ss);       vector<int> s(n, 0);       for (int i = 0; i < n; i++) {         s[i] = ss[i] -  0 ;         if (i > 0) {           add(s[i], s[i - 1]);         }       }       int ans = 0;       for (int d = 0; d <= n - 2; d++) {         int val = mul(ten[d], c(n - d - 2, k - 1));         val = mul(val, s[n - d - 2]);         add(ans, val);       }       for (int i = 0; i < n; i++) {         int val = mul(ten[n - i - 1], ss[i] -  0 );         val = mul(val, c(i, k));         add(ans, val);       }       printf( %d n , ans);     }     (void)42;     ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     long long n, R = 0, L = 0;     cin >> n;     long long l[n], r[n];     for (int x = 0; x < n; x++) {       cin >> l[x] >> r[x];       L += l[x];       R += r[x];     }     int val = abs(R - L);     int ans = 0;     for (int x = 0; x < n; x++) {       int tL = L - (l[x] - r[x]);       int tR = R - (r[x] - l[x]);       int i = abs(tL - tR);       if (i > val) {         ans = x + 1;         val = i;       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void fast() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);   }   long long int power(long long int x, long long int y, long long int p) {     long long int res = 1;     x %= p;     while (y > 0) {       if (y & 1) res = (res * x) % p;       y = y >> 1;       x = (x * x) % p;     }     return res;   }   long long int modInverse(long long int n, long long int p) {     return power(n, p - 2, p);   }   long long int nCrModPFermat(long long int n, long long int r, long long int p) {     if (r == 0) return 1;     long long int fac[n + 1];     fac[0] = 1;     for (long long int i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % p;     return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) %            p;   }   void SieveOfEratosthenes(long long int n) {     bool prime[n + 1];     memset(prime, true, sizeof(prime));     for (long long int p = 2; p * p <= n; p++) {       if (prime[p] == true)         for (long long int i = p * p; i <= n; i += p) prime[i] = false;     }     for (long long int p = 2; p <= n; p++)       if (prime[p]) cout << p <<    ;   }   int main() {     fast();     int t = 1;     while (t--) {       int n, k;       cin >> n >> k;       int v[n];       vector<int> a;       map<int, int> m;       for (int i = 0; i < n; ++i) cin >> v[i];       a.push_back(v[0]);       for (int i = 1; i < n; ++i) {         if (v[i] != a[a.size() - 1]) a.push_back(v[i]);       }       n = a.size();       m[a[0]]++;       for (int i = 1; i < n; ++i) {         if (i < n - 1 && a[i - 1] == a[i + 1])           m[a[i]] += 2;         else           m[a[i]]++;       }       int maxi = 0, ans;       for (auto x : m) {         if (maxi < x.second) {           maxi = x.second;           ans = x.first;         }       }       cout << ans <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   vector<pair<long long, long long> > adj[100100];   long long under[100100];   long long n;   long long dfs(long long u, long long p) {     under[u] = 0;     long long next, edge;     for (long long i = 0; i < adj[u].size(); i++) {       next = adj[u][i].first;       edge = adj[u][i].second;       if (next != p) {         under[u] += edge + dfs(next, u);       }     }     return under[u];   }   long long f(long long u, long long p) {     long long sum = 0;     long long edge, next;     for (long long i = 0; i < adj[u].size(); i++) {       next = adj[u][i].first;       edge = adj[u][i].second;       if (next != p) sum += edge + under[next];     }     if (sum == 0) return 0;     long long best = 100000000ll * 100000000ll;     long long now;     for (long long i = 0; i < adj[u].size(); i++) {       next = adj[u][i].first;       edge = adj[u][i].second;       if (next != p) {         now = (sum - (edge + under[next])) * 2 + edge + f(next, u);         best = min(best, now);       }     }     return best;   }   int main() {     cin >> n;     long long x, y, edge;     for (long long i = 1; i < n; i++) {       cin >> x >> y >> edge;       adj[x].push_back(pair<long long, long long>(y, edge));       adj[y].push_back(pair<long long, long long>(x, edge));     }     dfs(1, -1);     cout << f(1, -1) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   pair<int, int> answer[404];   set<pair<int, int> > S;   set<pair<int, int> >::iterator it, ii;   bool check(pair<int, int> c) {     ii = S.lower_bound(make_pair(c.first, 0));     if (ii != S.end()) {       if (c.first + c.second > (*ii).first) return false;     }     if (ii != S.begin()) {       ii--;       if (c.first < (*ii).first + (*ii).second) return false;     }     return true;   }   int main() {     scanf( %d , &n);     S.insert(make_pair(0, 1));     for (int i = 0; i < n; ++i) {       int x, y;       scanf( %d %d , &x, &y);       pair<int, int> c = make_pair(x, y);       if (check(c)) {         answer[i] = c;         S.insert(c);         continue;       }       for (it = S.begin(); it != S.end(); it++) {         c = make_pair((*it).first + (*it).second, y);         if (check(c)) {           S.insert(c);           answer[i] = c;           break;         }       }     }     for (int i = 0; i < n; ++i)       printf( %d %d n , answer[i].first, answer[i].second + answer[i].first - 1);   }
#include <bits/stdc++.h>   using namespace std;   vector<vector<int>> g, rv;   int ds[3030][3030];   vector<int> md[3030];   int rd[3030][3030];   vector<int> mr[3030];   int main() {     int n, m;     scanf( %d %d  , &n, &m);     g.assign(n, vector<int>());     rv.assign(n, vector<int>());     while (m--) {       int a, b;       scanf( %d %d  , &a, &b);       a--;       b--;       if (a == b) continue;       g[a].push_back(b);       rv[b].push_back(a);     }     memset(ds, -1, sizeof(ds));     memset(rd, -1, sizeof(rd));     for (int i = 0; i < n; i++) {       ds[i][i] = rd[i][i] = 0;       queue<int> q;       priority_queue<pair<int, int>, vector<pair<int, int>>,                      greater<pair<int, int>>>           pq;       q.push(i);       while (!q.empty()) {         int u = q.front();         q.pop();         if (i != u) pq.push({ds[i][u], u});         while (pq.size() > 3) {           pq.pop();         }         for (int j = 0; j < g[u].size(); j++) {           int v = g[u][j];           if (ds[i][v] >= 0) {             continue;           }           ds[i][v] = ds[i][u] + 1;           q.push(v);         }       }       while (!pq.empty()) {         int u = pq.top().second;         pq.pop();         md[i].push_back(u);       }       q = queue<int>();       q.push(i);       while (!q.empty()) {         int u = q.front();         q.pop();         if (i != u) pq.push({rd[i][u], u});         while (pq.size() > 3) {           pq.pop();         }         for (int j = 0; j < rv[u].size(); j++) {           int v = rv[u][j];           if (rd[i][v] >= 0) continue;           rd[i][v] = rd[i][u] + 1;           q.push(v);         }       }       while (!pq.empty()) {         int u = pq.top().second;         pq.pop();         mr[i].push_back(u);       }     }     int ma = 0;     int mi[4];     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         if (i == j) continue;         if (ds[i][j] < 0) continue;         for (int k = 0; k < mr[i].size(); k++) {           for (int l = 0; l < md[j].size(); l++) {             int a = mr[i][k], b = md[j][l];             if (a == b || a == j) continue;             if (b == i) continue;             int dist = ds[a][i] + ds[i][j] + ds[j][b];             if (dist > ma) {               ma = dist;               mi[0] = a;               mi[1] = i;               mi[2] = j;               mi[3] = b;             }           }         }       }     }     printf( %d %d %d %d n , mi[0] + 1, mi[1] + 1, mi[2] + 1, mi[3] + 1);   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1000006;   const long long int M = 935172938408392767LL;   vector<long long int> kub[N];   long long int kra[N];   long long int maska[N];   int deg[N];   int main() {     int n, m, a, b;     long long int wynik = 0;     scanf( %d%d , &n, &m);     kra[1] = 1;     for (int i = 2; i <= n; i++) kra[i] = (kra[i - 1] * 2) % M;     for (int i = 0; i < m; i++) {       scanf( %d%d , &a, &b);       maska[a] += kra[b];       maska[b] += kra[a];       maska[a] %= M;       maska[b] %= M;       deg[a]++;       deg[b]++;     }     for (int i = 1; i <= n; i++) {       kub[deg[i]].push_back(maska[i]);       kub[deg[i]].push_back((maska[i] + kra[i]) % M);     }     for (int i = 0; i <= n; i++) {       sort(kub[i].begin(), kub[i].end());       a = 1;       for (int j = 1; j < kub[i].size(); j++) {         if (kub[i][j - 1] == kub[i][j])           a++;         else {           wynik += ((a - 1) * (long long)a) / 2;           a = 1;         }       }       wynik += ((a - 1) * (long long)a) / 2;     }     printf( %I64d n , wynik);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = (long long)4e18 + 7;   inline void minimize(long long &x, const long long &y) {     if (x > y) x = y;   }   struct help {     int x, s, r;     help() { x = s = r = 0; }     void input(void) {       x = s = r = 0;       int k;       scanf( %d%d%d , &x, &r, &k);       for (int zz = 0; zz < (k); zz = zz + 1) {         int v;         scanf( %d , &v);         v--;         s |= (1 << (v));       }     }     bool operator<(const help &a) const { return (r < a.r); }   };   long long f[(1 << (20)) + 7];   help a[111];   int n, m, b;   void init(void) {     scanf( %d%d%d , &n, &m, &b);     for (int i = (1); i <= (n); i = i + 1) a[i].input();     sort(a + 1, a + n + 1);   }   void process(void) {     for (int i = 0; i < ((1 << (m))); i = i + 1) f[i] = INF;     f[0] = 0;     long long res = INF;     for (int i = (1); i <= (n); i = i + 1) {       long long cost = 1LL * b * a[i].r;       for (int j = 0; j < ((1 << (m))); j = j + 1)         if (f[j] < INF) minimize(f[j | a[i].s], f[j] + a[i].x);       minimize(res, f[(1 << (m)) - 1] + cost);     }     if (res < INF)       cout << res;     else       cout << -1;   }   int main(void) {     init();     process();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e5 + 10;   int n;   bool init[MAXN], goal[MAXN];   vector<int> e[MAXN];   bool mark[MAXN];   bool even = true;   bool eo[2];   queue<int> ans;   void dfs(int v) {     if (mark[v]) return;     mark[v] = true;     bool change = false;     if ((init[v] != goal[v]) ^ eo[even]) {       ans.push(v + 1);       eo[even] = !eo[even];       change = true;     }     for (int i = 0; i < e[v].size(); i++) {       int u = e[v][i];       even = !even;       dfs(u);       even = !even;     }     if (change) eo[even] = !eo[even];   }   int main() {     cin >> n;     for (int i = 0; i < n - 1; i++) {       int u, v;       cin >> u >> v;       u--;       v--;       e[u].push_back(v);       e[v].push_back(u);     }     for (int i = 0; i < n; i++) cin >> init[i];     for (int i = 0; i < n; i++) cin >> goal[i];     dfs(0);     cout << ans.size() << endl;     while (ans.size() > 0) {       cout << ans.front() << endl;       ans.pop();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());   using ll = long long int;   using ld = long double;   using pi = pair<int, int>;   const double PI = acos(-1.0);   const double eps = 1e-9;   const ll mod = 1e9 + 7;   const int inf = 1e7;   const int MAXN = 1e5 + 5;   void cp() {     int n;     cin >> n;     vector<int> arr(n);     for (int &x : arr) cin >> x;     int mn = *min_element(arr.begin(), arr.end());     for (int &x : arr) x -= mn, x++;     int one = count(arr.begin(), arr.end(), 1);     if (one > n / 2)       cout <<  Bob n ;     else       cout <<  Alice n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     int t;     t = 1;     while (t--) {       cp();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int Find(string x) {     if (x ==  rock ) return 1;     if (x ==  scissors ) return 2;     if (x ==  paper ) return 3;   }   int main() {     string a, b, c;     int sa, sb, sc;     cin >> a >> b >> c;     sa = Find(a), sb = Find(b), sc = Find(c);     if (sa == 1 && sb == 2 && sc == 2)       printf( F );     else if (sa == 2 && sb == 3 && sc == 3)       printf( F );     else if (sa == 3 && sb == 1 && sc == 1)       printf( F );     else if (sa == 2 && sb == 1 && sc == 2)       printf( M );     else if (sa == 3 && sb == 2 && sc == 3)       printf( M );     else if (sa == 1 && sb == 3 && sc == 1)       printf( M );     else if (sa == 2 && sb == 2 && sc == 1)       printf( S );     else if (sa == 3 && sb == 3 && sc == 2)       printf( S );     else if (sa == 1 && sb == 1 && sc == 3)       printf( S );     else       printf( ? );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long head[100005];   long long memory[100005];   int n, m;   bool possible(long long t) {     int curr = 1;     for (int i = 1; i <= n; i++) {       long long headloc = head[i];       if (headloc <= memory[curr]) {         headloc += t;         while (headloc >= memory[curr] && curr <= m) curr++;       } else {         if (headloc - t > memory[curr]) return false;         long long d = headloc - memory[curr];         long long next = max(headloc + (t - d) / 2, headloc + (t - 2 * d));         headloc = next;         while (headloc >= memory[curr] && curr <= m) curr++;       }       if (curr == m + 1) return true;     }     return false;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> n >> m;     for (int i = 1; i <= n; i++) cin >> head[i];     for (int i = 1; i <= m; i++) cin >> memory[i];     long long start = 0;     long long endi = 20000000000;     while (start < endi) {       long long mid = (start + endi) / 2;       if (possible(mid))         endi = mid;       else         start = mid + 1;     }     cout << endi;   }