malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   bool check(string s) {     for (int i = 0; i < s.size() - 1; i++) {       if (s[i] == s[i + 1] && s[i] ==  1 ) {         return false;       }     }     return true;   }   int main() {     int n;     cin >> n;     string v;     cin >> v;     int flag = 0, f = 1;     if (n == 1 && v[0] ==  0 ) {       cout <<  No ;     } else {       if (check(v) == false) {         flag = 1;       } else {         for (int i = 0; i < n; i++) {           if (v[i] ==  0 ) {             v[i] =  1 ;             if (check(v) == true) {               cout <<  No ;               f = 0;               break;             } else {               v[i] =  0 ;             }           }         }       }       if (flag == 1) {         cout <<  No ;       }       if (f == 1 && flag == 0) {         cout <<  Yes ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     string s1, s2;     cin >> s1 >> s2;     long long i, n = s1.size(), k1 = 0, k2 = 0, flag = 0, cnt = 0;     for (i = 0; i < n; i++) {       if (s1[i] ==  4  && s2[i] ==  7 )         k1++;       else if (s1[i] ==  7  && s2[i] ==  4 )         k2++;     }     if (k1 >= k2) {       cnt = k2 + (k1 - k2);     } else {       cnt = k1 + (k2 - k1);     }     cout << cnt;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   unsigned long long i, n, k, a[100001], b[100001];   unsigned long long solve(unsigned long long val) {     unsigned long long cnt = 0;     for (i = 0; i < n; i++) {       if (a[i] * val > b[i]) cnt += val * a[i] - b[i];     }     if (cnt > k) return 0;     return 1;   }   unsigned long long binarysearch(unsigned long long l, unsigned long long r) {     unsigned long long mid, ans = 0;     while (l <= r) {       mid = (l + r) / 2;       if (solve(mid)) {         ans = mid;         l = mid + 1;       } else         r = mid - 1;     }     return ans;   }   int main() {     cin >> n >> k;     for (i = 0; i < n; i++) cin >> a[i];     for (i = 0; i < n; i++) cin >> b[i];     unsigned long long l, r;     l = 0;     r = 0;     for (int i = 0; i < n; i++) r = max((b[i] + k) / a[i], r);     cout << binarysearch(l, r) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 7e3 + 11;   int n;   vector<int> s[2];   const int loose = 0;   const int win = 1;   bool vis[2][maxn][2];   int deg[maxn][2];   int32_t main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     cin >> n;     for (int k, i = 0; i < 2; i++) {       cin >> k;       s[i].resize(k);       for (auto &x : s[i]) cin >> x;     }     queue<pair<int, int> > q[2];     q[loose].push({0, 0});     q[loose].push({0, 1});     vis[loose][0][0] = 1;     vis[loose][0][1] = 1;     while (!q[loose].empty()) {       while (!q[loose].empty()) {         pair<int, int> fr = q[loose].front();         q[loose].pop();         int player = fr.second ^ 1;         int me = fr.first;         for (auto x : s[player]) {           int wp = me - x;           while (wp < 0) wp += n;           if (!vis[win][wp][player] && !vis[loose][wp][player]) {             vis[win][wp][player] = 1;             q[win].push({wp, player});           }         }       }       while (!q[win].empty()) {         pair<int, int> fr = q[win].front();         q[win].pop();         int player = fr.second ^ 1;         int me = fr.first;         for (auto x : s[player]) {           int lp = me - x;           while (lp < 0) lp += n;           if (!vis[loose][lp][player] && !vis[win][lp][player] &&               ++deg[lp][player] == (int)(s[player]).size()) {             vis[loose][lp][player] = 1;             q[loose].push({lp, player});           }         }       }     }     for (int player = 0; player < 2; player++) {       for (int i = 1; i < n; i++) {         if (vis[win][i][player])           cout <<  Win  ;         else if (vis[loose][i][player])           cout <<  Lose  ;         else           cout <<  Loop  ;       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 505, M = 1e9 + 7;   long long K, m, n, a[N], H[N], num[N], F[N], G[N], x, ans[N], C[N];   inline long long ksm(long long x, long long y) {     long long ans = 1;     for (; y; y >>= 1, x = x * x % M)       if (y & 1) (ans *= x) %= M;     return ans;   }   inline void cf1(long long A[]) {     memset(C, 0, sizeof C);     for (long long i = 0; i < 250; i++)       for (long long j = 0; j < 250; j++) (C[i + j] += A[i] * A[j]) %= M;     long long Inv = ksm(num[250], M - 2);     for (long long i = 499; i >= 250; i--) {       long long t = Inv * C[i] % M;       for (long long j = 0; j <= 250; j++)         (C[-250 + j + i] += M - t * num[j] % M) %= M;     }     for (long long i = 0; i < N; i++) A[i] = C[i];   }   inline void cf(long long A[], long long B[]) {     memset(C, 0, sizeof C);     for (long long i = 0; i < 250; i++)       for (long long j = 0; j < 250; j++) (C[i + j] += A[i] * B[j]) %= M;     long long Inv = ksm(num[250], M - 2);     for (long long i = 499; i >= 250; i--) {       long long t = Inv * C[i] % M;       for (long long j = 0; j <= 250; j++)         (C[-250 + j + i] += M - t * num[j] % M) %= M;     }     for (long long i = 0; i < N; i++) A[i] = C[i];   }   signed main() {     scanf( %lld%lld%lld , &K, &m, &n);     for (long long i = 1; i <= K; i++) scanf( %lld , &a[i]);     while (m--) {       scanf( %lld , &x);       (num[250 - x] += M - 1) %= M;     }     num[250]++;     ans[0] = 1;     for (long long i = 1; i < 250; i++)       for (long long j = 1; j <= i; j++)         (ans[i] += M - ans[i - j] * num[250 - j] % M) %= M;     for (long long i = 1; i <= K; i++) {       memset(F, 0, sizeof F);       memset(G, 0, sizeof G);       F[1] = 1;       long long y = a[i];       G[0] = 1;       for (; y; y >>= 1, cf1(F))         if (y & 1) cf(G, F);       for (long long j = 0; j < 250; j++) (H[j] += G[j]) %= M;     }     memset(G, 0, sizeof G);     G[0] = 1;     for (; n; n >>= 1, cf1(H))       if (n & 1) cf(G, H);     long long Ans = 0;     for (long long i = 0; i < 250; i++) (Ans += G[i] * ans[i]) %= M;     printf( %lld n , Ans);   }
#include <bits/stdc++.h>   using namespace std;   void marmot0814() {     int n;     cin >> n;     int p1 = 1, p2 = 2, p3 = 3;     while (n--) {       int v;       cin >> v;       if (v == p3) {         cout <<  NO n ;         return;       } else if (v == p1) {         swap(p2, p3);       } else {         swap(p1, p3);       }     }     cout <<  YES n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int t = 1, kase = 0;     while (t--) {       marmot0814();     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 100;   const int mod = 998244353;   void MOD(long long &x) {     if (x >= mod) x -= mod;   }   struct Tree {     long long mul[maxn << 2], add[maxn << 2], sum[maxn << 2];     void push(int l, int r, int rt) {       if (mul[rt] != 1) {         sum[(rt << 1)] = sum[(rt << 1)] * mul[rt],                    sum[(rt << 1 | 1)] = sum[(rt << 1 | 1)] * mul[rt];         add[(rt << 1)] = add[(rt << 1)] * mul[rt],                    add[(rt << 1 | 1)] = add[(rt << 1 | 1)] * mul[rt];         mul[(rt << 1)] = mul[(rt << 1)] * mul[rt],                    mul[(rt << 1 | 1)] = mul[(rt << 1 | 1)] * mul[rt];         mul[rt] = 1;       }       if (add[rt]) {         int mid = l + r >> 1;         MOD(sum[(rt << 1)] += add[rt] * (mid - l + 1) % mod),             MOD(sum[(rt << 1 | 1)] += add[rt] * (r - mid) % mod);         MOD(add[(rt << 1)] += add[rt]), MOD(add[(rt << 1 | 1)] += add[rt]);         add[rt] = 0;       }     }     void build(int l, int r, int rt) {       add[rt] = 0, mul[rt] = 1;       sum[rt] = 0;       if (l == r) return;       int mid = l + r >> 1;       build(l, mid, (rt << 1));       build(mid + 1, r, (rt << 1 | 1));     }     void update(int l, int r, int rt, int ql, int qr, int op, long long v) {       if (ql <= l && qr >= r) {         if (op == 1) {           MOD(add[rt] += v);           MOD(sum[rt] += (r - l + 1) * v % mod);         } else {           sum[rt] = sum[rt] * v;           add[rt] = add[rt] * v;           mul[rt] = mul[rt] * v;         }       } else {         push(l, r, rt);         int mid = l + r >> 1;         if (ql <= mid) update(l, mid, (rt << 1), ql, qr, op, v);         if (qr > mid) update(mid + 1, r, (rt << 1 | 1), ql, qr, op, v);         MOD(sum[rt] = sum[(rt << 1)] + sum[(rt << 1 | 1)]);       }     }     long long query(int l, int r, int rt, int p) {       if (l == r)         return sum[rt];       else {         push(l, r, rt);         int mid = l + r >> 1;         if (p <= mid)           return query(l, mid, (rt << 1), p);         else           return query(mid + 1, r, (rt << 1 | 1), p);       }     }   } T;   int a[maxn], k;   long long slove(int v[], int n) {     T.build(1, k, 1);     if (!v[1])       T.update(1, k, 1, 1, k, 1, 1);     else       T.update(1, k, 1, v[1], v[1], 1, 1);     for (int i = 2; i <= n; ++i) {       long long sum = T.sum[1];       if (!v[i])         T.update(1, k, 1, 1, k, 2, -1), T.update(1, k, 1, 1, k, 1, sum);       else {         long long x = T.query(1, k, 1, v[i]);         T.update(1, k, 1, 1, k, 2, 0);         T.update(1, k, 1, v[i], v[i], 1, sum - x);       }     }     return T.sum[1];   }   int main() {     ios::sync_with_stdio(0), cin.tie(0);     int n;     cin >> n >> k;     for (int i = 1; i <= n; ++i) {       cin >> a[i];       if (a[i] == -1) a[i] = 0;     }     long long ans = 1;     static int tp[maxn];     int top = 0;     for (int i = 1; i <= n; i += 2) tp[++top] = a[i];     long long ans1 = (slove(tp, top) + mod) % mod;     top = 0;     for (int i = 2; i <= n; i += 2) tp[++top] = a[i];     long long ans2 = (slove(tp, top) + mod) % mod;     cout << ans1 * ans2 % mod <<   n ;     return 0;   }
#include <bits/stdc++.h>   long long res;   int max;   const int N = 205;   int f[N], tt[N], cnt, next[N];   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }   void dfs(int u) {     cnt++;     f[u] = -2;     tt[u] = cnt;     if (next[u] != u) {       if (f[next[u]] == -2) {         int tmp = tt[u] - tt[next[u]] + 1;         res = lcm(res, tmp);         cnt = tt[next[u]] - 1;       } else {         if (f[next[u]] == -1) {           f[u] = 1;         } else {           if (f[next[u]] > 0) {             f[u] = f[next[u]] + 1;           } else {             dfs(next[u]);             if (tt[next[u]] <= cnt) {               f[u] = f[next[u]] + 1;             } else {               if (tt[u] <= cnt)                 f[u] = 1;               else                 f[u] = -1;             }           }         }       }     } else {       f[u] = -1;       cnt--;     }     if (f[u] > max) max = f[u];     if (f[u] == -2) f[u] = -1;   }   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &next[i]);     for (int i = 1; i <= n; i++) f[i] = 0;     max = 0;     res = 1;     for (int i = 1; i <= n; i++)       if (f[i] == 0) {         cnt = 0;         dfs(i);       }     if (max > 0) {       if (max % res == 0)         res = max;       else         res *= max / res + 1;     }     printf( %I64d , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double ppow(double a, int b) {     if (b == 1) return a;     if (b == 0) return 1;     double y = ppow(a, b / 2);     y = y * y;     if (b % 2 == 1) y = y * a;     return y;   }   int main() {     int n, m, i;     double s = 1, ans = 0, c = 0, x;     scanf( %d%d , &n, &m);     for (i = 1; i <= m; i++) s = s / n;     for (i = 1; i <= n; i++) {       x = (double)i / n;       x = ppow(x, m);       ans += (x - c) * i;       c = x;     }     printf( %.8lf n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX_N = 5500;   int n, T;   double p[MAX_N];   int t[MAX_N];   double dq[MAX_N];   int main() {     scanf( %d%d , &n, &T);     for (int i = 0; i < n; i++) {       scanf( %lf%d , &p[i], &t[i]);       p[i] /= 100;     }     vector<double> cur(T + 1), nxt(T + 1);     double exp = 0;     cur[0] = 1;     for (int i = 0; i < n; i++) {       double prb = 0;       double f = 1.0;       int s1 = 0, s2 = 0;       for (int j = 0; j < t[i] - 1; j++) {         f *= 1.0 - p[i];       }       for (int j = 0; j <= T; j++) {         double poped = 0;         if (s2 - s1 > t[i] - 1) {           poped = dq[s1];           prb -= f * dq[s1];           s1++;         }         nxt[j] = f * poped + prb * p[i];         dq[s2] = cur[j];         s2++;         prb = (1.0 - p[i]) * prb + cur[j];       }       exp += i * prb;       cur.swap(nxt);       fill(nxt.begin(), nxt.end(), 0);     }     printf( %.15f n , exp + n * accumulate(cur.begin(), cur.end(), 0.0));   }
#include <bits/stdc++.h>   using namespace ::std;   const long double PI = acos(-1);   const long long MOD = 1000000000 + 7;   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   long long add(long long a, long long b, long long m = MOD) {     return (a % m + b % m + 2 * m) % m;   }   long long mul(long long a, long long b, long long m = MOD) {     return ((a % m + m) * (b % m + m)) % m;   }   long long pow_mod(long long a, long long b, long long m = MOD) {     long long res = 1LL;     a = a % m;     while (b) {       if (b & 1) res = mul(res, a, m);       b >>= 1;       a = mul(a, a, m);     }     return res;   }   long long fastexp(long long a, long long b) {     long long res = 1LL;     while (b) {       if (b & 1) res = res * a;       b >>= 1;       a *= a;     }     return res;   }   int gcdExtendido(int a, int b, int *x, int *y) {     if (a == 0) {       *x = 0;       *y = 1;       return b;     }     int x1, y1;     int gcd = gcdExtendido(b % a, a, &x1, &y1);     *x = y1 - (b / a) * x1;     *y = x1;     return gcd;   }   int modInverso(int a, int m) {     int x, y;     int g = gcdExtendido(a, m, &x, &y);     if (g != 1)       return -1;     else       return (x % m + m) % m;   }   const int N = 100000 + 5;   struct line {     long long m;     long long b;     line(long long _m, long long _b) {       m = _m;       b = _b;     }   };   int n;   int a[N];   int b[N];   long long dp[N];   vector<line> ConvexHull;   bool l2IsUseless(line l1, line l2, line l3) {     return 1.0l * (l3.b - l1.b) * (l2.m - l1.m) >=            1.0L * (l2.b - l1.b) * (l3.m - l1.m);   }   void add_line(line x) {     int len = ConvexHull.size();     while (len >= 2 and            l2IsUseless(ConvexHull[len - 2], ConvexHull[len - 1], x)) {       ConvexHull.pop_back();       len--;     }     ConvexHull.push_back(x);   }   long long f(int i, long long x) {     return ConvexHull[i].m * x + ConvexHull[i].b;   }   long long getMinimum(long long x) {     int lo = 0, hi = int(ConvexHull.size()) - 1;     while (lo < hi) {       int mi = lo + (hi - lo) / 2;       if (f(mi, x) >= f(mi + 1, x))         lo = mi + 1;       else         hi = mi;     }     return f(lo, x);   }   int main() {     scanf( %d , &(n));     for (int i = 0; i < n; i++) {       scanf( %d , &(a[i]));     }     for (int i = 0; i < n; i++) {       scanf( %d , &(b[i]));     }     dp[0] = 0LL;     add_line(line(b[0], dp[0]));     for (int i = 1; i < n; i++) {       dp[i] = getMinimum(a[i]);       add_line(line(1LL * b[i], dp[i]));     }     printf( %lld n , dp[n - 1]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   T sqr(T x) {     return x * x;   }   template <class T>   T distsqr(T x, T y, T a, T b) {     return sqr(x - a) + sqr(y - b);   }   double cosine_angle(double a, double b, double c) {     return (double)(sqr(a) + sqr(b) - sqr(c)) / ((double)2.0 * a * b);   }   template <class T>   T Maximum(T a, T b) {     return a > b ? a : b;   }   template <class T>   T Minimum(T a, T b) {     return a < b ? a : b;   }   template <class T>   T GCD(T a, T b) {     if (!b) return a;     return GCD(b, a % b);   }   template <class T>   void SWAP(T &a, T &b) {     T temp = a;     a = b;     b = temp;     return;   }   template <class T>   T sign(T a) {     return a < 0 ? -1 : 1;   }   template <class T>   T BigMod(T a, T n, T mod) {     if (!n) return (T)1 % mod;     long long int power = BigMod(a, n >> 1, mod);     power %= mod;     power *= power;     power %= mod;     if (n & 1) power *= a % mod, power %= mod;     return power;   }   template <class T>   T ExtendedEuclid(T a, T b, T c) {     if (!a) return 0;     return (b * ExtendedEuclid(b % a, a, -c) + c) / a;   }   template <class T>   T ModInverse(T a, T m) {     return ((ExtendedEuclid(a, m, (T)GCD(a, m))) % (m) + (m)) % (m);   }   struct S {     char name[20];     int region, score;   } player[100100];   int Comp(const void *a, const void *b) {     S x = *(S *)a, y = *(S *)b;     if (x.region == y.region) return y.score - x.score;     return x.region - y.region;   }   int main() {     int i, j, k, n, m;     S A[3];     scanf( %d %d , &n, &m);     for (i = 0; i < n; i++)       scanf( %s %d %d , player[i].name, &player[i].region, &player[i].score);     qsort(player, n, sizeof(S), Comp);     player[n].region = m + 1;     for (i = j = k = 0; i < m; i++) {       while (player[j].region == i + 1) {         if (k < 3) {           A[k++] = player[j];         }         j++;       }       if (k == 2)         printf( %s %s , A[0].name, A[1].name);       else {         if (A[1].score == A[2].score)           printf( ? );         else           printf( %s %s , A[0].name, A[1].name);       }       k = 0;       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   const int N = 1e3 + 5;   using namespace std;   int main() {     ios::sync_with_stdio(false);     int arr[N][N], str, sve, k, n[N], m[N], i, j, x, y;     char ch;     cin >> str >> sve >> k;     for (i = 1; i <= str; i++)       for (j = 1; j <= sve; j++) cin >> arr[i][j];     for (i = 1; i <= N; i++) n[i] = m[i] = i;     while (k--) {       cin >> ch >> x >> y;       if (ch ==  r )         swap(n[x], n[y]);       else if (ch ==  c )         swap(m[x], m[y]);       else         cout << arr[n[x]][m[y]] << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, l;     cin >> n >> l;     vector<int> a(n);     vector<int> b(n);     for (int i = 0; i < n; ++i) cin >> a[i];     for (int i = 0; i < n; ++i) cin >> b[i];     vector<int> c(n);     for (int zsuv = 0; zsuv < l; ++zsuv) {       for (int i = 0; i < n; ++i) {         c[i] = (b[i] + zsuv) % l;       }       bool isequal = true;       for (int i = 0; i < n; ++i) {         bool iii = false;         for (int j = 0; j < n; ++j) {           if (c[i] == a[j]) {             iii = true;             break;           }         }         if (!iii) {           isequal = false;           break;         }       }       if (isequal) {         cout <<  YES ;         return 0;       }     }     cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double pi = acos(-1);   int main() {     ios::sync_with_stdio(false);     int m, n, k;     while (cin >> m >> n >> k) {       k *= 2;       if (m >= k && n >= k) {         cout <<  First  << endl;       } else {         cout <<  Second  << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<pair<long long, long long>> g[111111];   long long d[111111];   set<long long> t[111111];   int main() {     int n, m;     cin >> n >> m;     for (int i = 1; i <= n; i++) {       d[i] = 1e13;     }     for (int i = 1; i <= m; i++) {       long long a, b, cost;       cin >> a >> b >> cost;       g[a].push_back({b, cost});       g[b].push_back({a, cost});     }     for (int i = 1; i <= n; i++) {       long long a;       cin >> a;       for (int j = 1; j <= a; j++) {         long long b;         cin >> b;         t[i].insert(b);       }     }     d[1] = 0;     set<pair<long long, long long>> q;     q.insert({0, 1});     while (!q.empty()) {       long long h = 0;       int v = q.begin()->second;       q.erase(q.begin());       while (t[v].find(d[v]) != t[v].end()) {         h++;         d[v]++;       }       for (int i = 0; i < g[v].size(); i++) {         long long to = g[v][i].first, cost = g[v][i].second;         if (d[to] > d[v] + cost) {           q.erase({d[to], to});           d[to] = d[v] + cost;           q.insert({d[to], to});         }       }       d[v] = d[v] - h;     }     if (d[n] == 1e13) {       cout << -1;       return 0;     }     cout << d[n];   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a1, a2, a3, a4;     cin >> a1 >> a2 >> a3 >> a4;     int a[4];     a[0] = a1;     a[1] = a2;     a[2] = a3;     a[3] = a4;     sort(a, a + 4);     if (a[0] + a[1] + a[2] == a[3]) {       cout <<  YES ;     } else if (a[0] + a[3] == a[1] + a[2]) {       cout <<  YES ;     } else if (a[0] + a[2] == a[1] + a[3]) {       cout <<  YES ;     } else {       cout <<  NO ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long read() {     long long x = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return x * f;   }   const int maxn = 300010;   int n, Q, red[maxn], need[maxn], c[maxn], cnt = 0, ans = 0;   queue<int> q;   int main() {     memset(red, 0, sizeof(red));     memset(need, 0, sizeof(need));     memset(c, 0, sizeof(c));     n = read();     Q = read();     while (Q--) {       int opt = read(), x = read();       if (opt == 1) {         need[x]++;         ans++;         q.push(x);       } else if (opt == 2) {         ans -= need[x] - red[x];         red[x] = need[x];       } else if (opt == 3) {         int t = x - cnt;         while (!q.empty() && t > 0) {           t--;           int cur = q.front();           q.pop();           cnt++;           c[cur]++;           if (c[cur] > red[cur]) {             ans -= c[cur] - red[cur];             red[cur] = c[cur];           }         }       }       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     unsigned long long ans = 1e18, n, k;     cin >> n >> k;     vector<unsigned long long> v;     for (unsigned long long i = 1; i <= n; i++)       if (n % i == 0) v.push_back(i);     for (unsigned long long x : v)       if (x < k) ans = min(ans, (n / x) * k + x);     cout << ans;   }