malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int a[505];   pair<int, int> query(set<int> s) {     cout <<  ?  ;     for (auto e : s) {       cout << e <<    ;     }     cout << endl;     pair<int, int> res;     cin >> res.first >> res.second;     a[res.first] = res.second;     return res;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n, k;     cin >> n >> k;     set<int> s;     for (int i = 1; i <= k; i++) {       s.insert(i);     }     int mn = 1e9 + 1;     for (int i = k + 1; i <= n; i++) {       pair<int, int> u = query(s);       mn = min(mn, u.second);       s.erase(u.first);       s.insert(i);     }     pair<int, int> u = query(s);     mn = min(mn, u.second);     s.erase(u.first);     int ans = 1;     set<int> t;     int sm = 1e9 + 1, bg = 0;     for (int i = 1; i <= n; i++) {       if (a[i] != 0) {         t.insert(i);         sm = min(sm, a[i]);         bg = max(bg, a[i]);       }       if (t.size() == 2) break;     }     set<int> ss;     for (auto e : s) ss.insert(e);     for (auto e : t) ss.insert(e);     for (auto e : s) {       ss.erase(e);       auto u = query(ss);       if (u.second == bg) ans++;       ss.insert(e);     }     cout <<  !   << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   int main() {     string s;     cin >> s;     string a =   ;     for (int i = 0; i < s.size(); i++) {       if (s[i] ==  a  || s[i] ==  b ) a += s[i];     }     int ans = 1, cnt = 0;     for (int i = 0; i < a.size(); i++) {       if (a[i] ==  b ) {         ans = (ans * 1ll * (cnt + 1)) % MOD;         cnt = 0;       } else {         cnt++;       }     }     ans = (ans * 1ll * (cnt + 1)) % MOD;     printf( %d n , ans - 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   unsigned long long ans = 0;   int r = -1;   int n, g[40][21], p[40][21];   char ch;   void update(unsigned long long &a, int &b, int &c, unsigned long long d,               int e) {     if (b == 0 || a < d) {       a = d;       c = e;       b = 1;     }   }   unsigned long long f[40][21], bas[21], a[1010];   int main() {     bas[1] = 1;     for (int i = 2; i <= 19; i++) bas[i] = bas[i - 1] * 10LL;     scanf( %d , &n);     for (int i = 1; i <= n + n; i++) {       scanf(  %c , &ch);       a[i] = ch -  0 ;     }     g[0][0] = 1;     f[0][0] = 0;     for (int i = 1; i <= n + n; i++)       for (int j = 0; j <= n; j++)         if (g[i - 1][j]) {           int d1 = j, d2 = i - 1 - j;           d1 = n - d1, d2 = n - d2;           if (d2 > 0)             update(f[i][j], g[i][j], p[i][j], f[i - 1][j] + bas[d2] * a[i], j);           if (j != n)             update(f[i][j + 1], g[i][j + 1], p[i][j + 1],                    f[i - 1][j] + bas[d1] * a[i], j);         }     int sx = n + n, sy = n;     string a =   ;     while (sx != 0) {       int ty = p[sx][sy];       sx--;       if (ty == sy)         a +=  M ;       else         a +=  H ;       sy = ty;     }     reverse(a.begin(), a.end());     cout << a << endl;   }
#include <bits/stdc++.h>   using namespace std;   struct pony {     long long s, m, r, t;   } ponys[100005];   bool cmp(pony &x, pony &y) { return x.t < y.t; }   struct node {     long long l, r, latest;     long long *sm, *sr, *t;   } nodes[100005 << 4];   void build(long long ord, long long l, long long r) {     nodes[ord].latest = 0;     nodes[ord].l = l, nodes[ord].r = r;     if (l == r) {       nodes[ord].sm = &ponys[l].m;       nodes[ord].sr = &ponys[l].r;       nodes[ord].t = &ponys[l].t;       return;     }     int m = (l + r) >> 1;     build(ord << 1, l, m);     build(ord << 1 | 1, m + 1, r);     pony *tmp = new pony[r - l + 1];     for (int i = 0; i < r - l + 1; i++) tmp[i] = ponys[l + i];     sort(tmp, tmp + r - l + 1, cmp);     nodes[ord].sm = new long long[r - l + 2];     nodes[ord].sr = new long long[r - l + 2];     nodes[ord].t = new long long[r - l + 2];     nodes[ord].sm[0] = nodes[ord].sr[0] = nodes[ord].t[0] = 0;     for (int i = 1; i < r - l + 2; i++) {       nodes[ord].sm[i] = tmp[i - 1].m + nodes[ord].sm[i - 1];       nodes[ord].sr[i] = tmp[i - 1].r + nodes[ord].sr[i - 1];       nodes[ord].t[i] = tmp[i - 1].t;     }     delete[] tmp;   }   long long mana_obserbed(long long ord, long long t, long long l, long long r) {     long long res = 0;     if (nodes[ord].latest > 0)       nodes[ord << 1].latest = nodes[ord << 1 | 1].latest = nodes[ord].latest;     if (nodes[ord].l == l && nodes[ord].r == r) {       if (nodes[ord].latest > 0) {         if (l == r)           res = min(ponys[l].m, ponys[l].r * (t - nodes[ord].latest));         else {           int len = nodes[ord].r - nodes[ord].l + 2;           int tmp = upper_bound(nodes[ord].t + 1, nodes[ord].t + len,                                 t - nodes[ord].latest) -                     nodes[ord].t;           res = nodes[ord].sm[tmp - 1] +                 (nodes[ord].sr[len - 1] - nodes[ord].sr[tmp - 1]) *                     (t - nodes[ord].latest);         }         nodes[ord].latest = t;         return res;       } else if (nodes[ord].latest == 0 && l == r) {         res = min(ponys[l].m, ponys[l].s + ponys[l].r * t);         nodes[ord].latest = t;         return res;       }     }     int m = (nodes[ord].l + nodes[ord].r) >> 1;     if (r <= m)       res += mana_obserbed(ord << 1, t, l, r);     else if (m < l)       res += mana_obserbed(ord << 1 | 1, t, l, r);     else       res += mana_obserbed(ord << 1, t, l, m) +              mana_obserbed(ord << 1 | 1, t, m + 1, r);     nodes[ord].latest = nodes[ord << 1].latest == nodes[ord << 1 | 1].latest                             ? nodes[ord << 1].latest                             : -1;     return res;   }   int main() {     long long n, m, t, l, r;     cin >> n;     for (long long i = 1; i <= n; i++) {       cin >> ponys[i].s >> ponys[i].m >> ponys[i].r;       if (ponys[i].r)         ponys[i].t = (ponys[i].m + ponys[i].r - 1) / ponys[i].r;       else         ponys[i].t = 0x7fffffffffffffff;     }     build(1, 1, n);     cin >> m;     for (long long i = 1; i <= m; i++) {       cin >> t >> l >> r;       cout << mana_obserbed(1, t, l, r) << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   typedef int* Pint;   typedef long long* PLL;   const int MAXN = 1E4;   int a[110], f[110][3]{};   int n;   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , a + i);     for (int i = 1; i <= n; i++) {       f[i][0] = min(min(f[i - 1][0], f[i - 1][1]), f[i - 1][2]) + 1;       f[i][1] = f[i][2] = MAXN;       if (a[i] & 1) f[i][1] = min(f[i - 1][0], f[i - 1][2]);       if (a[i] & 2) f[i][2] = min(f[i - 1][0], f[i - 1][1]);     }     printf( %d n , min(min(f[n][0], f[n][1]), f[n][2]));   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:102400000,102400000 )   using std::bitset;   using namespace std;   struct point {     long long x, y;     bool operator<(const point &I) const {       return x < I.x || (x == I.x && y < I.y);     }   } a[101000];   long long n;   long long hmi[101000], tmi[101000], hma[101000], tma[101000];   long long judge(double r) {     long long i, j, tem;     long long mmi, mma;     j = 1;     for (i = 1; i <= n; i++) {       while (j <= n && a[j].x - a[i].x <= 2 * r) j++;       mmi = min(hmi[i - 1], tmi[j]);       mma = max(hma[i - 1], tma[j]);       if (mma - mmi <= 2 * r) return 1;     }     return 0;   }   int main() {     long long i, j, tem;     long long tx, ty;     while (scanf( %I64d , &n) != EOF) {       for (i = 1; i <= n; i++) {         scanf( %I64d%I64d , &tx, &ty);         a[i].x = tx - ty;         a[i].y = tx + ty;       }       sort(a + 1, a + 1 + n);       hmi[0] = 0x3f3f3f3f3f3f3f3fll;       hma[0] = -0x3f3f3f3f3f3f3f3fll;       for (i = 1; i <= n; i++) {         hmi[i] = min(hmi[i - 1], a[i].y);         hma[i] = max(hma[i - 1], a[i].y);       }       tmi[n + 1] = 0x3f3f3f3f3f3f3f3fll;       tma[n + 1] = -0x3f3f3f3f3f3f3f3fll;       for (i = n; i > 0; i--) {         tmi[i] = min(tmi[i + 1], a[i].y);         tma[i] = max(tma[i + 1], a[i].y);       }       double low, high, mid, ans = 0;       low = 0;       high = 1e20;       while (high - low > 1e-6) {         mid = (low + high) / 2;         if (judge(mid))           high = mid;         else           low = mid;       }       printf( %.6lf n , (low + high) / 2);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double pi = 3.1415926535897932384626433832795;   const int inf = 1e9;   const long long inf2 = 1e18;   const int mod = 1e9 + 7;   void boost() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);   }   inline long long exp(long long x, long long n, long long m = mod) {     long long r = 1;     while (n) {       if (n & 1) r = r * x % m;       x = x * x % m, n >>= 1;     }     return r;   }   void solve() {     int n, k;     cin >> n >> k;     vector<int> ncr(n + 1, 0);     vector<int> arr(n + 1);     for (int i = 1; i < n + 1; ++i) cin >> arr[i];     ncr[0] = 1;     for (int i = 1; i < n + 1; ++i) {       ncr[i] = (ncr[i - 1] * 1LL * (k + i - 1)) % mod;       ncr[i] = (ncr[i] * exp(i, mod - 2)) % mod;     }     vector<int> ans(n + 1, 0);     for (int i = 1; i < n + 1; ++i) {       for (int j = i; j < n + 1; ++j) {         ans[j] = (ans[j] * 1LL + 1LL * arr[i] * ncr[j - i]) % mod;       }     }     for (int i = 1; i < n + 1; ++i) cout << ans[i] <<    ;     return;   }   int main() {     boost();     int tc = 1;     while (tc--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a1[3], a2[3], i;     cin >> a1[0] >> a1[1] >> a1[2];     cin >> a2[0] >> a2[1] >> a2[2];     for (i = 0; i < 3; i++) {       if (a1[i] == a2[i]) {         cout <<  YES ;         return 0;       }     }     cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s;   int n, k, cal;   string solve() {     for (int i = 0; i < s.size(); i++) {       int m4x = min(s[i] + k, (int) z );       int m1n = max(s[i] - k, (int) a );       if (s[i] - m1n >= m4x - s[i]) {         k -= s[i] - m1n;         s[i] = m1n;       } else {         k -= m4x - s[i];         s[i] = m4x;       }     }     if (k == 0) return s;     return  -1 ;   }   int main() {     cin >> n >> k >> s;     cout << solve();   }
#include <bits/stdc++.h>   using namespace std;   long long i, j, x, y, curr, T, t, K, N, coun[51], fact[21], rev[51];   vector<int> ans, v;   set<int> cand;   set<int>::iterator it;   void precomp() {     fact[0] = 1;     for (i = 1; i < 21; i++) {       fact[i] = fact[i - 1] * i;     }     coun[0] = coun[1] = 1;     for (i = 2; i < 23; i++) {       coun[i] = fact[i - 2] + coun[i - 1];       for (j = 2; j < i; j++) {         coun[i] += (fact[j - 2] * coun[i - j]);       }     }     for (i = 23; i < 51; i++) coun[i] = coun[22];   }   void fillv(long long n, long long k) {     v.clear();     if (n < 3) {       for (i = n; i > 0; i--) v.push_back(i);       return;     }     cand.clear();     for (i = 1; i < n; i++) {       cand.insert((int)i);       rev[i] = 0;     }     v.push_back(n);     rev[n] = 1;     for (i = 1; i < (n - 1); i++) {       for (j = i + 1; rev[j] > 0; j = rev[j])         ;       x = cand.size();       for (it = cand.begin(), y = 0; y < (k / fact[x - 2]); y++, ++it) {         if (j == (*it)) ++it;       }       if (j == (*it)) ++it;       v.push_back(*it);       rev[*it] = v.size();       cand.erase(it);       k = k % fact[x - 2];     }     v.push_back(*cand.begin());   }   void fill(long long n, long long k) {     int i;     if (n == 0) return;     if (coun[n - 1] > k) {       ans.push_back(ans.size() + 1);       fill(n - 1, k);       return;     }     k -= coun[n - 1];     for (i = 2; i < n; i++) {       j = fact[i - 2] * coun[n - i];       if (j <= k) {         k -= j;         continue;       }       break;     }     fillv(i, k / coun[n - i]);     k = k % (coun[n - i]);     n -= i;     int x = ans.size();     for (j = 0; j < i; j++) {       ans.push_back(x + v[j]);     }     fill(n, k);   }   int main() {     precomp();     cin >> T;     for (t = 0; t < T; t++) {       cin >> N >> K;       if (K > coun[N]) {         cout <<  -1 n ;         continue;       }       ans.clear();       fill(N, K - 1);       for (i = 0; i < N; i++) {         cout << ans[i] <<    ;       }       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     deque<int> dq;     int n;     cin >> n;     int f = 0, a = 0, b = 0;     for (int i = 0; i < n; ++i) {       int x;       cin >> x;       dq.push_back(x);     }     while (!dq.empty()) {       int ans = max(dq.front(), dq.back());       if (f == 0) {         a += ans;         f = 1;         if (ans == dq.front())           dq.pop_front();         else           dq.pop_back();       } else {         b += ans;         f = 0;         if (ans == dq.front())           dq.pop_front();         else           dq.pop_back();       }     }     cout << a <<     << b;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100001;   int q, n;   int d[MAXN], p[MAXN];   int main() {     cin >> q;     int small = 1 << 30;     for (int i = 0; i < q; ++i) {       cin >> d[i];       small = ((small) > (d[i]) ? (d[i]) : (small));     }     cin >> n;     for (int i = 0; i < n; ++i) {       cin >> p[i];     }     sort(p, p + n, greater<int>());     int cost = 0;     for (int i = 0; i < n; i++) {       if (i % (small + 2) < small) {         cost += p[i];       }     }     cout << cost << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /stack:200000000 )   #pragma GCC optimize( Ofast )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native )   using namespace std;   void file() {}   void fast() {     std::ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);   }   int main() {     int x;     cin >> x;     int a[1003][3];     int ans = 0;     for (int i = 0; i < (int)x; i++)       for (int t = 0; t < (int)3; t++) {         cin >> a[i][t];         if (t) a[i][t] += a[i][t - 1];         if (t == 2) ans += a[i][t] >= 2;       }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   map<int, int> mp;   int a[300000];   int n, k;   int b[300000];   int cnt = 0;   int cmp(int a, int b) { return mp[a] > mp[b]; }   bool check(int mid) {     int sum = 0;     for (int i = 1; i <= cnt; i++) {       sum += mp[b[i]] / mid;     }     return sum >= k;   }   int main() {     cin >> n >> k;     for (int i = 1; i <= n; i++) cin >> a[i];     sort(a + 1, a + 1 + n);     for (int i = 1; i <= n; i++) {       if (!mp[a[i]]) b[++cnt] = a[i];       mp[a[i]]++;     }     int l = 1;     int r = 250000;     int ans;     while (l <= r) {       int mid = l + r >> 1;       if (check(mid))         ans = mid, l = mid + 1;       else         r = mid - 1;     }     int nd = k;     int now = 1;     sort(b + 1, b + 1 + cnt);     while (nd) {       while (nd && mp[b[now]] >= ans)         cout << b[now] <<    , mp[b[now]] -= ans, nd--;       now++;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     int t;     cin >> t;     for (int i = 0; i < t; i++) {       int x, y, a, b;       cin >> x >> y >> a >> b;       if ((y - x) % (a + b) == 0) {         cout << (y - x) / (a + b) <<   n ;       } else {         cout << -1 <<   n ;       }     }   }
#include <bits/stdc++.h>   long long a[100000], b[100000];   using namespace std;   bool isnp(long long n, long long k, long long t) {     long long magic = 0;     for (long long i = 0; i < t; i++) {       if (a[i] * n > b[i]) magic += a[i] * n - b[i];       if (magic > k) return false;     }     return true;   }   int32_t main() {     long long n, k;     cin >> n >> k;     for (long long i = 0; i < n; i++) {       cin >> a[i];     }     for (long long i = 0; i < n; i++) {       cin >> b[i];     }     long long l = 0, r = 2000000001;     while (r - l != 1) {       if (isnp((r + l) / 2, k, n))         l = (r + l) / 2;       else         r = (r + l) / 2;     }     cout << l;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5, K = 505, INF = K * (1e4 + 5);   int n, m, k;   int c[N], a[N], visit[N];   int w[K][K];   vector<pair<int, int>> edges[N];   vector<int> colors;   void dfs(int s) {     visit[s] = 1;     colors.push_back(a[s]);     for (auto x : edges[s]) {       int nxt = x.first;       int w = x.second;       if (visit[nxt] || w) continue;       dfs(nxt);     }   }   vector<vector<int>> ffloyd(int M) {     vector<vector<int>> dist(M, vector<int>(M, INF));     for (int i = 0; i < M; i++)       for (int j = 0; j < M; j++) dist[i][j] = w[i][j];     for (int k = 0; k < M; k++) {       for (int i = 0; i < M; i++) {         for (int j = 0; j < M; j++) {           if (dist[i][k] < INF && dist[k][j] < INF)             dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);         }       }     }     return dist;   }   void solve() {     cin >> n >> m >> k;     for (int i = 0; i < k; i++) cin >> c[i];     int col = 0;     for (int i = 0, id = 0; i < k; i++) {       for (int j = 0; j < c[i]; j++) a[id++] = col;       col++;     }     for (int i = 0; i < k; i++)       for (int j = 0; j < k; j++)         if (i != j) w[i][j] = INF;     while (m--) {       int u, v, x;       cin >> u >> v >> x;       u--;       v--;       edges[u].push_back({v, x});       edges[v].push_back({u, x});       u = a[u], v = a[v];       if (u == v) continue;       w[u][v] = min(w[u][v], x);       w[v][u] = min(w[v][u], x);     }     int fail = 0;     for (int i = 0; i < n; i++) {       if (!visit[i]) {         dfs(i);         sort(colors.begin(), colors.end());         int count = 1;         for (int i = 1; i < colors.size(); i++) {           if (colors[i] == colors[i - 1]) {             count++;             continue;           }           if (c[colors[i - 1]] != count) {             fail = 1;             break;           }           count = 1;         }         if (c[colors.back()] != count) {           fail = 1;           break;         }         colors.clear();       }     }     if (fail) {       cout <<  No n ;       return;     }     cout <<  Yes n ;     vector<vector<int>> dist = ffloyd(k);     for (int i = 0; i < k; i++) {       for (int j = 0; j < k; j++) {         if (dist[i][j] == INF) dist[i][j] = -1;         cout << dist[i][j] <<    ;       }       cout <<   n ;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     solve();   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   char a[222][222];   struct Dinic {     struct edge {       int to, flow, cap;     };     const static int N = 202 * 202;     vector<edge> e;     vector<int> g[N + 7];     int dp[N + 7];     int ptr[N + 7];     void clear() {       for (int i = 0; i < N + 7; i++) g[i].clear();       e.clear();     }     void addEdge(int a, int b, int cap = 1) {       g[a].push_back(e.size());       e.push_back({b, 0, cap});       g[b].push_back(e.size());       e.push_back({a, 0, 0});     }     int minFlow, start, finish;     bool bfs() {       for (int i = 0; i < N; i++) dp[i] = -1;       dp[start] = 0;       vector<int> st;       int uk = 0;       st.push_back(start);       while (uk < st.size()) {         int v = st[uk++];         for (int to : g[v]) {           auto ed = e[to];           if (ed.cap - ed.flow >= minFlow && dp[ed.to] == -1) {             dp[ed.to] = dp[v] + 1;             st.push_back(ed.to);           }         }       }       return dp[finish] != -1;     }     int dfs(int v, int flow) {       if (v == finish) return flow;       for (; ptr[v] < g[v].size(); ptr[v]++) {         int to = g[v][ptr[v]];         edge ed = e[to];         if (ed.cap - ed.flow >= minFlow && dp[ed.to] == dp[v] + 1) {           int add = dfs(ed.to, min(flow, ed.cap - ed.flow));           if (add) {             e[to].flow += add;             e[to ^ 1].flow -= add;             return add;           }         }       }       return 0;     }     int dinic(int start, int finish) {       Dinic::start = start;       Dinic::finish = finish;       int flow = 0;       for (minFlow = 1; minFlow; minFlow >>= 1) {         while (bfs()) {           for (int i = 0; i < N; i++) ptr[i] = 0;           while (int now = dfs(start, (int)2e9 + 7)) flow += now;         }       }       return flow;     }   } dinic;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n >> m;     for (int i = 0; i < n; ++i)       for (int j = 0; j < m; ++j) cin >> a[i][j];     int s = n * m;     int t = n * m + 1;     auto get_node = [](int first, int second) { return first * m + second; };     for (int i = 0; i < n; ++i) {       for (int j = 0; j < m; ++j)         if (a[i][j] ==  # ) {           if (i > 0 && a[i - 1][j] ==  # )             dinic.addEdge(get_node(i, j), get_node(i - 1, j));           if (j + 1 < m && a[i][j + 1] ==  # )             dinic.addEdge(get_node(i, j), get_node(i, j + 1));           if (j == 0 || a[i][j - 1] ==  . ) dinic.addEdge(s, get_node(i, j));           if (i == 0 || a[i - 1][j] ==  . ) dinic.addEdge(get_node(i, j), t);         }     }     cout << dinic.dinic(s, t);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     std::ios::sync_with_stdio(false);     cin >> n >> m;     int x, y;     for (int i = 0; i < m; i++) cin >> x >> y;     for (int i = 0; i < n; i++)       if (i % 2 == 0)         cout << 0;       else         cout << 1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     cin >> n >> k;     int a[n];     for (int i = 0; i < n; i++) {       cin >> a[i];     }     int ans = 0;     for (int i = 0; i < k; i++) {       int m = 0;       for (int j = i; j < n; j += k) {         if (a[j] == 1) {           m++;         }       }       ans += min(m, (n / k - m));     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   struct abc {     long long int y, x;   };   bool compare(abc a1, abc a2) {     if (a1.x == a2.x) return a1.y < a2.y;     return a1.x < a2.x;   }   long long int countDivisors(long long int n) {     long long int cnt = 0;     for (long long int i = 1; i <= sqrt(n); i++) {       if (n % i == 0) {         if (n / i == i)           cnt++;         else           cnt = cnt + 2;       }     }     return cnt;   }   const long long int mod = 1e9 + 7;   long long int n, m, x, y, l, r, ans, k, q, w, h;   string second, p;   map<long long int, long long int> mp;   void solve() {     cin >> n >> k;     long long int a[n], sum = 0;     vector<long long int> v;     for (long long int i = 0; i < n; i++) {       cin >> a[i];       ans += a[i] / 10;       long long int x = a[i] % 10;       if (x % 10 != 0)         x = 10 - x;       else         x = 0;       if (x) v.push_back(x);       a[i] += x;       sum += (100 - a[i]);     }     sort(v.begin(), v.end());     for (long long int i = 0; i < v.size(); i++) {       if (k >= v[i])         ans++, k -= v[i];       else {         k = 0;         break;       }     }     ans += min(sum, k) / 10;     cout << ans;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     solve();   }
#include <bits/stdc++.h>   using namespace std;   vector<int> v;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     long long n;     cin >> n;     int flag = 0;     int m;     cin >> m;     long long a[m];     for (int i = 0; i < m; i++) {       cin >> a[i];     }     sort(a, a + m);     for (int i = 1; i < m - 1; i++) {       if ((a[i] - a[i - 1] == 1) && (a[i + 1] - a[i] == 1)) {         flag = 1;         break;       }     }     if (flag == 1 || a[m - 1] == n || a[0] == 1)       cout <<  NO             <<   n ;     else       cout <<  YES             <<   n ;     return 0;   }