malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main(int argc, const char *argv[]) {     int n, m;     scanf( %d %d , &n, &m);     int a[n], b[n];     map<int, int> mp_a;     map<int, int> mp_b;     for (int i = 0; i < n; i++) scanf( %d , &a[i]);     for (int i = 0; i < n; i++) {       scanf( %d , &b[i]);       mp_b[b[i]]++;     }     sort(a, a + n);     int k = a[0];     long long ans = 2000000000000000 + 5;     for (int i = 0; i < n; i++) {       int x;       if (b[i] == k)         x = 0;       else if (b[i] > k)         x = b[i] - k;       else         x = m - k + b[i];       for (int j = 0; j < n; j++) {         mp_a[(a[j] + x) % m]++;       }       bool f = true;       for (auto &it : mp_a) {         if (mp_b.find(it.first) != mp_b.end() && mp_b[it.first] == it.second)           continue;         else           f = false;       }       if (f) ans = min(ans, (long long)x);       mp_a.clear();     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<pair<int, int> > vc, va, vb;   int a[3], b[3], c[3];   long long n, m, s, p[50], pp[1 << 20];   void fac(int k, vector<pair<int, int> > &v) {     int m = sqrt(k);     for (int i = 2; i <= m; i++)       if (k % i == 0) {         int cnt = 0;         while (k % i == 0) k /= i, cnt++;         v.push_back(pair<int, int>(i, cnt));       }     if (k > 1) v.push_back(pair<int, int>(k, 1));     return;   }   void func(vector<pair<int, int> > &v) {     sort(v.begin(), v.end());     vector<pair<int, int> > w;     for (auto first : v) {       if (!w.empty() && w.back().first == first.first)         w.back().second += first.second;       else         w.push_back(first);     }     v = w;     return;   }   long long ans;   void calc(int first, long long up) {     if (first == vc.size()) {       ans++;       return;     }     if (up < vc[first].first) {       ans++;       return;     }     int al = vc[first].second;     for (int i = 0; i <= al; i++) {       calc(first + 1, up);       up /= vc[first].first;       if (up == 0) break;     }     return;   }   int main() {     int T;     for (scanf( %d , &T); T--;) {       scanf( %d %d %d , &a[0], &a[1], &a[2]);       scanf( %d %d %d , &b[0], &b[1], &b[2]);       scanf( %d %d %d , &c[0], &c[1], &c[2]);       long long m = 1ll * b[0] * b[1] * b[2];       va.clear();       vb.clear(), vc.clear();       ans = 0;       for (int i = 0; i < 3; i++) fac(a[i], va);       for (int i = 0; i < 3; i++) fac(c[i], vc);       func(va), func(vc);       if (vc[0].first == 2)         vc[0].second++;       else         vc.insert(vc.begin(), pair<int, int>(2, 1));       n = 1ll * a[0] * a[1] * a[2];       m = 1ll * b[0] * b[1] * b[2];       calc(0, n);       int sz = va.size();       for (int i = 0; i < sz; i++) {         int k =             lower_bound(vc.begin(), vc.end(), pair<int, int>(va[i].first, 0)) -             vc.begin();         int deg = 0;         if (k < vc.size() && vc[k].first == va[i].first) deg = vc[k].second;         if (va[i].second > deg)           vb.push_back(pair<int, int>(va[i].first, deg + 1));       }       sz = vb.size();       for (int i = 0; i < sz; i++) {         int q = vb[i].first, r = vb[i].second;         p[i] = 1;         while (r--) p[i] *= q;       }       int up = 1 << sz;       pp[0] = 1;       for (int i = 1; i < up; i++) {         int t = __builtin_ctz(i);         pp[i] = pp[i - (1 << t)] * p[t];       }       for (int i = 0; i < up; i++) {         int k = __builtin_popcount(i);         if (k & 1)           ans -= m / pp[i];         else           ans += m / pp[i];       }       printf( %I64d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long ans[1000005], anss[1000005][10];   int make(int n) {     long long g = 1;     if (n % 10 != 0) g = g * (n % 10);     n = n / 10;     while (n > 0) {       if (n % 10 != 0) g = g * (n % 10);       n = n / 10;     }     return g;   }   long long bit[1000005][11];   void update(int idx, int val) {     while (idx <= 1000000) {       bit[idx][val]++;       idx += idx & (-idx);     }   }   long long query(int idx, int val) {     long long sum = 0;     while (idx > 0) {       sum += bit[idx][val];       idx -= idx & (-idx);     }     return sum;   }   int main() {     long long int i;     ans[1] = 1;     ans[0] = 0;     for (i = 2; i <= 9; i++) {       ans[i] = i;     }     int k;     for (int i = 10; i <= 1000000; i++) {       k = i;       while (make(k) >= 10) {         k = make(k);       }       k = make(k);       ans[i] = k;     }     for (i = 1; i <= 1000000; i++) {       update(i, ans[i]);     }     int q;     cin >> q;     while (q--) {       int l, r, k;       cin >> l >> r >> k;       cout << query(r, k) - query(l - 1, k) << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, c = 0, sum = 0, cn = 0, mx = 0;     char s[101];     scanf( %s , s);     for (b = 0; b <= strlen(s); b++) {       cn++;       if (s[b] ==  A  || s[b] ==  E  || s[b] ==  I  || s[b] ==  O  ||           s[b] ==  U  || s[b] ==  Y ) {         mx = max(cn, mx);         cn = 0;       }       mx = max(mx, cn);     }     printf( %d n , mx);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1000000007;   long long powmod(long long a, long long b) {     long long res = 1;     a %= mod;     assert(b >= 0);     for (; b; b >>= 1) {       if (b & 1) res = res * a % mod;       a = a * a % mod;     }     return res;   }   int n, k, m, x, a, b;   long long t, T;   set<pair<int, pair<long long, int>>> wc;   set<pair<long long, pair<int, int>>> rc;   int main() {     scanf( %d%d%d , &n, &k, &m);     for (int i = 1; i < k + 1; i++)       scanf( %d , &x), wc.insert(make_pair(x, make_pair(0, i)));     for (int i = 0; i < m; i++) {       scanf( %lld%d%d , &t, &a, &b);       T = max(T, t);       while (!rc.empty() && rc.begin()->first <= T) {         int id = rc.begin()->second.first;         int pos = rc.begin()->second.second;         wc.insert(make_pair(pos, make_pair(rc.begin()->first, id)));         rc.erase(rc.begin());       }       if (wc.empty()) {         T = max(T, rc.begin()->first);         while (!rc.empty() && rc.begin()->first <= T) {           int id = rc.begin()->second.first;           int pos = rc.begin()->second.second;           wc.insert(make_pair(pos, make_pair(rc.begin()->first, id)));           rc.erase(rc.begin());         }       }       auto rit = wc.lower_bound(make_pair(a, make_pair(0, 0)));       pair<int, pair<long long, int>> carl, carr;       if (rit == wc.end())         carr = make_pair((1 << 30), make_pair(0, 0));       else         carr = *rit;       auto lit = wc.lower_bound(make_pair(a + 1, make_pair(0, 0)));       if (lit == wc.begin()) {         carl = make_pair(-(1 << 30), make_pair(0, 0));       } else {         --lit;         int pos = lit->first;         lit = wc.lower_bound(make_pair(pos, make_pair(0, 0)));         carl = *lit;       }       if (a - carl.first < carr.first - a ||           (a - carl.first == carr.first - a && carl.second < carr.second))         swap(carl, carr);       printf( %d %lld n , carr.second.second, T + abs(carr.first - a) - t);       wc.erase(carr);       rc.insert(make_pair(T + abs(carr.first - a) + abs(a - b),                           make_pair(carr.second.second, b)));     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 100;   const double pi = acos(-1);   inline long long read() {     long long x = 0, f = 1;     char ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (isdigit(ch)) {       x = x * 10 + ch - 48;       ch = getchar();     }     return x * f;   }   long long a[maxn], b[maxn], dp[maxn];   struct Tree {     long long l, r, maxval;   } tree[maxn * 4];   void push_up(long long p) {     tree[p].maxval = max(tree[p * 2].maxval, tree[p * 2 + 1].maxval);   }   void build(long long p, long long l, long long r) {     tree[p].maxval = 0;     tree[p].l = l;     tree[p].r = r;     if (l == r) {       return;     }     long long mid = (l + r) >> 1;     build(p * 2, l, mid);     build(p * 2 + 1, mid + 1, r);     push_up(p);   }   void modify(long long p, long long l, long long r, long long d) {     if (l <= tree[p].l && r >= tree[p].r) {       tree[p].maxval = d;       return;     }     long long mid = (tree[p].l + tree[p].r) >> 1;     if (l <= mid) modify(p * 2, l, r, d);     if (r > mid) modify(p * 2 + 1, l, r, d);     push_up(p);   }   long long query(long long p, long long l, long long r) {     if (l <= tree[p].l && r >= tree[p].r) {       return tree[p].maxval;     }     long long mid = (tree[p].l + tree[p].r) >> 1;     long long ans = 0;     if (l <= mid) ans = max(ans, query(p * 2, l, r));     if (r > mid) ans = max(ans, query(p * 2 + 1, l, r));     return ans;   }   int main(void) {     cin.tie(0);     std::ios::sync_with_stdio(false);     long long n;     cin >> n;     for (long long i = 1; i <= n; i++) {       long long r, h;       cin >> r >> h;       a[i] = r * r * h;       b[i] = a[i];     }     sort(b + 1, b + 1 + n);     build(1, 1, n);     long long ans = 0;     for (long long i = 1; i <= n; i++) {       long long tmp = lower_bound(b + 1, b + 1 + n, a[i]) - b;       dp[i] = max(dp[i], query(1, 1, tmp - 1) + a[i]);       modify(1, tmp, tmp, dp[i]);       ans = max(ans, dp[i]);     }     cout << fixed << setprecision(10) << (1.0 * ans * pi) <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long a, b, i, j, n, t, m;     cin >> t;     while (t--) {       string s;       cin >> s;       n = s.size();       vector<long long> ans;       long long count = 0;       for (i = 0; i < n; i++) {         if (s[i] ==  1 )           count++;         else {           ans.push_back(count);           count = 0;         }       }       if (count != 0) ans.push_back(count);       long long sum = 0;       sort(ans.rbegin(), ans.rend());       for (i = 0; i < ans.size(); i++) {         if (i % 2 == 0) sum += ans[i];       }       cout << sum << endl;     }   }
#include <bits/stdc++.h>   int main() {     long long n, m;     scanf( %lld %lld , &n, &m);     long long res = 1, p = 2;     while (m != 0) {       if (m % 2 != 0) res = res * p % 1000000007;       p = p * p % 1000000007;       m >>= 1;     }     res--;     p = res;     res = 1;     while (n != 0) {       if (n % 2 != 0) res = res * p % 1000000007;       p = p * p % 1000000007;       n >>= 1;     }     printf( %lld , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k, a, lev[16], loy[16], suf;   double ret;   double dp[16][(2 << 8)];   double calc(int pos, int mask) {     if (pos == n) {       int need = suf - __builtin_popcount(mask);       if (need <= 0)         return 1.0;       else {         int b = 0;         for (int i = 0; i < (n); ++i)           if (!((mask & (1LL << i)) != 0LL)) b += lev[i];         return double(a) / double(a + b);       }     }     double &ret = dp[pos][mask];     if (ret != -1) return ret;     ret = calc(pos + 1, mask) * double(100.0 - loy[pos]) / 100.0 +           calc(pos + 1, mask + (1 << pos)) * double(loy[pos]) / 100.0;     return ret;   }   int llamadas = 0;   double calcprob() {     fill(&dp[0][0], &dp[16][0], -1.0);     llamadas++;     return calc(0, 0);   }   void simu(int pos, int candy) {     if (pos == n) {       ret = max(ret, calcprob());       return;     }     int minus = 0;     simu(pos + 1, candy);     for (int i = 0; i < (candy); ++i) {       if (loy[pos] == 100) break;       minus++;       loy[pos] += 10;       simu(pos + 1, candy - i - 1);     }     loy[pos] -= minus * 10;   }   int main() {     cin >> n >> k >> a;     for (int i = 0; i < (n); ++i) cin >> lev[i] >> loy[i];     suf = n / 2 + 1;     ret = 0.0;     simu(0, k);     printf( %.10f n , ret);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long P = 998244353LL;   const int N_MAX = 1e5 + 15;   int A[N_MAX];   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) cin >> A[i];     long long ans = 0LL;     bool rem = 1;     long long q = 1LL;     while (rem) {       long long t = 0LL;       for (int i = 0; i < n; i++) {         t += (1LL * (A[i] % 10));         A[i] /= 10;         if (A[i] == 0) rem = 0;       }       t *= q;       t %= P;       q *= 100LL;       q %= P;       ans += t;       ans %= P;     }     ans *= 11LL;     ans %= P;     ans *= n;     ans %= P;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int i, j;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int k, n;     cin >> k;     long long int maxi = -1;     for (i = 0; i < k; i++) {       cin >> n;       maxi = max(maxi, n);     }     if (maxi > 25)       cout << maxi - 25;     else       cout << 0;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 5;   const long long INF = 1e9;   long long b[N];   long long ans[N];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       for (int i = 1; i <= n; ++i) cin >> b[i];       long long sum = 0;       for (int i = 1; i <= n; ++i) sum += b[i];       long long x = (long long)n * (n + 1) / 2;       if (sum % x != 0) {         cout <<  NO  <<   n ;       } else {         sum /= x;         bool cek = true;         for (int i = 1; i <= n; ++i) {           int p = (i + n - 2) % n + 1;           if ((sum - b[i] + b[p]) % n != 0) cek = false;           ans[i] = (sum - b[i] + b[p]) / n;         }         for (int i = 1; i <= n; ++i) {           if (ans[i] <= 0 || ans[i] > INF) cek = false;         }         if (cek) {           cout <<  YES  <<   n ;           for (int i = 1; i <= n; ++i) {             cout << ans[i];             if (i < n) cout <<    ;           }           cout <<   n ;         } else {           cout <<  NO  <<   n ;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 5000 + 10;   const int MOD = 998244353;   long long f[maxn];   int lim[maxn];   long long frac[maxn], ifrac[maxn];   int arr[maxn], b[maxn];   int n;   long long fpow(long long a, long long b) {     long long ret = 1;     while (b) {       if (b & 1) ret = (ret * a) % MOD;       a = (a * a) % MOD;       b >>= 1;     }     return ret;   }   void init() {     frac[0] = 1;     for (int i = 1; i < maxn; i++) frac[i] = frac[i - 1] * i % MOD;     ifrac[maxn - 1] = fpow(frac[maxn - 1], MOD - 2);     for (int i = maxn - 2; i >= 0; i--) ifrac[i] = ifrac[i + 1] * (i + 1) % MOD;     return;   }   long long A(int a, int b) {     if (a < b || b < 0) return 0;     return frac[a] * ifrac[a - b] % MOD;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     init();     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> arr[i];       b[i] = arr[i] * 2;     }     sort(arr + 1, arr + 1 + n);     sort(b + 1, b + 1 + n);     for (int i = 1; i <= n; i++) {       int dex = upper_bound(b + 1, b + 1 + n, arr[i]) - b;       --dex;       lim[i] = dex;     }     f[0] = 1;     lim[0] = -1;     for (int i = 1; i <= n; i++) {       for (int j = 0; j <= lim[i]; j++)         f[i] = (f[i] + f[j] * A(n - 2 - lim[j], lim[i] - lim[j] - 1) % MOD) % MOD;     }     if (lim[n] == n - 1)       cout << f[n] <<   n ;     else       cout << 0 <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = 1e18;   priority_queue<pair<int, int> > p;   int n;   const int maxn = 1 << 19;   int vis[maxn];   long long dp[maxn][19];   int a[maxn], pos, L, sum;   long long ans;   int main() {     scanf( %d , &n);     memset(dp, -1, sizeof(dp));     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       if (a[i] == -1) pos = i;       if (!pos) a[i] = 0;     }     a[pos] = 0;     int tmp = n;     for (L = 0; 1 << L <= n; L++)       ;     for (int j = 1; j <= L; j++) {       long long Mi = inf;       if (j == 1) Mi = 0;       for (int i = n; i > n - j + 1; i--)         if (dp[i][j - 1] != -1) Mi = min(Mi, dp[i][j - 1]);       for (int i = n - j + 1; i >= n - sum; i--) {         dp[i][j] = Mi + a[i];         if (dp[i][j - 1] != -1) Mi = min(Mi, dp[i][j - 1]);       }       sum += tmp / 2;       tmp /= 2;     }     long long ans = inf;     for (int i = 1; i <= n; i++)       if (dp[i][L] != -1) ans = min(ans, dp[i][L]);     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int sx, sy, dx, dy, n, dis[100004];   map<pair<int, int>, int> mp;   int main() {     cin >> sx >> sy >> dx >> dy;     cin >> n;     int i, j, cnt = 1;     for (i = 0; i < n; i++) {       int r, c1, c2;       cin >> r >> c1 >> c2;       for (j = c1; j <= c2; j++) {         mp[{r, j}] = cnt;         dis[cnt] = 1000000000;         cnt++;       }     }     mp[{dx, dy}] = cnt;     dis[cnt] = 1000000000;     queue<pair<int, int> > q;     q.push({sx, sy});     dis[mp[{sx, sy}]] = 0;     while (!q.empty()) {       int x = q.front().first;       int y = q.front().second;       q.pop();       if (mp.find({x + 1, y}) != mp.end() &&           dis[mp[{x + 1, y}]] > dis[mp[{x, y}]] + 1) {         dis[mp[{x + 1, y}]] = dis[mp[{x, y}]] + 1;         q.push({x + 1, y});       }       if (mp.find({x - 1, y}) != mp.end() &&           dis[mp[{x - 1, y}]] > dis[mp[{x, y}]] + 1) {         dis[mp[{x - 1, y}]] = dis[mp[{x, y}]] + 1;         q.push({x - 1, y});       }       if (mp.find({x, y + 1}) != mp.end() &&           dis[mp[{x, y + 1}]] > dis[mp[{x, y}]] + 1) {         dis[mp[{x, y + 1}]] = dis[mp[{x, y}]] + 1;         q.push({x, y + 1});       }       if (mp.find({x, y - 1}) != mp.end() &&           dis[mp[{x, y - 1}]] > dis[mp[{x, y}]] + 1) {         dis[mp[{x, y - 1}]] = dis[mp[{x, y}]] + 1;         q.push({x, y - 1});       }       if (mp.find({x + 1, y + 1}) != mp.end() &&           dis[mp[{x + 1, y + 1}]] > dis[mp[{x, y}]] + 1) {         dis[mp[{x + 1, y + 1}]] = dis[mp[{x, y}]] + 1;         q.push({x + 1, y + 1});       }       if (mp.find({x - 1, y - 1}) != mp.end() &&           dis[mp[{x - 1, y - 1}]] > dis[mp[{x, y}]] + 1) {         dis[mp[{x - 1, y - 1}]] = dis[mp[{x, y}]] + 1;         q.push({x - 1, y - 1});       }       if (mp.find({x + 1, y - 1}) != mp.end() &&           dis[mp[{x + 1, y - 1}]] > dis[mp[{x, y}]] + 1) {         dis[mp[{x + 1, y - 1}]] = dis[mp[{x, y}]] + 1;         q.push({x + 1, y - 1});       }       if (mp.find({x - 1, y + 1}) != mp.end() &&           dis[mp[{x - 1, y + 1}]] > dis[mp[{x, y}]] + 1) {         dis[mp[{x - 1, y + 1}]] = dis[mp[{x, y}]] + 1;         q.push({x - 1, y + 1});       }     }     if (dis[mp[{dx, dy}]] == 1000000000) {       cout << -1 <<   n ;     } else {       cout << dis[mp[{dx, dy}]] <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 998244353;   int qmul(int a, int b) {     a = (a % mod + mod) % mod;     b = (b % mod + mod) % mod;     int ans = 0;     while (b) {       if (b & 1) ans = (ans + a) % mod;       a = (a << 1) % mod;       b >>= 1;     }     return ans;   }   int qpow(int a, int p) {     int ans = 1;     while (p) {       if (p & 1) ans = qmul(ans, a);       a = qmul(a, a);       p >>= 1;     }     return ans;   }   int gcd(int a, int b) {     if (b == 0) return a;     return gcd(b, a % b);   }   int main() {     int n, a, p = 0, q = 1;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a;       p = qmul((p + q) % mod, 100);       q = qmul(q, a);       int r = gcd(p, q);       p = p / r;       q = q / r;     }     cout << qmul(p, qpow(q, mod - 2)) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 111;   const long double Eps = 1e-6;   int sgn(long double a, long double b = 0) {     a -= b;     return (a > Eps) - (a < -Eps);   }   const long double Pi = 4 * atan(1);   struct Point {     long double x, y;     Point operator-(Point p) { return {x - p.x, y - p.y}; }     Point operator+(Point p) { return {x + p.x, y + p.y}; }     Point operator/(long double d) { return {x / d, y / d}; }     bool operator<(Point p) const {       if (sgn(x, p.x) == 0) return sgn(y, p.y) < 0;       return sgn(x, p.x) < 0;     }     Point rot(long double d) {       long double rx = x * cos(d) - y * sin(d);       long double ry = x * sin(d) + y * cos(d);       return {rx, ry};     }     long double len2() { return x * x + y * y; }     long double len() { return sqrt(len2()); }     long double dot(Point p) { return x * p.x + y * p.y; }     long double cross(Point p) { return x * p.y - y * p.x; }   } p[N];   long double xmul(Point a, Point b, Point c) { return (b - a).cross(c - a); }   Point inter(Point p1, Point p2, Point q1, Point q2) {     long double u = xmul(p1, p2, q1);     long double v = xmul(p2, p1, q2);     long double rx = (q1.x * v + q2.x * u) / (v + u);     long double ry = (q1.y * v + q2.y * u) / (v + u);     return {rx, ry};   }   class Cmp {    public:     bool operator()(long double a, long double b) const { return sgn(a, b) < 0; }   };   int main() {     ios ::sync_with_stdio(false);     int n;     cin >> n;     set<Point> st;     for (int i = 0; i < n; i++) {       cin >> p[i].x >> p[i].y;       st.insert(p[i]);     }     bool found = false;     long double ans = 0;     for (int i = 0; i < n; i++)       for (int j = i + 1; j < n; j++)         for (int k = j + 1; k < n; k++) {           if (sgn((p[j] - p[i]).dot(p[k] - p[i])) > 0 &&               sgn((p[k] - p[j]).dot(p[i] - p[j])) > 0 &&               sgn((p[i] - p[k]).dot(p[j] - p[k])) > 0) {             Point mij = (p[i] + p[j]) / 2;             Point dij = (p[i] - p[j]).rot(Pi / 2);             Point mjk = (p[j] + p[k]) / 2;             Point djk = (p[j] - p[k]).rot(Pi / 2);             Point o = inter(mij, mij + dij, mjk, mjk + djk);             bool flag = true;             for (int r = 0; r < n; r++)               if (sgn((p[r] - o).len2(), (p[i] - o).len2()) < 0) flag = false;             if (flag) {               found = true;               ans = max(ans, (p[i] - o).len());             }           }         }     for (int i = 0; i < n; i++)       for (int j = i + 1; j < n; j++) {         Point mij = (p[i] + p[j]) / 2;         Point dij = (p[j] - p[i]) / 2;         Point pk = mij + dij.rot(Pi / 2);         Point ps = mij - dij.rot(Pi / 2);         if (st.find(pk) != st.end() && st.find(ps) != st.end()) {           Point &o = mij;           bool flag = true;           for (int s = 0; s < n; s++)             if (sgn((p[s] - o).len2(), (p[i] - o).len2()) < 0) flag = false;           if (flag) {             found = true;             ans = max(ans, (p[i] - o).len());           }         }       }     if (!found)       cout << -1 <<   n ;     else       cout << setprecision(6) << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void mf() { freopen( input.in ,  r , stdin); }   int a[1007];   int n, k;   map<int, int> mm;   queue<int> q;   bool f(map<int, int>& _mm, int x) { return _mm.find(x) != _mm.end(); }   void solve() {     int m;     n = 0;     cin >> k >> m;     int x;     for (int i = 1; i <= m; i++) {       cin >> x;       x -= k;       if (!f(mm, x)) {         mm[x] = 1;         n++;         a[n] = x;         q.push(x);       }     }     while (!f(mm, 0) && !q.empty()) {       x = q.front();       q.pop();       for (int i = 1; i <= n; i++) {         int nx = x + a[i];         if (nx > 1000 || nx < -1000) continue;         if (!f(mm, nx)) {           mm[nx] = mm[x] + 1;           q.push(nx);         }       }     }     if (f(mm, 0)) {       cout << mm[0];     } else {       cout << -1;     }   }   int main() {     ios_base::sync_with_stdio(false);     solve();     return 0;   }