malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1000 * 1000 * 1000 + 7LL;   const double EXP = 1e-6;   const int MAX = 100001;   int main() {     int n, k;     while (cin >> n >> k) {       int a[10001];       for (int i = 1; i <= n; i++) a[i] = 1;       a[n] = 0;       while (k--) {         for (int i = 1; i <= n; i++) {           if (a[i] + a[i] > n - i) {             int p = n - i - a[i];             int o = n - p;             a[i] += a[o];             cout << o <<    ;           } else if (a[i] == n - i)             cout << n <<    ;           else {             a[i] += a[i];             cout << i <<    ;           }         }         cout << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char s[100010], s1[100010], s2[100010], s3[100010], s11[100010];   int main() {     scanf( %s , &s);     int len;     len = strlen(s);     int sum = 0, a = 0;     for (int i = 0; i < len; i++) {       sum += s[i] -  0 ;       if (s[i] ==  0 ) a = 1;     }     if (sum % 3 == 0) {       int cnt = 0;       for (int i = 0; i < len - 1; i++) {         if (s[i] !=  0 )           break;         else           cnt++;       }       int j = 0;       for (int i = cnt; i < len; i++) s1[j++] = s[i];       cout << s1 << endl;     } else {       int num = sum % 3;       int cnt1 = -1, cnt2 = -1, cnt3 = -1;       int t1 = 0, t2 = 0;       for (int i = len - 1; i >= 0; i--) {         if ((s[i] -  0 ) % 3 == num) {           cnt1 = i;           break;         }       }       if (cnt1 != -1) {         int j = 0;         for (int i = 0; i < len; i++) {           if (i == cnt1)             continue;           else             s1[j++] = s[i];         }         int cnt = 0;         for (int i = 0; i < j - 1; i++) {           if (s1[i] !=  0 )             break;           else             cnt++;         }         for (int i = cnt; i < j; i++) s2[t1++] = s1[i];       }       for (int i = len - 1; i >= 1; i--) {         if ((s[i] -  0 ) % 3 == 0) continue;         for (int j = i - 1; j >= 0; j--) {           int cnt = s[i] -  0  + s[j] -  0 ;           if (cnt % 3 == num) {             cnt2 = i;             cnt3 = j;             break;           }         }         if (cnt2 != -1 && cnt3 != -1) break;       }       if (cnt2 != -1 && cnt3 != -1) {         int j = 0;         for (int i = 0; i < len; i++) {           if (i == cnt2 || i == cnt3) continue;           s11[j++] = s[i];         }         int cnt = 0;         for (int i = 0; i < j - 1; i++) {           if (s11[i] !=  0 )             break;           else             cnt++;         }         for (int i = cnt; i < j; i++) s3[t2++] = s11[i];       }       if (!a && t1 == 0 && t2 == 0)         cout << -1 << endl;       else if (t1 == 0 && t2 == 0)         cout << 0 << endl;       else if (t1 >= t2)         cout << s2 << endl;       else         cout << s3 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void sprint(string s) {     for (int i = 0; i < s.size(); ++i) printf( %c , s[i]);     printf(  n );   }   int main() {     int n, k, d;     cin >> n >> k >> d;     int a[n];     int b[n];     for (int i = 0; i < n; ++i) {       scanf( %d , &a[i]);       b[i] = 0;     }     sort(a, a + n);     if (k == 1) b[n - 1] = 1;     for (int i = n - 2; i >= 0; --i) {       if (n - i < k) continue;       if (n - i >= k and a[n - 1] - a[i] <= d)         b[i] = b[i + 1] + 1;       else if (a[i + k - 1] - a[i] > d)         b[i] = b[i + 1];       else {         auto it = upper_bound(a, a + n, a[i] + d);         it--;         int id = it - a;         if (id < i + k - 1) {           b[i] = b[i + 1];         } else {           id++;           if (id == n - 1) {             if (b[i + k])               b[i] = b[i + 1] + 1;             else               b[i] = b[i + 1];           } else {             if (b[i + k] - b[id + 1] > 0)               b[i] = b[i + 1] + 1;             else               b[i] = b[i + 1];           }         }       }     }     for (int i = 0; i < n; ++i) {     }     if (n == 1) {       printf( YEs n );     } else if (b[0] - b[1])       printf( YES n );     else       printf( NO n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct myQueue {     stack<pair<long long, long long> > s1, s2;     int size() { return s1.size() + s2.size(); }     bool isEmpty() { return size() == 0; }     long long getMax() {       if (isEmpty()) {         return -2e9;       }       if (!s1.empty() && !s2.empty()) {         return max(s1.top().second, s2.top().second);       }       if (!s1.empty()) {         return s1.top().second;       }       return s2.top().second;     }     void push(long long val) {       if (s2.empty()) {         s2.push({val, val});       } else {         s2.push({val, max(val, s2.top().second)});       }     }     void pop() {       if (s1.empty()) {         while (!s2.empty()) {           if (s1.empty()) {             s1.push({s2.top().first, s2.top().first});           } else {             s1.push({s2.top().first, max(s2.top().first, s1.top().second)});           }           s2.pop();         }       }       assert(!s1.empty());       s1.pop();     }   };   int main() {     cin.tie(NULL);     cout.tie(NULL);     ios_base::sync_with_stdio(0);     long long n, k, x;     cin >> n >> k >> x;     vector<int> a(n);     for (long long i = 0; i < n; i++) {       cin >> a[i];     }     vector<myQueue> q(x + 1);     for (long long i = 0; i < n; i++) {       vector<long long> dp(x + 1, -2e9);       if (i)         for (long long j = 1; j < x + 1; j++) {           if (i < k && j == 1) dp[j] = a[i];           long long getMax = q[j - 1].getMax();           if (getMax != -2e9) dp[j] = max(dp[j], getMax + 1LL * a[i]);         }       if (!i) dp[1] = a[0];       for (long long j = 1; j < x + 1; j++) {         if (q[j].size() == k) {           q[j].pop();         }         q[j].push(dp[j]);       }     }     long long ans = q[x].getMax();     if (ans == -2e9) return cout << -1, 0;     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s1, s2;   int len1, len2;   int dp[5002][5002];   int func(int p1, int p2) {     if ((p1 == len1) || (p2 == len2)) {       return 0;     }     if (dp[p1][p2] != -1) {       return dp[p1][p2];     }     int ans = 0;     if (s1[p1] == s2[p2]) {       ans = (1 + ans + func(p1 + 1, p2 + 1)) % 1000000007;     }     ans = (ans + func(p1, p2 + 1)) % 1000000007;     return dp[p1][p2] = ans;   }   int main() {     std::ios_base::sync_with_stdio(false);     ;     cin >> s1 >> s2;     len1 = s1.size();     len2 = s2.size();     memset((dp), -1, sizeof(dp));     int ans = 0;     for (int i = 0; i <= len1 - 1; i++) {       ans = (ans + func(i, 0)) % 1000000007;     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using namespace std;   int get_type(int a, int b, int c) {     if (a == 0 && b == 0 && c != 0) return 0;     if (a == 0 && b == 0 && c == 0) return -1;     if (a == 0) return 1;     if (b == 0) return 2;     return 3;   }   int main() {     int a1, b1, c1, a2, b2, c2;     cin >> a1 >> b1 >> c1 >> a2 >> b2 >> c2;     int t1 = get_type(a1, b1, c1);     int t2 = get_type(a2, b2, c2);     if (t1 == 0 || t2 == 0)       cout <<  0 ;     else if (t1 == -1 || t2 == -1)       cout <<  -1 ;     else if (t1 != t2)       cout <<  1 ;     else {       if (t1 == 1) {         if (c1 * b2 == c2 * b1)           cout <<  -1 ;         else           cout <<  0 ;       } else if (t1 == 2) {         if (c1 * a2 == c2 * a1)           cout <<  -1 ;         else           cout <<  0 ;       } else {         if (b1 * a2 != a1 * b2)           cout <<  1 ;         else {           if (c1 * b2 == c2 * b1)             cout <<  -1 ;           else             cout <<  0 ;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 10;   struct node {     long long v[10];     int tag[10];     void init(int x) {       int y = 1;       memset(v, 0, sizeof(v));       while (x) {         v[x % 10] += y;         x /= 10;         y *= 10;       }     }     void updtag(int* _tag) {       for (int i = 0; i < 10; i++) tag[i] = _tag[tag[i]];     }     bool havetag() {       for (int i = 0; i < 10; i++)         if (tag[i] != i) return 1;       return 0;     }   } f[N * 4];   int a[N];   int n, q;   int tag[10];   long long ans;   void upd(int s) {     for (int i = 0; i < 10; i++) f[s].v[i] = f[s + s].v[i] + f[s + s + 1].v[i];   }   void build(int l, int r, int s) {     for (int i = 0; i < 10; i++) f[s].tag[i] = i;     if (l == r) {       f[s].init(a[l]);       return;     }     build(l, (l + r) / 2, s + s);     build((l + r) / 2 + 1, r, s + s + 1);     upd(s);   }   long long tmp[10] = {0};   void down(int l, int r, int s) {     if (!f[s].havetag()) return;     for (int i = 0; i < 10; i++) tmp[f[s].tag[i]] += f[s].v[i];     for (int i = 0; i < 10; i++) f[s].v[i] = tmp[i], tmp[i] = 0;     if (l != r) f[s + s].updtag(f[s].tag), f[s + s + 1].updtag(f[s].tag);     for (int i = 0; i < 10; i++) f[s].tag[i] = i;   }   void change(int l, int r, int s, int ll, int rr) {     down(l, r, s);     if (r < ll || rr < l) return;     if (ll <= l && r <= rr) {       f[s].updtag(tag);       down(l, r, s);       return;     }     change(l, (l + r) / 2, s + s, ll, rr);     change((l + r) / 2 + 1, r, s + s + 1, ll, rr);     upd(s);   }   void get(int l, int r, int s, int ll, int rr) {     down(l, r, s);     if (r < ll || rr < l) return;     if (ll <= l && r <= rr) {       for (int i = 1; i < 10; i++) ans += f[s].v[i] * i;       return;     }     get(l, (l + r) / 2, s + s, ll, rr);     get((l + r) / 2 + 1, r, s + s + 1, ll, rr);   }   int main() {     scanf( %d %d , &n, &q);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);     }     build(1, n, 1);     while (q--) {       int sig, l, r, x, y;       scanf( %d %d %d , &sig, &l, &r);       if (sig == 1) {         scanf( %d %d , &x, &y);         for (int i = 0; i < 10; i++) tag[i] = i;         tag[x] = y;         change(1, n, 1, l, r);         continue;       }       ans = 0;       get(1, n, 1, l, r);       printf( %lld n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<pair<int, pair<int, int> > > horz, vert, tmp;   set<int> y_com;   map<int, int> y_map;   void cleanup(vector<pair<int, pair<int, int> > >& v) {     sort(v.begin(), v.end());     for (auto it = v.begin(); it != v.end();) {       if (it != v.begin()) {         auto prev = it;         prev--;         if (prev->first == it->first &&             prev->second.second >= it->second.first - 1) {           prev->second.second = max(it->second.second, prev->second.second);           it = v.erase(it);         } else           it++;       } else         it++;     }   }   int BIT[211111];   void update(int pos, int val) {     while (pos < 211111) {       BIT[pos] += val;       pos += (pos & (-pos));     }   }   int get(int pos) {     int ans = 0;     while (pos > 0) {       ans += BIT[pos];       pos -= (pos & (-pos));     }     return ans;   }   int main() {     ios_base::sync_with_stdio(false);     int n;     cin >> n;     long long ans = 0;     for (int i = 0; i < n; i++) {       int x[2], y[2];       cin >> x[0] >> y[0] >> x[1] >> y[1];       x[0] += 1000000001;       x[1] += 1000000001;       y[0] += 1000000001;       y[1] += 1000000001;       if (y[0] == y[1]) {         horz.push_back(             make_pair(y[0], make_pair(min(x[0], x[1]), max(x[0], x[1]))));       } else {         vert.push_back(             make_pair(x[0], make_pair(min(y[0], y[1]), max(y[0], y[1]))));       }     }     cleanup(horz);     cleanup(vert);     for (auto it : horz) {       ans += it.second.second - it.second.first + 1;       y_com.insert(it.first);     }     for (auto it : vert) {       ans += it.second.second - it.second.first + 1;       y_com.insert(it.second.first);       y_com.insert(it.second.second);     }     int cnt = 1;     for (auto it : y_com) y_map[it] = cnt++;     for (auto it : horz) {       tmp.push_back(make_pair(it.second.first, make_pair(it.first, 1)));       tmp.push_back(make_pair(it.second.second + 1, make_pair(it.first, -1)));     }     sort(tmp.begin(), tmp.end());     int cur = 0;     for (auto it : vert) {       while (cur < tmp.size() && tmp[cur].first <= it.first) {         update(y_map[tmp[cur].second.first], tmp[cur].second.second);         cur++;       }       ans -= get(y_map[it.second.second]) - get(y_map[it.second.first] - 1);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-7;   const int inf = 0x3f3f3f3f;   const int hinf = 0x3f3f3f3f;   const long long mod = 1000000009;   struct node {     int l, r;     double expe;     double add;   } sgt[100010 << 2];   int n, m;   int a[100010], h[100010], l[100010], r[100010];   struct mushroom {     int b, z;     bool operator<(const mushroom& bb) const { return b < bb.b; }   } dat[100010];   void up(int root) {     sgt[root].expe = sgt[root << 1].expe + sgt[root << 1 | 1].expe;   }   void down(int root) {     sgt[root << 1].add *= sgt[root].add;     sgt[root << 1].expe *= sgt[root].add;     sgt[root << 1 | 1].add *= sgt[root].add;     sgt[root << 1 | 1].expe *= sgt[root].add;     sgt[root].add = 1.0;   }   void build(int l, int r, int root) {     sgt[root].l = l;     sgt[root].r = r;     sgt[root].expe = 0.0;     sgt[root].add = 1.0;     if (l == r) {       sgt[root].expe = dat[sgt[root].l].z;       return;     }     int mid = (l + r) >> 1;     build(l, mid, root << 1);     build(mid + 1, r, root << 1 | 1);     up(root);   }   void upd(int l, int r, double val, int root) {     if (l > dat[sgt[root].r].b || r < dat[sgt[root].l].b) return;     if (dat[sgt[root].l].b >= l && dat[sgt[root].r].b <= r) {       sgt[root].add *= val;       sgt[root].expe *= val;       return;     }     down(root);     int mid = (sgt[root].l + sgt[root].r) >> 1;     if (l <= dat[mid].b) upd(l, r, val, root << 1);     if (r >= dat[mid].b) upd(l, r, val, root << 1 | 1);     up(root);   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) {       scanf( %d%d%d%d , &a[i], &h[i], &l[i], &r[i]);     }     for (int i = 1; i <= m; i++) {       scanf( %d%d , &dat[i].b, &dat[i].z);     }     sort(dat + 1, dat + 1 + m);     build(1, m, 1);     for (int i = 1; i <= n; i++) {       upd(a[i] - h[i], a[i] - 1, 1.0 - l[i] / 100.0, 1);       upd(a[i] + 1, a[i] + h[i], 1.0 - r[i] / 100.0, 1);     }     printf( %.15lf n , sgt[1].expe);   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-9;   const long long int MOD1 = 1e9 + 7;   const long long int MAX5 = 1e5;   const long long int MAX6 = 1e6;   const long long int MAX7 = 1e7;   const long long int MAX8 = 1e8;   const long long int MAX9 = 1e9;   const long long int MAX10 = 1e10;   const long long int MAXX = 1e18;   long long int pow(long long int x, long long int y) {     long long int res = 1;     while (y > 0) {       res = res * x;       x = x * x;       y >>= 1;     }     return res;   }   long long int gcd(int a, int b) {     if (a < b) swap(a, b);     if (b == 0) return a;     return gcd(a % b, b);   }   void solve() {     int n, q;     cin >> n >> q;     set<int> p;     for (int ii = 0; ii < n; ii++) {       int aa;       cin >> aa;       p.insert(aa);     }     auto it = p.begin();     multiset<int> m;     m.insert(0);     for (int ii = 0; ii < p.size() - 1; ii++) {       int x = *it;       it++;       m.insert(x - *it);     }     cout << *p.rbegin() - *p.begin() + *m.begin();     cout <<   n ;     ;     for (int ii = 0; ii < q; ii++) {       int t, x;       cin >> t >> x;       int y, z;       bool Y = false, Z = false;       if (t == 0) {         it = p.find(x);         if (it != p.begin()) {           it--;           y = *it;           Y = true;           m.erase(m.find(y - x));         }         it = p.find(x);         if (it != (--p.end())) {           it++;           z = *it;           Z = true;           m.erase(m.find(x - z));         }         if (Y && Z) m.insert(y - z);         p.erase(x);       }       if (t == 1) {         p.insert(x);         it = p.find(x);         if (it != p.begin()) {           it--;           y = *it;           Y = true;           m.insert(y - x);         }         it = p.find(x);         if (it != (--p.end())) {           it++;           z = *it;           Z = true;           m.insert(x - z);         }         if (Y && Z) m.erase(m.find(y - z));       }       if (!p.empty())         cout << *p.rbegin() - *p.begin() + *m.begin();       else         cout << 0;       cout <<   n ;       ;     }   }   int main() {     { solve(); }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     pair<int, int> mmx[3];     for (int i = 0; i < 3; i++) cin >> mmx[i].first >> mmx[i].second;     int a, b, c;     a = min(n - mmx[1].first - mmx[2].first, mmx[0].second);     b = min(n - a - mmx[2].first, mmx[1].second);     c = n - a - b;     cout << a <<     << b <<     << c;     return 0;   }
#include<bits/stdc++.h>      using namespace :: std;      #define ll long long   #define mp make_pair   #define ld long double   #define F first   #define S second   #define pii pair<int,int>   #define pb push_back      const int maxn=2e5+500;   const int inf=1e9+900;   const int mod=1e9+7;      pair<int,int> tip,che;      ld lenght(pair<ld,ld> a){    return sqrt(a.F*a.F+a.S*a.S);   }   bool mibin(pair<ld,ld> x){     complex<ld> a,b;     a.real(((ld)(che.F)-(x.F)));     a.imag(((ld)(che.S)-(x.S)));     b.real(((ld)(che.F)-(tip.F)));     b.imag(((ld)(che.S)-(tip.S)));     a*=-1;     b*=-1;     if(arg(a)<=0 && arg(b)<=0){      return (arg(a)<=arg(b));     }     if(arg(a)>=0 && arg(b)>=0){      return (arg(a)<=arg(b));     }     if(arg(a)>=0 && arg(b)<=0){      return 1;     }     if(arg(a)<=0 && arg(b)>=0){      return 0;     }     return (arg(a)<=arg(b));   }      void add(pair<int,int> x){    if(mibin(mp((ld)x.F,(ld)x.S))){     tip=x;    }   }   ld mibine(pair<int,int> s,pair<int,int> t){    pair<int,int> v=mp(t.F-s.F,t.S-s.S);    if(!mibin(s)){    // cout<< NOting n ;     return 0;    }    if(mibin(t)){    // cout<< ALL n ;     return lenght(v);    }    ld b=0;    ld e=1;    for(int i=0;i<60;i++){     ld mid=(e+b)/2;     if(mibin(mp((s.F)+mid*(v.F),(s.S)+mid*(v.S)))){      b=mid;     }else{      e=mid;     }    }   // cout<<b<<endl;    return lenght(v)*b;   }         int x[maxn];   int y[maxn];         int main(){    ios_base::sync_with_stdio(false);    cin.tie(0);       int n,h;    cin>>n>>h;    for(int i=0;i<n;i++){     cin>>x[i]>>y[i];    }    ld ans=lenght(mp(x[n-1]-x[n-2],y[n-1]-y[n-2]));    tip=mp(x[n-2],y[n-2]);    che=mp(x[n-1],y[n-1]+h);    for(int i=n-3;i>=0;i--){     add(mp(x[i+1],y[i+1]));     ans+=mibine(mp(x[i],y[i]),mp(x[i+1],y[i+1]));    }    cout<<fixed<<setprecision(10)<<ans;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   T read1() {     T t = 0;     char k;     bool v = 0;     do (k = getchar()) ==  -  && (v = 1);     while ( 0  > k || k >  9 );     while ( 0  <= k && k <=  9 )       t = (t << 3) + (t << 1) + (k ^  0 ), k = getchar();     return v ? -t : t;   }   int v[1200005], s, fl[1200005], w[1200005];   vector<pair<int, pair<int, int> > > a[300005], b;   void down(int d) {     fl[d << 1] += fl[d];     fl[d << 1 | 1] += fl[d];     v[d << 1] += fl[d];     v[d << 1 | 1] += fl[d];     fl[d] = 0;   }   void up(int d) {     v[d << 1] > v[d << 1 | 1] ? (w[d] = w[d << 1], v[d] = v[d << 1])                               : (w[d] = w[d << 1 | 1], v[d] = v[d << 1 | 1]);   }   void add(int l, int r, int x, int y, int z, int d) {     if (l == x && r == y) {       v[d] += z, fl[d] += z;       return;     }     down(d);     int mid = l + r >> 1;     if (y <= mid)       add(l, mid, x, y, z, d << 1);     else if (mid < x)       add(mid + 1, r, x, y, z, d << 1 | 1);     else       add(l, mid, x, mid, z, d << 1), add(mid + 1, r, mid + 1, y, z, d << 1 | 1);     up(d);   }   void build(int l, int r, int d) {     if (l == r)       w[d] = l;     else {       build(l, l + r >> 1, d << 1);       build(l + r + 2 >> 1, r, d << 1 | 1);       w[d] = w[d << 1];     }   }   int wh, g;   int main() {     s = read1<long long>();     build(1, 300000, 1);     for (int i = 1; i <= s; ++i) {       int l = read1<long long>(), v = read1<long long>(), r = read1<long long>();       b.push_back(make_pair(l, make_pair(v, r)));       a[l].push_back(make_pair(1, make_pair(v, r)));       a[v + 1].push_back(make_pair(-1, make_pair(v, r)));     }     int ans = 0;     for (int i = 1; i <= 300000; ++i) {       for (int j = 0; j < a[i].size(); ++j)         add(1, 300000, a[i][j].second.first, a[i][j].second.second, a[i][j].first,             1);       if (v[1] > ans) ans = v[1], wh = i, g = w[1];     }     cout << ans << endl;     for (int i = 0; i < s; ++i)       if (b[i].first <= wh && wh <= b[i].second.first && b[i].second.first <= g &&           g <= b[i].second.second)         printf( %d  , i + 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int c, d, n, m, k;     cin >> c >> d >> n >> m >> k;     int users = n * m - k;     int ans = 1000000000;     for (int i = 0; i <= m; i++)       for (int j = 0; j <= 10000; j++) {         if (i * n + j >= users) {           if (c * i + j * d < ans) ans = c * i + j * d;         }       }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int a[10001];   int i, j, n, k;   int main() {     cin >> n;     for (i = 0; i < n; i++)       for (j = 0; j < n; j++) {         cin >> k;         if (k == 3 || k == 1) a[i] = -1;       }     k = 0;     for (i = 0; i < n; i++)       if (a[i] != -1) k++;     cout << k <<   n ;     for (i = 0; i < n && k > 0; i++)       if (a[i] != -1) cout << i + 1 <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int i;     int n, d, l;     cin >> n >> d >> l;     int pos = (n + 1) / 2;     int neg = n / 2;     int a[n + 1];     if (d > (pos * l - neg) || d < (pos - neg * l)) {       cout <<  -1 ;       return 0;     }     if (d > 0) {       for (i = 1; i <= n; i++) a[i] = 1;       i = 1;       if (n & 1) d--;       while (d) {         a[2 * i - 1] += min(l - 1, d);         d -= min(l - 1, d);         i++;       }     } else {       for (i = 1; i <= n; i++) a[i] = 1;       i = 1;       d = -d;       if (n & 1) d++;       while (d) {         a[2 * i] += min(l - 1, d);         d -= min(l - 1, d);         i++;       }     }     for (i = 1; i <= n; i++) cout << a[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 2e5 + 10;   int n, m;   bool lie[40];   int ask(int d) {     int ret;     cout << d << endl;     cin >> ret;     if (ret == 0) exit(0);     return ret;   }   int main() {     cin >> m >> n;     for (int i = 0; i < n; i++)       if (ask(m) == 1) lie[i] = true;     int l = 1, r = m;     int cnt = 0;     while (l < r) {       int mid = l + (r - l) / 2;       int ans = ask(mid);       if (lie[(cnt++) % n]) ans = -ans;       if (ans > 0)         l = mid + 1;       else         r = mid - 1;     }     ask(l);   }