malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   constexpr int N = 1e5 + 10;   int n, ans = 0;   int dp[N][2];   vector<int> g[N];   void chkmax(int &first, int second) {     if (first < second) first = second;   }   void dfs(int u, int fa) {     dp[u][0] = dp[u][1] = 0;     int flag = 0;     for (int &v : g[u]) {       if (v == fa) continue;       dfs(v, u);       chkmax(dp[u][0], max(dp[v][0], dp[v][1]));       chkmax(dp[u][1], dp[v][0]);     }     int deg = g[u].size();     if (dp[u][0] <= 0)       dp[u][0] += deg - 1;     else       dp[u][0] += deg - 2;     dp[u][1] += 1;     int pre = 0;     for (int &v : g[u]) {       if (v == fa) continue;       chkmax(ans, pre + max(dp[v][0], dp[v][1]) + deg - 2);       chkmax(pre, max(dp[v][0], dp[v][1]));     }     chkmax(ans, pre + deg - 1);     pre = 0;     for (int &v : g[u]) {       if (v == fa) continue;       chkmax(ans, pre + dp[v][0] + 1);       chkmax(pre, dp[v][0]);     }     chkmax(ans, pre + 1);     return;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0), cout.tie(0);     cin >> n;     for (int i = 1, u, v; i < n; i++) {       cin >> u >> v;       g[u].push_back(v), g[v].push_back(u);     }     dfs(1, 0);     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-8;   int i, j, k, l, n, m, K[120], tmp, flag, bo;   struct point {     int x, y;   } a[120];   struct ppp {     double x, y;   } O;   double ans;   int dot(point &a, point &b, point &c, point &d) {     return (b.x - a.x) * (d.x - c.x) + (b.y - a.y) * (d.y - c.y);   }   double dist(ppp &a, point &b) {     return sqrt((b.x - a.x) * (b.x - a.x) + (b.y - a.y) * (b.y - a.y));   }   void calc(double a, double b, double c, double d, double e, double f) {     O.y = (a * f - d * c) / (b * d - e * a);     O.x = (b * f - c * e) / (a * e - b * d);   }   bool Find(int x, int y) {     for (int i = 1; i <= n; ++i)       if (a[i].x == x && a[i].y == y) return 1;     return 0;   }   int main() {     scanf( %d , &n);     for (i = 1; i <= n; ++i) scanf( %d%d , &a[i].x, &a[i].y);     for (i = 1; i <= n; ++i) K[i] = a[i].x * a[i].x + a[i].y * a[i].y;     for (i = 1; i <= n; ++i)       for (j = i + 1; j <= n; ++j)         for (k = j + 1; k <= n; ++k) {           tmp = dot(a[i], a[j], a[i], a[k]);           bo = 0;           if (tmp < 0 || tmp == 0 && !Find(a[j].x + a[k].x - a[i].x,                                            a[j].y + a[k].y - a[i].y))             continue;           if (tmp == 0)             bo = 1, O.x = (a[j].x + a[k].x) / 2.0, O.y = (a[j].y + a[k].y) / 2.0;           tmp = dot(a[j], a[i], a[j], a[k]);           if (tmp < 0 || tmp == 0 && !Find(a[i].x + a[k].x - a[j].x,                                            a[i].y + a[k].y - a[j].y))             continue;           if (tmp == 0)             bo = 1, O.x = (a[i].x + a[k].x) / 2.0, O.y = (a[i].y + a[k].y) / 2.0;           tmp = dot(a[k], a[i], a[k], a[j]);           if (tmp < 0 || tmp == 0 && !Find(a[i].x + a[j].x - a[k].x,                                            a[i].y + a[j].y - a[k].y))             continue;           if (tmp == 0)             bo = 1, O.x = (a[i].x + a[j].x) / 2.0, O.y = (a[i].y + a[j].y) / 2.0;           if (!bo)             calc(a[j].x - a[i].x, a[j].y - a[i].y, (K[i] - K[j]) / 2.0,                  a[k].x - a[i].x, a[k].y - a[i].y, (K[i] - K[k]) / 2.0);           double R = dist(O, a[i]);           for (l = 1; l <= n; ++l)             if (l != i && l != j && l != k && dist(O, a[l]) + eps < R) break;           if (l <= n) continue;           ans = max(ans, R);           flag = 1;         }     if (!flag)       printf( -1 n );     else       printf( %.6lf n , ans);   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1e9;   const int MAXN = 1e6 + 5;   const long long LINF = 1e18;   const double pi = 3.1415926535;   const long long MOD = 1e9 + 7;   void cyclic_roll(int &a, int &b, int &c, int &d) {     int tmp = a;     a = b;     b = c;     c = d;     d = tmp;   }   int map1[15][15];   int map2[15][15];   int n;   bool check() {     int nM = 0, vM = 0, hM = 0;     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         if (map1[i][j] == map2[i][j]) nM++;         if (map1[n - i - 1][j] == map2[i][j]) vM++;         if (map1[i][n - j - 1] == map2[i][j]) hM++;       }     }     return nM == n * n || vM == n * n || hM == n * n;   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         char c;         scanf(  %c , &c);         if (c ==  O ) map1[i][j] = 1;       }     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         char c;         scanf(  %c , &c);         if (c ==  O ) map2[i][j] = 1;       }     }     for (int i = 0; i < 4; i++) {       if (check()) return printf( Yes n ), 0;       for (int i = 0; i < n / 2; i++)         for (int j = 0; j < (n + 1) / 2; j++)           cyclic_roll(map1[i][j], map1[n - 1 - j][i], map1[n - 1 - i][n - 1 - j],                       map1[j][n - 1 - i]);     }     printf( No n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long q, n, arp[3000], s, ans, ar[2100][2100];   vector<long> pp;   void dfs(long a, long b) {     arp[a] = 1;     ans = max(ans, b);     for (int i = 1; i <= n; i++)       if (ar[a][i] == 1 && arp[i] == 0) {         dfs(i, b + 1);       }   }   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> q;       if (q == -1)         pp.push_back(i);       else {         ar[q][i] = 1;         ar[i][q] = 1;       }     }     for (int i = 0; i < pp.size(); i++) {       q = pp[i];       s = 0;       dfs(q, 1);     }     cout << ans << endl;     cin.get();     cin.get();     cin.get();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, a[111169], sum = 0;   int main() {     int x, y;     cin >> n >> m;     for (int i = (0); i < n; i += 1) cin >> a[i];     for (int i = (0); i < m; i += 1) {       cin >> x >> y;       sum += min(a[x - 1], a[y - 1]);     }     cout << sum;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O2 )   using namespace std;   const int maxn = 200000 + 10;   inline void read(int &x) {     int f = 1;     x = 0;     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();     }     x *= f;   }   inline void readll(long long &x) {     long long f = 1;     x = 0;     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();     }     x *= f;   }   long long n, q;   long long a[maxn], k, Prefix[maxn], last, cur;   void BinarySearch() {     if (last + k < a[cur]) {       last += k;       return;     }     long long l = cur, r = n, ans = 0;     while (l <= r) {       long long mid = (l + r) >> 1;       if (Prefix[mid] - Prefix[cur - 1] - last <= k)         ans = mid, l = mid + 1;       else         r = mid - 1;     }     if (ans == n) {       last = 0;       cur = 1;       return;     }     ans++;     long long ttt = Prefix[ans] - Prefix[cur - 1] - last - k;     last = a[ans] - ttt;     cur = ans;   }   int main() {     readll(n), readll(q);     for (long long i = 1; i <= n; i++) {       readll(a[i]), Prefix[i] = Prefix[i - 1] + a[i];     }     last = 0;     cur = 1;     for (long long i = 1; i <= q; i++) {       readll(k);       BinarySearch();       printf( %I64d n , n - cur + 1);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, K;   int tosum;   int begin1 = 1000000001, end1;   map<int, pair<int, int> > m;   vector<pair<int, int> > v;   int main() {     if (fopen( cf612d.in ,  r )) {       freopen( cf612d.in ,  r , stdin);       freopen( cf612d.out ,  w , stdout);     }     scanf( %d %d , &N, &K);     for (int i = 0; i < N; i++) {       int a, b;       scanf( %d %d , &a, &b);       m[a].first++;       m[b].second++;     }     for (map<int, pair<int, int> >::iterator it = m.begin(); it != m.end();          it++) {       tosum += it->second.first;       if (tosum >= K && begin1 == 1000000001) {         begin1 = it->first;       }       tosum -= it->second.second;       if (tosum < K && begin1 != 1000000001) {         end1 = it->first;         v.push_back(make_pair(begin1, end1));         begin1 = 1000000001;       }     }     printf( %u n , v.size());     for (int i = 0; i < v.size(); i++) {       printf( %d %d n , v[i].first, v[i].second);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, x, l;     cin >> n;     vector<int> tab;     for (long long int i = 0; i < n; ++i) {       l = 0;       cin >> x;       if (x <= 7)         tab.push_back(1);       else if (x % 7 == 0)         tab.push_back(x / 7);       else if (x % 6 == 0)         tab.push_back(x / 6);       else if (x % 5 == 0)         tab.push_back(x / 5);       else if (x % 4 == 0)         tab.push_back(x / 4);       else if (x % 3 == 0)         tab.push_back(x / 3);       else if (x % 2 == 0)         tab.push_back(x / 2);       else {         while ((x >= 7) && (x / 7 != 1)) {           x -= 7;           ++l;         }         while ((x >= 6) && (x / 6 != 1)) {           x -= 6;           ++l;         }         while ((x >= 5) && (x / 5 != 1)) {           x -= 5;           ++l;         }         while ((x >= 4) && (x / 4 != 1)) {           x -= 4;           ++l;         }         while ((x >= 3) && (x / 3 != 1)) {           x -= 3;           ++l;         }         while ((x >= 2) && (x / 2 != 1)) {           x -= 2;           ++l;         }         tab.push_back(l);       }     }     for (long long int i = 0; i < tab.size(); ++i) {       cout << tab[i] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int first;     int second;   } a[350030];   int cmp(node a, node b) {     if (a.first == b.first) {       return a.second < b.second;     } else       return a.first > b.first;   }   int main() {     int n;     while (~scanf( %d , &n)) {       for (int i = 1; i <= n; i++) {         scanf( %d , &a[i].first);         a[i].second = i;       }       sort(a + 1, a + 1 + n, cmp);       int L, R;       L = R = a[1].second;       int ans = 1000000000 + 7;       for (int i = 2; i <= n; i++) {         ans = min(ans,                   a[i].first / max(abs(a[i].second - L), abs(a[i].second - R)));         L = min(L, a[i].second);         R = max(R, a[i].second);       }       printf( %d n , ans);     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, m, j = 0, ans = 0;     cin >> n >> m;     string s;     cin >> s;     set<char> st;     vector<long long int> vec;     for (long long int i = 0; i < m; i++) {       char c;       cin >> c;       st.insert(c);     }     for (long long int i = 0; i < n; i++) {       if (st.count(s[i])) {         j++;       }       if (!st.count(s[i])) {         ans += (j * (j + 1)) / 2;         j = 0;       }     }     if (j > 0) {       ans += (j * (j + 1)) / 2;     }     cout << ans;   }
#include <bits/stdc++.h>      using namespace std;      typedef int8_t i8;   typedef int16_t i16;   typedef int32_t i32;   typedef int64_t i64;   typedef ptrdiff_t isize;      typedef uint8_t u8;   typedef uint16_t u16;   typedef uint32_t u32;   typedef uint64_t u64;   typedef size_t usize;      typedef float f32;   typedef double f64;         i64 gcd(i64 a, i64 b, i64& x, i64& y) {       if (b == 0) {           x = 1;           y = 0;           return a;       }       i64 x1, y1;       i64 d = gcd(b, a % b, x1, y1);       x = y1;       y = x1 - y1 * (a / b);       return d;   }      auto main() -> i32 {          ios::sync_with_stdio(false), cin.tie(nullptr);          i64 n, m, k;       cin >> n >> m >> k;       vector<i64> a(max(n, m) + 1);       i64 M = 2 * max(n, m);       vector<i64> p(M + 1, -1);          if (n <= m) {           for (i64 i = 1; i <= n; i++) {               cin >> a[i];           }                 for (i64 i = 1; i <= m; i++) {               i64 b;               cin >> b;               p[b] = i;           }       }       else {           swap(n, m);                 for (i64 i = 1; i <= m; i++) {               i64 b;               cin >> b;               p[b] = i;           }           for (i64 i = 1; i <= n; i++) {               cin >> a[i];           }          }       vector<i64> min_rnd(n + 1, -1);       i64 g; {           i64 x, y;           g = gcd(n, m, x, y);       }       i64 lcm = m / g;          for (i64 i = 1; i <= n; i++) {           if (p[a[i]] != -1) {               i64 dif = 0;               if (i > p[a[i]]) {                   dif = p[a[i]] + m - i;               }               else {                   dif = p[a[i]] - i;               }                  if (dif % g == 0) {                   dif /= g;                   i64 x, y;                   gcd(n / g, m / g, x, y);                   x = (x % lcm + lcm) % lcm;                   min_rnd[i] = (x * dif) % (lcm)+1;               }           }       }          i64 l = 1, r = 1e18 + 1;       while (l < r) {           i64 d = (l + r) / 2;           i64 bad = 0;           {               for (i64 i = 1; i <= n; i++) {                   i64 rnd = d / n + (d % n >= i ? 1 : 0);                   if (min_rnd[i] != -1) {                       bad += rnd - rnd / lcm - ((rnd % lcm) >= min_rnd[i] ? 1 : 0);                   }                   else {                       bad += rnd;                   }               }              }              if (bad >= k) {               r = d;           }           else if (bad < k) {               l = d + 1;           }       }          cout << l;          cout <<   n ;          return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, A;   int a[100005];   map<int, int> mp;   map<int, set<int> > se;   set<int>::iterator it, itt;   set<int> re;   int main() {     scanf( %d %d , &n, &A);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     int now = 0;     int flag = 0;     for (int i = 1; i <= n; i++) {       if (a[i] != A) {         it = se[mp[a[i]]].find(a[i]);         if (it != se[mp[a[i]]].end()) se[mp[a[i]]].erase(it);         mp[a[i]]++;         se[mp[a[i]]].insert(a[i]);         if (flag == 0) re.insert(a[i]);       } else {         now++;         if (now == 1) flag = 1;         for (it = re.begin(); it != re.end();) {           if (mp[*it] < now) {             re.erase(it++);           } else             it++;         }         if (re.size() == 0) {           printf( -1 n );           return 0;         }       }     }     printf( %d n , *re.begin());     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   bool uin(T &a, T b) {     return (a > b ? a = b, true : false);   }   template <class T>   bool uax(T &a, T b) {     return (a < b ? a = b, true : false);   }   int const X = 8;   int const L = 16;   int const N = 41;   long long const INF = 3e18 + 41;   int x, k, n, q;   int c[N];   int p[N], w[N];   long long d[(1 << X)][(1 << X)][L];   long long ans;   bool bit(int m, int i) { return (m & (1 << i)); }   int xorbit(int m, int i) { return (m ^ (1 << i)); }   int dx[(1 << X)][(1 << X)];   unordered_map<int, int> a;   vector<pair<int, long long>> e[(1 << X)][L];   void build() {     for (int i = 0; i < (1 << X); ++i)       for (int j = 0; j < (1 << X); ++j)         for (int o = 0; o < L; ++o) d[i][j][o] = INF;     memset(dx, 255, sizeof(dx));     for (int i = 0; i < (1 << k); ++i) {       if (!bit(i, 0)) {         int m0 = i;         int m1 = (m0 >> 1);         uin(d[m0][m1][0], 0ll);       } else {         int m0 = i;         for (int j = 1; j < k + 1; ++j) {           if (bit(m0, j)) continue;           int m1 = xorbit(m0, j);           m1 = xorbit(m1, 0);           m1 >>= 1;           if (uin(d[m0][m1][0], (long long)c[j - 1])) dx[m0][m1] = j;         }       }     }     for (int o = 1; o < L; ++o) {       for (int t = 0; t < (1 << k); ++t) {         for (int i = 0; i < (1 << k); ++i) {           for (int j = 0; j < (1 << k); ++j) {             uin(d[i][j][o], d[i][t][o - 1] + d[t][j][o - 1]);           }         }       }     }     for (int o = 0; o < L; ++o) {       for (int i = 0; i < (1 << X); ++i)         for (int j = 0; j < (1 << X); ++j)           if (d[i][j][o] < INF) {             e[i][o].push_back(make_pair(j, d[i][j][o]));           }     }   }   long long f[(1 << X)], nf[(1 << X)];   void solve() {     int p1 = 0;     int x0 = 0;     for (int i = 0; i < (1 << X); ++i) f[i] = INF;     f[(1 << x) - 1] = 0;     while (x0 < n - x) {       while (p1 < q && x0 > p[p1]) ++p1;       int s;       for (int i = L - 1; i >= 0; --i) {         s = i;         if (x0 + (1 << i) + k - 1 > n - 1) continue;         if (p1 != q && x0 + (1 << i) + k - 1 >= p[p1]) continue;         break;       }       for (int i = 0; i < (1 << k); ++i) nf[i] = INF;       for (int i = 0; i < (1 << k); ++i) {         if (f[i] == INF) continue;         for (pair<int, long long> p : e[i][s]) {           long long v = f[i] + p.second;           if (s == 0 && dx[i][p.first] != -1 &&               a.find(x0 + dx[i][p.first]) != a.end()) {             v += a[x0 + dx[i][p.first]];           }           uin(nf[p.first], v);         }       }       memcpy(f, nf, sizeof(f));       x0 += (1 << s);     }     ans = f[(1 << x) - 1];   }   int main() {     scanf( %d %d %d %d , &x, &k, &n, &q);     for (int i = 0; i < k; ++i) scanf( %d , &c[i]);     for (int i = 0; i < q; ++i) {       scanf( %d %d , &p[i], &w[i]);       --p[i];       a[p[i]] = w[i];     }     for (int i = 0; i < q; ++i)       for (int j = i + 1; j < q; ++j)         if (p[j] < p[i]) {           swap(p[j], p[i]);           swap(w[j], w[i]);         }     build();     solve();     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> adj[100005], dir[100005], vec;   int vis1[100005], vis2[100005], vis3[100005], fl = 0;   void dfs1(int u) {     vis1[u] = 1;     vec.push_back(u);     for (int i = (int)0; i <= (int)adj[u].size() - 1; i++) {       if (!vis1[adj[u][i]]) dfs1(adj[u][i]);     }   }   void dfs2(int u) {     vis2[u] = 1;     vis3[u] = 1;     for (int i = (int)0; i <= (int)dir[u].size() - 1; i++) {       if (!vis2[dir[u][i]]) dfs2(dir[u][i]);       if (vis3[dir[u][i]]) fl = 1;     }     vis3[u] = 0;   }   int fun() {     int ret = 0;     for (int j = (int)0; j <= (int)vec.size() - 1; j++) {       if (!vis2[vec[j]]) {         fl = 0;         dfs2(vec[j]);         ret += fl;       }     }     return (ret == 0);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n, m;     cin >> n >> m;     for (int i = (int)1; i <= (int)m; i++) {       int u, v;       cin >> u >> v;       adj[u].push_back(v);       adj[v].push_back(u);       dir[u].push_back(v);     }     int ans = 0;     for (int i = (int)1; i <= (int)n; i++) {       if (!vis1[i]) {         vec.clear();         dfs1(i);         ans += vec.size() - fun();       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 600050;   long long a[N], dp[N][3];   int main() {     int n, x;     scanf( %d%d , &n, &x);     for (int i = 1; i <= n; i++) {       scanf( %lld , &a[i]);     }     long long ans = 0;     for (int i = 1; i <= n; i++) {       dp[i][0] = max(dp[i][0], max(dp[i - 1][0], 0ll) + a[i]);       dp[i][1] = max(dp[i][1], max(dp[i - 1][0], 0ll) + a[i] * x);       dp[i][1] = max(dp[i][1], dp[i - 1][1] + a[i] * x);       dp[i][2] = max(dp[i][2], max(dp[i - 1][1], dp[i - 1][2]) + a[i]);       ans = max(max(ans, dp[i][0]), max(dp[i][1], dp[i][2]));     }     printf( %lld n , ans);   }
#include <bits/stdc++.h>   using namespace std;   int q;   long long L, R;   set<long long> s;   long long v2[2000002], x;   void precalculate() {     long long LLMAX = 1e18;     for (int i = 2; i <= 1000000; ++i) {       long long x = 1LL * i * i * i;       while (1) {         if ((int)sqrt(x) != sqrt(x)) s.insert(x);         if (x <= LLMAX / i)           x = x * i;         else           break;       }     }     for (set<long long>::iterator it = s.begin(); it != s.end(); ++it)       v2[++x] = *it;     v2[x + 1] = 2e18;   }   long long cb(long long nr) {     int b = 1;     int e = x;     while (b <= e) {       int m = (b + e) / 2;       if (v2[m] <= nr && v2[m + 1] > nr) return m;       if (v2[m] <= nr)         b = m + 1;       else         e = m - 1;     }     return 0;   }   long long cb2(long long nr) {     int b = 0;     int e = 1e9;     while (b <= e) {       int m = (b + e) / 2;       if (1LL * m * m <= nr && 1LL * (m + 1) * (m + 1) > nr) return m;       if (1LL * m * m <= nr)         b = m + 1;       else         e = m - 1;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cin >> q;     precalculate();     for (int i = 1; i <= q; ++i) {       cin >> L >> R;       long long sol = cb(R) - cb(L - 1) + cb2(R) - cb2(L - 1);       cout << sol <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<char, int> m;   int main() {     string s;     cin >> s;     int x = 0;     for (int i = 0; i < s.size(); i++) {       if (m[s[i]] == 0) x++;       m[s[i]]++;     }     if (x > 4 || x < 2)       cout <<  No  << endl;     else if (x == 2) {       for (int i = 0; i < s.size(); i++) {         if (m[s[i]] < 2) {           cout <<  No  << endl;           return 0;         }       }       cout <<  Yes  << endl;     } else if (x == 3) {       if (s.size() >= 4)         cout <<  Yes  << endl;       else         cout <<  No  << endl;     } else if (x == 4) {       cout <<  Yes  << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const long long M = 1000000007;   const double pi = 3.141592653589793238463;   long long modExp(long long x, long long n, long long M) {     long long result = 1;     while (n > 0) {       if (n % 2 == 1) result = (result * x) % M;       x = (x * x) % M;       n = n / 2;     }     return result;   }   bool sortbysec(const pair<long long, long long> &a,                  const pair<long long, long long> &b) {     return (a.second < b.second);   }   bool vow(char ch) {     return ch ==  a  || ch ==  e  || ch ==  i  || ch ==  o  || ch ==  u ;   }   bool isPrime(long long n) {     for (long long i = 2; i * i <= n; i++)       if (n % i == 0) return false;     return true;   }   long long fast_exp(long long x, long long n) {     long long ans = 1;     while (n) {       if (n & 1) {         ans *= x;         ans %= M;       }       n = n >> 1;       x = (x * x) % M;     }     return ans;   }   long long inverse(long long x) { return fast_exp(x, M - 2); }   long long combination(long long n, long long r) {     if (r == 0)       return 1;     else {       long long ans = n % M;       ans *= combination(n - 1, r - 1) % M;       ans %= M;       ans *= inverse(r) % M;       ans %= M;       return ans;     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     ;     long long n, a, b, q;     cin >> n >> a >> b;     for (long long i = min(a, b); i > 0; i--) {       q = a / i + b / i;       if (q >= n) return cout << i, 0;     }   }