malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long n, k, M, D, N, sol, x, mid, f, l, T;   long long up(long long a, long long b) {     long long tmp = a / b;     if (a % b != 0) tmp = tmp + 1ll;     return tmp;   }   long long rep(long long a) {     long long tmp = n / a;     tmp = up(tmp, k);     return tmp;   }   int main() {     cin >> n >> k >> M >> D;     sol = rep(M) * M;     for (long long p = 2ll; p <= D; p++) {       f = 1ll, l = M;       mid = (f + l + 1ll) / 2;       T = -1;       while (l > f) {         mid = (f + l + 1ll) / 2;         if (rep(mid) == p && rep(mid + 1ll) != p) {           T = mid;           break;         }         if (rep(mid) >= p) {           f = mid;         } else if (rep(mid) < p) {           l = mid - 1ll;         }         if (l - f <= 1) {           if (rep(f) == p && rep(l + 1ll) > p) {             T = f;             break;           }           if (rep(l) == p && rep(l + 1ll) > p) {             T = l;             break;           }         }       }       if (T != -1) {         x = T;         T = rep(x) * x;         sol = max(sol, T);       }     }     cout << sol;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int max(int a, int b) { return a > b ? a : b; }   inline int min(int a, int b) { return a < b ? a : b; }   map<int, int> mp;   int main() {     int n, x;     cin >> n;     mp.clear();     for (int i(0); i < (n); ++i) {       cin >> x;       ++mp[x];     }     long long ans(0);     for (map<int, int>::iterator it = mp.begin(); it != mp.end() && it->first < 0;          ++it)       ans += (long long)it->second * (long long)mp[-it->first];     ans += (long long)mp[0] * ((long long)mp[0] - 1ll) / 2ll;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   long long a[305];   int prt[305], num[305] = {0}, ha[305] = {0};   long long f[305][605] = {0};   long long c[305][305], jc[305];   int n;   bool pd(int i, int j) {     long long ha = sqrt(a[i] * a[j]);     if (ha * ha == a[i] * a[j]) return true;     return false;   }   int getfa(int x) {     if (x == prt[x]) return x;     return prt[x] = getfa(prt[x]);   }   void init() {     c[0][0] = 1;     for (int i = 1; i <= 300; i++) {       c[i][0] = 1;       for (int j = 1; j <= i; j++)         c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod;     }     jc[0] = 1;     for (int i = 1; i <= 300; i++) jc[i] = jc[i - 1] * i % mod;   }   void solve() {     int i, j, k, h;     int sum = num[1];     f[1][num[1] - 1] = 1;     for (i = 2; i <= num[0]; i++) {       for (j = 0; j <= sum - 1; j++)         for (k = 1; k <= num[i]; k++)           for (h = 0; h <= j && h <= k; h++) {             f[i][j - h + num[i] - k] += f[i - 1][j] * c[j][h] % mod *                                         c[num[i] - 1][k - 1] % mod *                                         c[sum + 1 - j][k - h] % mod;             f[i][j - h + num[i] - k] %= mod;           }       sum += num[i];     }     long long ans = f[num[0]][0];     for (int i = 1; i <= num[0]; i++) ans = ans * jc[num[i]] % mod;     printf( %lld n , ans);   }   int main() {     init();     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %lld , &a[i]);     for (int i = 1; i <= n; i++) prt[i] = i;     for (int i = 1; i <= n; i++)       for (int j = i + 1; j <= n; j++)         if (pd(i, j)) {           int f1, f2;           f1 = getfa(i);           f2 = getfa(j);           if (f1 != f2) prt[f1] = f2;         }     for (int i = 1; i <= n; i++) prt[i] = getfa(i);     for (int i = 1; i <= n; i++) {       if (ha[prt[i]] == 0) {         num[0]++;         ha[prt[i]] = num[0];         num[num[0]]++;       } else         num[ha[prt[i]]]++;     }     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};   const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};   const int Mod = 1000000000 + 0;   template <typename T>   inline T sq(T x) {     return x * x;   }   template <typename T>   inline T In() {     T x;     cin >> x;     return x;   }   template <typename T>   inline void Out(T& x) {     cout << x;   }   template <typename T>   inline void sort(T& v) {     sort(begin(v), end(v));   }   template <typename T>   inline void revs(T& v) {     reverse(begin(v), end(v));   }   template <typename T>   inline void uniq(T& v) {     sort(v);     v.erase(unique(begin(v), end(v)), end(v));   }   template <typename T>   inline int ubnd(T& v, typename T::value_type& x) {     return upper_bound(begin(v), end(v), x) - begin(v);   }   template <typename T>   inline int lbnd(T& v, typename T::value_type& x) {     return lower_bound(begin(v), end(v), x) - begin(v);   }   template <typename T, typename F>   inline void inpt(T& v, int n, F f) {     for (v.reserve(n); n--; v.emplace_back(f()))       ;   }   template <typename T, typename F>   inline void show(T& v, F f, string d =    , string e =   n ) {     int i = 0;     for (auto& x : v) i++ && (cout << d), f(x);     cout << e;   }   template <typename T>   inline typename T::iterator minel(T& v) {     return min_element(begin(v), end(v));   }   template <typename T>   inline typename T::iterator maxel(T& v) {     return max_element(begin(v), end(v));   }   inline void fast_io() {     ios::sync_with_stdio(0);     cin.tie(0);   }   inline int in() {     int x;     scanf( %d , &x);     return x;   }   inline long long pow_mod(long long a, long long k, long long m) {     long long r = 1;     for (; k > 0; a = a * a % m, k >>= 1)       if (k & 1) r = r * a % m;     return r;   }   inline long long mod_inv(long long a, long long p) {     return pow_mod(a, p - 2, p);   }   int main() {     vector<long long> xs, ys;     int n = in();     for (int i = 0; i < n; i++) {       long long x, y;       cin >> x >> y;       xs.emplace_back(x);       ys.emplace_back(y);     }     sort(xs);     sort(ys);     long long xx = abs(xs[0] - xs[n - 1]);     long long yy = abs(ys[0] - ys[n - 1]);     cout << sq(max(xx, yy)) << endl;     return 0;   }
#include <bits/stdc++.h>   const long long mod = (long long)1e9 + 7;   const int maxn = (int)4e5 + 2;   long long inf = 1LL << 60;   const double eps = 1e-9;   using namespace std;   template <class N>   inline void read(N &n) {     N x = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = 10 * x + ch -  0 ;       ch = getchar();     }     n = x * f;   }   long long a[2001], b[2001];   int main() {     ios_base::sync_with_stdio(0);     int n, m;     cin >> n;     long long s1 = 0, s2 = 0;     for (int i = 0; i < n; i++) {       cin >> a[i];       s1 += a[i];     }     cin >> m;     for (int i = 0; i < m; i++) {       cin >> b[i];       s2 += b[i];     }     long long diff = abs(s1 - s2);     pair<int, int> ans1 = {-1, -1};     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         long long bs = s2 - b[j] + a[i];         long long as = s1 - a[i] + b[j];         if (diff > abs(as - bs)) {           diff = abs(as - bs);           ans1 = {i, j};         }       }     }     map<long long, pair<int, int> > mpa, mpb;     for (int i = 0; i < n; i++) {       for (int j = i + 1; j < n; j++) {         mpa[a[i] + a[j]] = {i, j};       }     }     long long diff1 = inf;     pair<int, int> ans[2];     for (int i = 0; i < m; i++) {       for (int j = i + 1; j < m; j++) {         long long d = b[i] + b[j];         auto it1 = mpa.lower_bound((s1 - s2 + 2 * d) / 2);         if (it1 != mpa.begin()) it1--;         int jj = 0;         while (it1 != mpa.end() && jj <= 2) {           long long diff2 = abs((s1 - it1->first + d) - (s2 - d + it1->first));           if (diff1 > diff2) {             diff1 = diff2;             ans[1] = {i, j};             ans[0] = it1->second;           }           jj++;           it1++;         }       }     }     if (diff1 < diff) {       cout << diff1 << endl;       cout << 2 << endl;       cout << ans[0].first + 1 <<     << ans[1].first + 1 << endl;       cout << ans[0].second + 1 <<     << ans[1].second + 1 << endl;     } else {       cout << diff << endl;       if (ans1.first == -1)         cout << 0;       else {         cout << 1 << endl;         cout << ans1.first + 1 <<     << ans1.second + 1;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1e9 + 7;   const int iinf = 1 << 29;   const long long llinf = 1ll << 60;   const double PI = 3.14159265;   mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());   long long mrand(long long B) { return (unsigned long long)rng() % B; }   long long cross(pair<long long, long long> p1, pair<long long, long long> p2) {     return p1.first * p2.second - p2.first * p1.second;   }   bool online(pair<long long, long long> a, pair<long long, long long> b,               pair<long long, long long> c) {     pair<long long, long long> p1{b.first - a.first, b.second - a.second};     pair<long long, long long> p2{c.first - a.first, c.second - a.second};     return cross(p1, p2) == 0;   }   void z_func(vector<int> &z, vector<int> &s, int n) {     int L = 0, R = 0;     for (int i = 1; i < n; i++) {       if (i > R) {         L = R = i;         while (R < n && s[R - L] == s[R]) R++;         z[i] = R - L;         R--;       } else {         int k = i - L;         if (z[k] < R - i + 1)           z[i] = z[k];         else {           L = i;           while (R < n && s[R - L] == s[R]) R++;           z[i] = R - L;           R--;         }       }     }   }   const int MXN = 1e5 + 1;   int n, m;   bool roots[MXN];   vector<int> g[MXN];   int listt[MXN];   vector<int> ans;   void fail() {     cout <<  -1 n ;     exit(0);   }   int dfs(int node) {     int request = -1;     for (auto &v : g[node]) {       int req = dfs(v);       if (req != -1 && request != -1 && req != request) fail();       if (req != -1) request = req;     }     if (request != -1 && listt[node] != request) fail();     if (request == -1) {       if (listt[node] == node) {         ans.push_back(node);         return -1;       } else {         return listt[node];       }     } else {       if (node == listt[node]) {         ans.push_back(node);         return -1;       }       return listt[node];     }   }   void work() {     cin >> n >> m;     for (int i = 0; i < m; ++i) {       int u, v;       cin >> u >> v;       roots[v] = true;       g[u].push_back(v);     }     for (int i = 1; i <= n; ++i) cin >> listt[i];     for (int i = 1; i <= n; ++i)       if (!roots[i]) dfs(i);     cout << ((int)(ans).size()) <<   n ;     for (auto &e : ans) cout << e <<   n ;   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     work();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k;   struct Poi {     int x, y, ff;     bool operator<(const Poi &A) const {       return x < A.x || (x == A.x && y < A.y);     }   } pp[(200100)];   int row[(200100)], cntr;   int cnt[(200100)], pre[(200100)];   long long ans[(200100)];   inline void solve() {     sort(pp + 1, pp + 1 + n * 2);     for (int i = 1; i <= n * 2; ++i) {       int y = lower_bound(row + 1, row + 1 + cntr, pp[i].y) - row;       for (int j = y; row[j] < row[y] + k; ++j) {         if (cnt[j] > 0)           ans[cnt[j]] += (long long)(row[j + 1] - row[j]) * (pp[i].x - pre[j]);         pre[j] = pp[i].x;         cnt[j] += pp[i].ff;       }     }     for (int i = 1; i <= n; ++i) cout << ans[i] <<    ;   }   inline void In() {     scanf( %d %d , &n, &k);     for (int i = 1; i <= n; ++i) {       int i1 = i * 2 - 1, i2 = i * 2;       scanf( %d %d , &pp[i1].x, &pp[i1].y);       pp[i1].ff = 1;       row[i1] = pp[i1].y;       row[i2] = row[i1] + k;       pp[i2].y = pp[i1].y;       pp[i2].ff = -1;       pp[i2].x = pp[i1].x + k;     }     sort(row + 1, row + 1 + n * 2);     cntr = 1;     for (int i = 2; i <= n * 2; ++i)       if (row[i] != row[cntr]) row[++cntr] = row[i];   }   int main() {     In();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int gcd(long long int x, long long int y) {     if (y == 0) return x;     return gcd(y, x % y);   }   long long exp(long long a, long long b) {     if (b == 0) return 1;     long long res = exp(a, b / 2);     if (b % 2)       return res * res * a;     else       return res * res;   }   int prime(long long x) {     if (x % 2 == 0)       return 0;     else {       for (int i = 3; i * i <= x; i += 2) {         if (x % i == 0) return 0;       }     }     return 1;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     int n, m, k;     map<int, int> ma;     cin >> n;     int arr[n];     for (int i = 0; i < n; i++) cin >> arr[i];     cin >> m;     int brr[m];     for (int i = 0; i < m; i++) cin >> brr[i];     for (int i = 0; i < n; i++) {       for (int j = m - 1; j >= 0; j--) {         if (brr[j] % arr[i] == 0) {           k = brr[j] / arr[i];           if (ma.find(k) == ma.end())             ma.insert({k, 1});           else             ma[k]++;         }       }     }     map<int, int>::iterator it;     it = ma.end();     it--;     cout << it->second <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a[105], sum = 0, i, j, x, k;     scanf( %d , &n);     for (i = 0; i < n; i++) {       scanf( %d , &a[i]);       sum += a[i];     }     x = sum / (n / 2);     for (j = 0; j < n; j++) {       for (k = j + 1; k < n; k++) {         if (a[j] + a[k] == x) {           printf( %d %d n , j + 1, k + 1);           a[j] = 0;           a[k] = 0;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f, N = 1e3 + 5, MOD = 1e9 + 7;   int T, cas = 0;   int n, m;   bool vis[N];   vector<int> primes;   void Init_Primes() {     memset(vis, 0, sizeof(vis));     int m = sqrt(N + 0.5);     for (int i = (2); i <= (m); i++)       if (!vis[i])         for (int j = i * i; j <= N; j += i) vis[j] = 1;     for (int i = (2); i < (N); i++)       if (!vis[i]) primes.push_back(i);   }   int main() {     Init_Primes();     while (scanf( %d , &n) != EOF) {       int a[N], k = 0;       for (int i = 2; i <= n; i++) {         if (!vis[i]) {           int t = 1;           while (t * i <= n) {             t *= i;             a[k++] = t;           }         }       }       printf( %d n , k);       for (int i = 0; i < (k - 1); i++) printf( %d  , a[i]);       if (k > 0) printf( %d n , a[k - 1]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int d1[5], c1[5], d2[5], c2[5];   int min2[5], min1[5];   int main() {     int n;     cin >> n;     for (int i = 1; i <= 4; i++) {       cin >> c1[i] >> d1[i] >> c2[i] >> d2[i];       min1[i] = min(c1[i], d1[i]);       min2[i] = min(c2[i], d2[i]);     }     int tmp = 1e9;     int it;     for (int i = 1; i <= 4; i++)       if (min1[i] + min2[i] < tmp) {         tmp = min1[i] + min2[i];         it = i;       }     if (tmp > n)       cout << -1;     else       cout << it <<     << min1[it] <<     << n - min1[it];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a, x, y, xx, yy;   int main() {     cin >> a >> x >> y >> xx >> yy;     if (abs(x - xx) == a)       cout << a + min(2 * a - y - yy, y + yy);     else if (abs(y - yy) == a)       cout << a + min(2 * a - x - xx, x + xx);     else       cout << abs(xx - x) + abs(yy - y);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long a, b, c;     cin >> a >> b >> c;     long long d = b * b - 4 * a * c;     if (a != 0) {       double x = a, y = b;       if (d < 0) cout << 0;       if (d == 0) {         cout << 1 << endl;         printf( %lf , -y / (2 * x));       }       if (d > 0) {         cout << 2 << endl;         if (x > 0)           printf( %lf n%lf , (-y - sqrt(d)) / (2 * x), (-y + sqrt(d)) / (2 * x));         else           printf( %lf n%lf , (-y + sqrt(d)) / (2 * x), (-y - sqrt(d)) / (2 * x));       }     } else {       if (b == 0) {         if (c == 0)           cout << -1;         else           cout << 0;       } else {         double s = c, t = b;         cout << 1 << endl;         printf( %lf , -s / t);       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int arr[200][200];     int n, m, ok = 1000000000, ans = 0;     scanf( %d %d , &n, &m);     for (int i = 0; i < n; i++) {       ok = 1000000000;       for (int j = 0; j < m; j++) {         scanf( %d , &arr[i][j]);         if (ok > arr[i][j]) ok = arr[i][j];       }       ans = max(ans, ok);     }     printf( %d , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int a;     cin >> a;     if (a <= 1) {       cout << a;     } else if (a == 2) {       cout << 2;     } else if (a == 3) {       cout << 6;     } else if (a == 4) {       cout << 20;     } else if (a == 5) {       cout << 70;     } else if (a == 6) {       cout << 252;     } else if (a == 7) {       cout << 924;     } else if (a == 9) {       cout << 12870;     } else if (a == 10) {       cout << 48620;     } else if (a == 8) {       cout << 3432;     }   }
#include <bits/stdc++.h>   using namespace std;   long long a[200001], b[200001];   int main() {     int t;     int i, j;     cin >> t;     while (t--) {       long long n, m;       cin >> n >> m;       for (i = 0; i < n; i++) cin >> a[i] >> b[i];       long long A = 0, B = 0, Ap = 0, Bp = 0;       long long tot = 0, sum = 0;       for (i = 0; i < n; i++) {         A += a[i] - (m - min(m, b[i]));         Ap += m - min(m, b[i]);         B += b[i] - (m - min(m, a[i]));         Bp += m - min(m, a[i]);         sum += m;         tot += a[i] + b[i] - m;       }       if (A + A < tot) {         cout << tot - (A + A) << endl;         for (i = 0; i < n; i++) {           cout << m - min(m, b[i]) <<     << min(m, b[i]) << endl;         }       } else if (B + B < tot) {         cout << tot - (B + B) << endl;         for (i = 0; i < n; i++) {           cout << min(m, a[i]) <<     << m - min(m, a[i]) << endl;         }       } else {         long long togo = A - tot / 2;         cout << (tot & 1) << endl;         for (i = 0; i < n; i++) {           long long x = min(togo, min(m, b[i]));           x = min(x, a[i] - (m - min(m, b[i])));           togo -= x;           cout << m - min(m, b[i]) + x <<     << min(m, b[i]) - x << endl;         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     long long mx = 0, x = 0;     cin >> n;     for (int i = 0; i < n; i++) {       long long y;       cin >> y;       y += mx;       mx += max(0LL, x - y), x = max(y, x);     }     cout << mx << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC target( avx,avx2,fma )   using namespace std;   const long long MOD = 1e9 + 7;   const long long mxN = 1e5 + 3;   vector<long long> g[mxN];   long long good[mxN];   long long total[mxN], people[mxN];   long long h[mxN];   bool ok[mxN];   void dfs1(long long u, long long par) {     long long sum = 0;     for (long long i : g[u]) {       if (i != par) {         dfs1(i, u);         sum += total[i];       }     }     total[u] = sum + people[u];   }   bool dfs2(long long u, long long par) {     bool ret = true;     if (ok[u] == false) return false;     long long cnt = 0;     for (long long i : g[u]) {       if (i != par) {         cnt++;         ret = (ret && dfs2(i, u));       }     }     if (ret == true) {       long long su = 0;       for (long long ii : g[u]) {         if (ii != par) {           su += good[ii];         }       }       if (su > good[u])         return false;       else         return true;     }     return false;   }   void solve() {     long long n;     cin >> n;     for (long long i = 0; i <= n; ++i) {       g[i].clear();       good[i] = 0;       total[i] = 0;       people[i] = 0;       h[i] = 0;       ok[i] = true;     }     long long m;     cin >> m;     for (long long i = 1; i <= n; ++i) {       cin >> people[i];     }     for (long long i = 1; i <= n; ++i) {       cin >> h[i];     }     long long u, v;     for (long long i = 1; i < n; ++i) {       cin >> u >> v;       g[u].push_back(v);       g[v].push_back(u);     }     dfs1(1, -1);     for (long long i = 1; i <= n; ++i) {       long long g2 = (total[i] + h[i]);       long long b2 = (total[i] - h[i]);       if (g2 & 1) {         ok[i] = false;         continue;       }       if (b2 & 1) {         ok[i] = false;         continue;       }       long long go = g2 / 2;       long long b = b2 / 2;       if (go > total[i] or b > total[i] or go < 0 or b < 0) {         ok[i] = false;         continue;       }       good[i] = go;     }     bool ans = dfs2(1, -1);     if (ans)       cout <<  YES             <<   n ;     else       cout <<  NO             <<   n ;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long nT = 1;     cin >> nT;     for (long long i = 1; i <= nT; ++i) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100;   int l[N], r[N], t[N], c[N];   int main() {     int n, m;     scanf( %d %d , &n, &m);     for (int i = 0; i < m; ++i) {       scanf( %d %d %d %d , l + i, r + i, t + i, c + i);     }     int ans = 0;     for (int i = 1; i <= n; ++i) {       int win = 0, min = -1;       for (int j = 0; j < m; ++j) {         if (l[j] <= i && i <= r[j]) {           if (min == -1 || min > t[j]) {             min = t[j];             win = c[j];           }         }       }       ans += win;     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MX = 3005;   int n, a[MX], mem[MX][MX], ind[MX];   vector<int> pos[MX];   int dp(int i, int j) {     if (i > j) return 0;     int &res = mem[i][j];     if (res != -1) return res;     res = dp(i, j - 1);     for (int k = ind[j] - 1, x; k >= 0 && (x = pos[a[j]][k]) >= i; k--)       res = max(res, dp(i, x) + dp(x + 1, j - 1) + 1);     return res;   }   void main_() {     cin >> n;     for (int i = 0; i < int(n + 1); i++) pos[i].clear();     for (int i = 0; i < int(n); i++) {       cin >> a[i];       ind[i] = pos[a[i]].size();       pos[a[i]].push_back(i);     }     for (int i = 0; i < int(n); i++)       for (int j = 0; j < int(n); j++) mem[i][j] = -1;     cout << n - 1 - dp(0, n - 1) <<   n ;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t = 1;     cin >> t;     while (t--) main_();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long solve() {     long long k, a, b;     cin >> k >> a >> b;     if (a > b) swap(a, b);     if (a == 0) {       if (b % k == 0) return b / k;       return -1;     }     long long ans = a / k + b / k;     if (b % k != 0 && a < k) return -1;     if (a % k != 0 && b < k) return -1;     if (ans == 0) return -1;     return ans;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout << solve() << endl;     return 0;   }