malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   map<long long int, vector<pair<long long int, long long int> > > mapp;   bool cmp(pair<long long int, long long int> &p1,            pair<long long int, long long int> &p2) {     if (p1.second != p2.second) return p1.second < p2.second;     return p1.first < p2.first;   }   int main() {     long long int n, i, j, k;     cin >> n;     vector<long long int> a(n);     for (i = 0; i < n; i++) cin >> a[i];     for (i = 0; i < n; i++) {       long long int s = 0;       for (j = i; j < n; j++) s += a[j], mapp[s].push_back({i, j});     }     long long int ans = 0, f = 0;     for (auto j : mapp) {       sort(mapp[j.first].begin(), mapp[j.first].end(), cmp);       long long int bound = -1, cnt = 0;       for (auto k : mapp[j.first]) {         if (k.first > bound) cnt++, bound = k.second;       }       if (ans < cnt) ans = cnt, f = j.first;     }     cout << ans <<   n ;     long long int bound = -1, cnt = 0;     for (auto j : mapp[f]) {       if (j.first > bound)         cout << j.first + 1 <<     << j.second + 1 <<   n , bound = j.second;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, h, k, i, j, a[100100], pkp = 0, tmp, p, ans = 0;     double d;     scanf( %lld %lld %lld , &n, &h, &k);     for (i = 0; i < n; i++) scanf( %lld , &a[i]);     for (i = 0; i < n; i++) {       if (pkp + a[i] <= h) {         pkp += a[i];       } else {         tmp = h - a[i];         p = pkp - tmp;         d = ceil((double)p / (double)k);         ans += (long long)d;         pkp -= d * k;         if (pkp < 0) pkp = 0;         pkp += a[i];       }     }     d = ceil((double)pkp / (double)k);     ans += (long long)d;     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int n, k, num, count = 0, i, j;     cin >> n >> k;     bitset<32> b[6];     for (i = 1; i < 3; i++) {       for (j = i + 1; j <= 3; j++) {         cout <<  or   << i <<     << j <<   n  << flush;         cin >> num;         b[count] = num;         count++;         cout <<  and   << i <<     << j <<   n  << flush;         cin >> num;         b[count] = num;         count++;       }     }     bitset<32> b1, b2;     for (i = 0; i < 32; i++) {       if (b[0][i] == b[1][i]) {         b1[i] = b[0][i];         b2[i] = b[0][i];       } else {         if (b[2][i] != b[4][i]) {           b1[i] = b[2][i];           b2[i] = b[4][i];         } else {           b1[i] = b[3][i];           b2[i] = b[5][i];         }       }     }     bitset<32> r, ans;     r = b1;     vector<int> vec;     vec.push_back(b1.to_ulong());     vec.push_back(b2.to_ulong());     b1 = b[2];     b2 = b[3];     for (i = 3; i <= n; i++) {       if (i > 3) {         cout <<  or   << 1 <<     << i <<   n  << flush;         cin >> num;         b1 = num;         cout <<  and   << 1 <<     << i <<   n  << flush;         cin >> num;         b2 = num;       }       for (j = 0; j < 32; j++) {         if (r[j] == 0 && b1[j] == 0)           ans[j] = 0;         else if (r[j] == 0 && b1[j] == 1)           ans[j] = 1;       }       for (j = 0; j < 32; j++) {         if (r[j] == 1 && b2[j] == 0)           ans[j] = 0;         else if (r[j] == 1 && b2[j] == 1)           ans[j] = 1;       }       vec.push_back(ans.to_ulong());     }     sort(vec.begin(), vec.end());     cout <<  finish   << vec[k - 1] <<   n  << flush;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxk = 999 + 5;   int a[maxk];   vector<int> vec;   int main() {     int n, k, p, x, y;     scanf( %d%d%d%d%d , &n, &k, &p, &x, &y);     for (int i = 0; i < k; i++) scanf( %d , a + i);     if (y > p) {       printf( -1 n );       return 0;     }     sort(a, a + k);     for (int one = 0, now = 0; one <= n - k; one++) {       now = 0;       vec.clear();       for (int i = 0; i < one; i++) {         now++;         vec.push_back(1);       }       for (int i = 0; i < k; i++) {         now += a[i];         vec.push_back(a[i]);       }       for (; vec.size() < n;) {         vec.push_back(y);         now += y;       }       if (now > x) continue;       sort(vec.begin(), vec.end());       if (vec[(n + 1) / 2 - 1] >= y) {         vector<int> ans;         for (int i = 0; i < one; i++) ans.push_back(1);         for (int i = 0; i < n - (one + k); i++) ans.push_back(y);         for (int i = 0; i < ans.size(); i++)           printf( %d%c , ans[i], i == ans.size() - 1 ?   n  :    );         return 0;       }     }     printf( -1 n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct point {     point() : x(0), y(0){};     point(long long x, long long y) : x(x), y(y){};     long long x;     long long y;   };   point operator+(point a, point b) { return point(a.x + b.x, a.y + b.y); }   point operator-(point a, point b) { return point(a.x - b.x, a.y - b.y); }   long long dotProduct(point a, point b) { return a.x * b.x + a.y * b.y; }   long long crossProduct(point a, point b) { return a.x * b.y - a.y * b.x; }   int f(point a, point b) {     if ((double)a.x / a.y > (double)b.x / b.y) return 1;     return -1;   }   int main() {     int n;     cin >> n;     vector<long long> a(n), b(n);     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; i < n; i++) cin >> b[i];     vector<long long> dp(n);     dp[0] = 0;     vector<point> hull(n);     hull[0] = point(b[0], dp[0]);     int k = 1;     for (int i = 1; i < n; i++) {       int l = 0, r = k;       point q(a[i], 1);       while (r - l > 2) {         int m1 = (r + 2 * l) / 3;         int m2 = (2 * r + l) / 3;         long long u = dotProduct(q, hull[m1]);         long long v = dotProduct(q, hull[m2]);         if (u < v)           r = m2;         else           l = m1;       }       if (l + 1 < r && dotProduct(q, hull[l]) > dotProduct(q, hull[l + 1])) l++;       dp[i] = a[i] * hull[l].x + hull[l].y;       point p(b[i], dp[i]);       while (k > 1 && f(hull[k - 1] - hull[k - 2], p - hull[k - 1]) > 0) k--;       hull[k++] = p;     }     cout << dp[n - 1] << endl;   }
#include <bits/stdc++.h>   using namespace std;   const long long linf = 1e18 + 5;   const int mod = (int)1e9 + 7;   const int logN = 17;   const int inf = 1e9;   const int N = 2e5 + 5;   int main() {     int n, t;     vector<pair<int, int> > ans;     scanf( %d , &n);     queue<int> q;     for (int i = 1; i <= n; i++) {       scanf( %d , &t);       while (q.size() > t) {         ans.push_back(make_pair(q.front(), i - 1));         q.pop();       }       while (q.size() < t) q.push(i);     }     while (q.size()) {       ans.push_back(make_pair(q.front(), n));       q.pop();     }     cout << ans.size() <<   n ;     for (__typeof(ans.begin()) it = ans.begin(); it != ans.end(); it++)       cout << it->first <<     << it->second <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 5e5 + 10;   int n, q, a[maxn], bit[maxn][22] = {0}, pos[maxn][22] = {0};   int main() {     int i, j, l, r;     ios::sync_with_stdio(false);     cin.tie(0), cout.tie(0);     cin >> n;     for (i = 1; i <= n; i++) {       cin >> a[i];       l = i, r = a[i];       for (j = 20; j >= 0; j--)         bit[i][j] = bit[i - 1][j], pos[i][j] = pos[i - 1][j];       for (j = 20; j >= 0; j--)         if (r & (1 << j)) {           if (bit[i][j] == 0) {             bit[i][j] = r, pos[i][j] = l;             break;           }           if (l > pos[i][j]) {             swap(l, pos[i][j]);             swap(r, bit[i][j]);           }           r ^= bit[i][j];         }     }     cin >> q;     while (q--) {       cin >> l >> r;       int num = 0;       for (i = 20; i >= 0; i--)         if ((num ^ bit[r][i]) > num && pos[r][i] >= l) num ^= bit[r][i];       cout << num << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline string itos(T n) {     return (n) < 0    ?  -  + itos(-(n))            : (n) < 10 ? (string)(  ) + (char)( 0  + (n))                       : itos((n) / 10) + itos((n) % 10);   }   string name[60];   map<string, int> mp;   int point[60], _plus[60], _minus[60];   vector<pair<pair<int, pair<int, int> >, string> > v;   int main(void) {     int N, i, j;     string s;     cin >> N;     for ((i) = 0; (i) < (int)(N); (i)++) {       cin >> name[i];       mp[name[i]] = i;     }     for ((i) = 0; (i) < (int)(N * (N - 1) / 2); (i)++) {       cin >> s;       for (j = 0;; j++) {         if (s[j] ==  - ) break;       }       int a = mp[s.substr(0, j)];       int b = mp[s.substr(j + 1)];       int x, y;       cin >> s;       for ((j) = 0; (j) < (int)(s.length()); (j)++) {         if (s[j] ==  : ) {           s[j] =    ;         }       }       istringstream ss(s);       ss >> x >> y;       if (x > y)         point[a] += 3;       else if (x < y)         point[b] += 3;       else {         point[a]++;         point[b]++;       }       _plus[a] += x;       _plus[b] += y;       _minus[a] += y;       _minus[b] += x;     }     for ((i) = 0; (i) < (int)(N); (i)++) {       v.push_back(make_pair(           make_pair(-point[i], make_pair(_minus[i] - _plus[i], -_plus[i])),           name[i]));     }     sort(v.begin(), v.end());     vector<string> ans;     for ((i) = 0; (i) < (int)(N / 2); (i)++) {       ans.push_back(v[i].second);     }     sort(ans.begin(), ans.end());     for ((i) = 0; (i) < (int)(N / 2); (i)++) {       cout << ans[i] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int ar[105] = {0};     int n;     int r;     cin >> n;     int tc = n, a;     while (tc--) {       cin >> r;       for (int i = 0; i < r; i++) {         cin >> a;         ar[a]++;       }     }     for (int i = 1; i <= 100; i++)       if (ar[i] == n) cout << i <<    ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     int T;     cin >> T;     while (T--) {       int n;       int number[200005], dis[10] = {0};       char c;       cin >> n;       for (int a = 1; a <= n; a++) {         cin >> c;         number[a] = c -  0 ;         dis[number[a]] = 1;       }       int f = 0;       for (int a = 0; a <= 9; a++) {         int vis[200005];         for (int j = 1; j <= n; j++) vis[j] = 2;         int t = 1;         for (int i = 0; i <= a; i++) {           if (dis[i] == 0) continue;           for (int b = t; b <= n; b++)             if (number[b] == i) {               vis[b] = 1;               t = b + 1;             }           if (t == n + 1) break;         }         int flag = 0;         int maxx = 0;         for (int i = 1; i <= n; i++) {           if (vis[i] == 1) continue;           if (number[i] >= a && number[i] >= maxx)             maxx = number[i];           else {             flag = 1;             break;           }         }         if (flag == 1)           continue;         else {           for (int i = 1; i <= n; i++) cout << vis[i];           cout << endl;           f = 1;           break;         }       }       if (f == 0) cout <<  -  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dx[] = {0, 0, -1, 1};   int dy[] = {1, -1, 0, 0};   int px[105], py[105];   int main() {     int x, y, Sz, d, z;     bool f = 0;     string s;     cin >> x >> y >> s;     Sz = s.size();     px[0] = py[0] = 0;     for (int i = 0; i < Sz; i++) {       if (s[i] ==  U )         d = 0;       else if (s[i] ==  D )         d = 1;       else if (s[i] ==  L )         d = 2;       else         d = 3;       px[i + 1] = px[i] + dx[d];       py[i + 1] = py[i] + dy[d];     }     for (int i = 0; i <= Sz; i++) {       if (px[Sz] != 0) z = (x - px[i]) / px[Sz];       if (py[Sz] != 0) z = (y - py[i]) / py[Sz];       if (z < 0) continue;       if (z * px[Sz] == (x - px[i]) && z * py[Sz] == (y - py[i])) f = 1;     }     if (f)       printf( Yes n );     else       printf( No n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void hehe() {     int n;     cin >> n;     vector<int> arr(n);     for (int i = 0; i < n; i++) {       cin >> arr[i];     }     sort(arr.rbegin(), arr.rend());     vector<long long int> rem;     for (int i = 0; i < n - 1; i++) {       if (arr[i] - arr[i + 1] < 2) {         i++;         rem.push_back(arr[i]);       }     }     long long int ans = 0;     for (int i = 0; i + 1 < rem.size(); i += 2) {       ans += (long long int)(rem[i] * rem[i + 1]);     }     cout << ans;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int t = 1;     while (t--) {       hehe();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, k, cnt;   int A[10];   long long FE(long long n, long long m) {     if (!m) return 1;     long long t = FE(n, m >> 1);     t = (t * t) % (1000000007);     if (m & 1) t = (t * n) % (1000000007);     return t % (1000000007);   }   bool ctrl() {     bool H[10] = {0};     int s = k - 1;     if (!s) return true;     for (int i = 2; i <= k; i++) {       if (A[i] == 1) {         H[i] = 1;         s--;         if (!s) return true;       }     }     bool flag;     while (1) {       flag = 0;       for (int i = 2; i <= k; i++) {         if (!H[i] && H[A[i]]) {           H[i] = 1;           s--;           flag = 1;           if (!s) return true;         }       }       if (!flag) return false;     }   }   void solve(int x) {     if (x == k + 1) {       if (ctrl()) {         cnt++;         cnt %= (1000000007);       }       return;     }     for (int i = 1; i <= k; i++) {       A[x] = i;       solve(x + 1);     }   }   int main() {     scanf( %lld %lld , &n, &k);     solve(2);     long long res = 1;     if (n - k > 0) res *= FE(n - k, n - k);     cout << ((cnt * k) % (1000000007) * res) % (1000000007) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int i, t = 1, j, temp;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     long long t = 1;     while (t--) {       long long int n, k = 0;       cin >> n;       long long int a[n];       map<int, long long int> m;       for (i = 0; i < n; i++) {         cin >> a[i];         m[a[i]]++;       }       map<int, long long int>::iterator itr;       for (itr = m.begin(); itr != m.end(); itr++) {         if (k < (itr->second)) {           k = itr->second;         }       }       if (n % 2) {         (k <= ((n + 1) / 2)) ? cout <<  YES  : cout <<  NO ;       } else {         (k <= (n / 2)) ? cout <<  YES  : cout <<  NO ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   string transo(int n) {     switch (n) {       case 0:         return  zero ;         break;       case 1:         return  one ;         break;       case 2:         return  two ;         break;       case 3:         return  three ;         break;       case 4:         return  four ;         break;       case 5:         return  five ;         break;       case 6:         return  six ;         break;       case 7:         return  seven ;         break;       case 8:         return  eight ;         break;       case 9:         return  nine ;         break;     }   }   string transp(int n) {     switch (n) {       case 10:         return  ten ;         break;       case 11:         return  eleven ;         break;       case 12:         return  twelve ;         break;       case 13:         return  thirteen ;         break;       case 14:         return  fourteen ;         break;       case 15:         return  fifteen ;         break;       case 16:         return  sixteen ;         break;       case 17:         return  seventeen ;         break;       case 18:         return  eighteen ;         break;       case 19:         return  nineteen ;         break;     }   }   string transd(int n) {     switch (n) {       case 2:         return  twenty ;         break;       case 3:         return  thirty ;         break;       case 4:         return  forty ;         break;       case 5:         return  fifty ;         break;       case 6:         return  sixty ;         break;       case 7:         return  seventy ;         break;       case 8:         return  eighty ;         break;       case 9:         return  ninety ;         break;     }   }   int main() {     cin >> n;     if (n < 10) cout << transo(n);     if (n >= 10 && n <= 19) cout << transp(n);     if (n > 19 && n % 10 != 0) cout << transd(n / 10) <<  -  << transo(n % 10);     if (n > 19 && n % 10 == 0) cout << transd(n / 10);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long ts, tf, t, n, x, ans, lim = 1000000000007;   int main() {     cin >> ts >> tf >> t;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> x;       if (x <= tf - t) {         if (max(ts, x - 1) <= tf - t && ts - (x - 1) < lim) {           lim = ts - (x - 1);           ans = min(ts, x - 1);         }         ts = max(ts, x) + t;       }     }     if (ts <= tf - t) ans = ts;     cout << ans <<   n ;   }
#include <bits/stdc++.h>   int main() {     int t;     scanf( %d , &t);     while (t--) {       int n;       scanf( %d , &n);       if (n == 1 || n == 2 || n == 4) {         printf( -1 n );         continue;       }       if (!(n % 3))         printf( %d %d %d n , (n / 3), 0, 0);       else if (n % 3 == 1)         printf( %d %d %d n , (n - 7) / 3, 0, 1);       else         printf( %d %d %d n , (n - 5) / 3, 1, 0);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     std::ios_base::sync_with_stdio(false);     long long n, h, a, b, k;     cin >> n >> k >> a >> b >> k;     while (k--) {       long long tower1, tower2, source, destination;       cin >> tower1 >> source >> tower2 >> destination;       long long ans = 0;       if (tower1 == tower2) {         cout << abs(source - destination) << endl;       } else if (source > b) {         ans += abs(source - b);         ans += abs(tower2 - tower1);         ans += abs(b - destination);         cout << ans << endl;       } else if (source < a) {         ans += abs(a - source);         ans += abs(tower2 - tower1);         ans += abs(a - destination);         cout << ans << endl;       } else {         ans += abs(tower2 - tower1);         ans += abs(source - destination);         cout << ans << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 5;   int connected;   int par[N], sz[N];   struct DSU {     void init(int n) {       for (int i = 1; i <= n; i++) {         par[i] = i;         sz[i] = 1;       }       connected = n;     }     int getPar(int k) {       while (k != par[k]) {         par[k] = par[par[k]];         k = par[k];       }       return k;     }     int getSize(int k) { return sz[getPar(k)]; }     void unite(int u, int v) {       int par1 = getPar(u), par2 = getPar(v);       if (par1 == par2) return;       connected--;       if (sz[par1] > sz[par2]) swap(par1, par2);       sz[par2] += sz[par1];       sz[par1] = 0;       par[par1] = par[par2];     }   };   DSU dsu;   long long gcd(long long a, long long b) {     if (a == 0) return b;     return gcd(b % a, a);   }   long long powermod(long long x, long long y) {     if (y == 0) return 1;     if (y % 2 == 0)       return (powermod(x, y / 2) * powermod(x, y / 2)) % 1000000007;     else       return (((powermod(x, y / 2) * powermod(x, y / 2)) % 1000000007) * x) %              1000000007;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     map<int, int> m1, m2;     int n;     cin >> n;     long long ans = 0;     for (int i = 0; i < 2 * n; i++) {       int x;       cin >> x;       if (m1.find(x) == m1.end())         m1[x] = i + 1;       else         m2[x] = i + 1;     }     int y = 1;     for (auto x : m1) {       ans += abs(y - x.second);       y = x.second;     }     y = 1;     for (auto x : m2) {       ans += abs(y - x.second);       y = x.second;     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   inline int Get() {     int res = 0, q = 1;     char ch = getchar();     while ((ch <  0  || ch >  9 ) && ch !=  - ) ch = getchar();     if (ch ==  - ) q = -1, ch = getchar();     while (ch >=  0  && ch <=  9 ) res = res * 10 + ch -  0 , ch = getchar();     return res * q;   }   const double eps = 1e-12, pi = M_PI;   const int oo = (int)2e9, mod = (int)1e9 + 7;   const long long INF = (long long)1e17;   const int N = (int)1e6;   typedef long long arr[N + 10];   bool pri[N + 10];   arr f, g, phi, sum, sqrsum, prm;   long long s[N + 10][3], n, m;   int T;   void Prepare() {     phi[1] = 1;     for (long long i = (2), end = (N); i <= end; ++i) {       if (!pri[i]) prm[++m] = i, phi[i] = i - 1;       for (long long j = (1), end = (m); j <= end; ++j) {         if (i * prm[j] > N) break;         pri[i * prm[j]] = 1;         if (i % prm[j])           phi[i * prm[j]] = phi[i] * (prm[j] - 1);         else {           phi[i * prm[j]] = phi[i] * prm[j];           break;         }       }     }     for (long long i = (1), end = (N); i <= end; ++i) {       for (int j = 1; i * j <= N; ++j) {         g[i * j] = (g[i * j] + i * phi[j]) % mod;       }     }     for (long long i = (1), end = (N); i <= end; ++i)       sum[i] = (sum[i - 1] + i) % mod, sqrsum[i] = (sqrsum[i - 1] + i * i) % mod,       g[i] = (g[i] - i + mod) % mod;     for (long long i = (1), end = (N); i <= end; ++i) {       f[i] = (i >> 1) * i * i % mod,       f[i] = (f[i] - 4 * i % mod * sum[i >> 1] % mod + mod) % mod,       f[i] = (f[i] + 4 * sqrsum[i >> 1]) % mod;       f[i] = (f[i] << 1) % mod,       f[i] = (f[i] + 2 * (i * sum[i - 1] - sqrsum[i - 1]) % mod + mod) % mod,       f[i] = (f[i] + 2 * g[i]) % mod;       f[i] = (f[i] - i * i % mod + mod) % mod, f[i] = (f[i] + 2 * i) % mod;       s[i][0] = (s[i - 1][0] + f[i]) % mod,       s[i][1] = (s[i - 1][1] + f[i] * (i - 1) % mod) % mod;       s[i][2] = (s[i - 1][2] + f[i] * (i - 1) % mod * (i - 1)) % mod;     }   }   int main() {     Prepare();     for (scanf( %d                   n ,                &T);          T; --T) {       scanf(            %I64d             %I64d              n ,           &n, &m);       long long L = ((n) < (m) ? (n) : (m)), ans = 0;       ans = (ans + n * m % mod * s[L][0]) % mod;       ans = (ans - (n + m) * s[L][1] % mod + mod) % mod;       ans = (ans + s[L][2]) % mod;       printf(            %I64d              n ,           ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double pi = acos(-1.0);   const double eps = 1e-11;   const int INFINITE = 0x3f3f3f3f;   template <class T>   inline void checkmin(T &a, T b) {     if (b < a) a = b;   }   template <class T>   inline void checkmax(T &a, T b) {     if (b > a) a = b;   }   template <class T>   inline T sqr(T x) {     return x * x;   }   template <class T>   inline T lowbit(T n) {     return (n ^ (n - 1)) & n;   }   template <class T>   inline int countbit(T n) {     return (n == 0) ? 0 : (1 + countbit(n & (n - 1)));   }   template <class T>   inline T gcd(T a, T b) {     T c;     while (a != 0) {       c = a;       a = b % a;       b = c;     }     return b;   }   typedef vector<int> VI;   typedef vector<VI> VII;   typedef vector<string> VS;   inline void solve() {     int n;     scanf( %d , &n);     bool f = true;     for (int i = 20; i >= 0; i--) {       if ((n & (1 << i)) > 0) {         if (f)           f = false;         else           printf(   );         printf( %d , i + 1);       }     }     printf(  n );   }   int main() {     ios::sync_with_stdio(false);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k, res;     int a[400], c;     while (cin >> n >> k) {       cin >> c;       for (int i = 0; i < c; i++) cin >> a[i];       sort(a, a + c);       res = 0;       for (int t = 0, ci = 0; t < n; res++) {         if (ci < c && a[ci] <= t + k && a[ci] <= n) {           t = a[ci++];         } else {           t += k;           if (t > n) res--;         }       }       cout << res << endl;     }     return 0;   }