malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long n, m;   long long ban[300000];   long long cnt[300000];   long long used[300000];   long long dp[300000];   long long g[300000];   long long fi;   vector<long long> vec[300000];   vector<long long> GCD[300000];   vector<long long> ans;   long long gcd(long long a, long long b) {     if (!a) return b;     return gcd(b % a, a);   }   void update(long long v) {     used[v] = 1;     if (GCD[v].size() == 0) return;     dp[v] += GCD[gcd(v, m)].size();     long long mx = 0;     for (int i = 0; i < vec[v].size(); i++) {       long long to = vec[v][i];       if (!used[to]) update(to);       if (dp[to] > mx) mx = dp[to];     }     dp[v] += mx;   }   long long bin_pow(long long x, long long y) {     if (y == 1) return x;     if (y % 2 == 0) {       long long z = bin_pow(x, y / 2);       return (z * z) % m;     } else       return (x * bin_pow(x, y - 1)) % m;   }   int main() {     ios_base::sync_with_stdio(0);     cin >> n >> m;     if (m == 1) {       cout << 1 << endl;       cout << 0 << endl;       return 0;     }     for (int i = 0; i < n; i++) {       long long x;       cin >> x;       ban[x] = 1;     }     for (int i = 1; i < m; i++) {       g[i] = gcd(i, m);       if (g[i] == 1) fi++;       if (!ban[i]) GCD[gcd(i, m)].push_back(i);     }     for (int i = 1; i < m; i++)       for (int j = 2 * i; j < m; j += i) vec[i].push_back(j);     int v = 0;     for (int i = 1; i < m; i++) {       if (!used[i]) update(i);       if (dp[i] > dp[g[v]]) v = GCD[i][0];     }     while (v) {       for (int i = 0; i < GCD[g[v]].size(); i++) ans.push_back(GCD[g[v]][i]);       int w = 0;       for (int i = 0; i < vec[g[v]].size(); i++) {         if (dp[vec[g[v]][i]] > dp[g[w]]) w = GCD[vec[g[v]][i]][0];       }       if (!w)         break;       else         v = w;     }     cout << ans.size() + 1 - ban[0] << endl;     if (!ans.empty()) cout << ans[0] <<    ;     for (int i = 0; i < ans.size() - 1; i++) {       long long x = ans[i];       long long y = ans[i + 1];       x /= g[x];       y /= g[y];       long long a = y * bin_pow(x, fi - 1);       a %= m;       a *= g[ans[i + 1]] / g[ans[i]];       cout << a % m <<    ;     }     if (!ban[0]) cout << 0 << endl;   }
#include <bits/stdc++.h>   using namespace std;   int prime[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59};   int fack[62];   int dp[110][1 << 17];   int pre[110][1 << 17];   int x[110][1 << 17];   int n;   int a[110];   void init() {     memset(fack, 0, sizeof(fack));     for (int i = 1; i <= 60; i++) {       for (int j = 0; j <= 16; j++) {         if (i % prime[j] == 0) {           fack[i] += (1 << j);         }       }     }   }   void dfs(int idx, int id) {     if (idx >= 2) dfs(idx - 1, pre[idx][id]);     printf( %d%c , x[idx][id], idx == n ?   n  :    );   }   int main() {     init();     fack[1] = 0;     while (~scanf( %d , &n)) {       for (int i = 1; i <= n; i++) scanf( %d , &a[i]);       memset(dp, 50, sizeof(dp));       dp[0][0] = 0;       for (int i = 1; i <= n; i++) {         for (int s = 0; s <= (1 << 17) - 1; s++) {           for (int k = 1; k < 60; k++) {             if (s & fack[k])               continue;             else {               if (dp[i][s | fack[k]] > dp[i - 1][s] + abs(a[i] - k)) {                 dp[i][s | fack[k]] = dp[i - 1][s] + abs(a[i] - k);                 pre[i][s | fack[k]] = s;                 x[i][s | fack[k]] = k;               }             }           }         }       }       int ans = 0x3f3f3f3f;       int id;       for (int s = 0; s <= (1 << 17) - 1; s++) {         if (dp[n][s] < ans) {           ans = dp[n][s];           id = s;         }       }       dfs(n, id);     }   }
#include <bits/stdc++.h>   using namespace std;   using LL = long long;   const int MAXN = 11;   const int MAXM = 1e4 + 5;   int n, m, ex[MAXN];   int cnt[30];   char w[MAXN][MAXM];   void solve() {     scanf( %d %d , &n, &m);     for (int i = 0; i < n; i++) scanf( %d , &ex[i]);     for (int i = 0; i < n; i++) scanf( %s , w[i]);     LL ans = 0;     int pos;     for (int i = 0; i < (1 << n); i++) {       for (int j = 0; j <= 20; j++) cnt[j] = 0;       for (int j = 0; j < m; j++) {         int x[2] = {0, 0};         for (int k = 0; k < n; k++)           if (w[k][j] ==  1 ) x[((1 << k) & i) != 0]++;         cnt[x[1] - x[0] + 10]++;       }       int mm = m;       LL sum = 0;       for (int j = 0; j < n; j++)         if (((1 << j) & i) == 0)           sum += ex[j];         else           sum -= ex[j];       for (int j = 20; j >= 0; j--) {         sum += 1ll * (j - 10) * (2 * mm - cnt[j] + 1) * cnt[j] / 2;         mm -= cnt[j];       }       if (sum >= ans) ans = sum, pos = i;     }     {       for (int j = 0; j <= 20; j++) cnt[j] = 0;       for (int j = 0; j < m; j++) {         int x[2] = {0, 0};         for (int k = 0; k < n; k++)           if (w[k][j] ==  1 ) x[((1 << k) & pos) != 0]++;         cnt[x[1] - x[0] + 10]++;       }       for (int j = 1; j <= 20; j++) cnt[j] += cnt[j - 1];       for (int j = 0; j < m; j++) {         int x[2] = {0, 0};         for (int k = 0; k < n; k++)           if (w[k][j] ==  1 ) x[((1 << k) & pos) != 0]++;         printf( %d  , cnt[x[1] - x[0] + 10]);         cnt[x[1] - x[0] + 10]--;       }       printf(  n );     }   }   int main() {     int T;     scanf( %d , &T);     for (int i = 1; i <= T; i++) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) {     if (a == 0 || b == 0) return abs(a - b);     long long res = a % b;     while (res) {       a = b;       b = res;       res = a % b;     }     return b;   }   long long lcm(long long a, long long b) { return a * b / gcd(a, b); }   long long max(long long a, long long b) {     if (a > b)       return a;     else       return b;   }   long long min(long long a, long long b) {     if (a < b)       return a;     else       return b;   }   long long numberofdiviser(long long a) {     long long ans = 0;     long long i;     for (i = 1; i * i < a; i++) {       if (a % i == 0) ans += 2;     }     if (i * i == a) ans++;     return ans;   }   void fival(long long* a, long long b, long long n) {     for (int i = 0; i < n; i++) {       a[i] = b;     }   }   long long sum, ans, l, r, x;   long long ss(vector<long long> a, vector<long long>& b, int ii) {     for (int i = ii; i < a.size(); i++) {       b.push_back(a[i]);       sum += a[i];       if (b.size() > 1 && sum >= l && sum <= r && b[b.size() - 1] - b[0] >= x)         ans++;       ss(a, b, i + 1);       sum -= b[b.size() - 1];       b.pop_back();     }     return ans;   }   unsigned long long fact(long long n) {     if (n == 0) return 1;     return n * fact(n - 1);   }   unsigned long long Combinations(unsigned long long n, unsigned long long r) {     if (r > n) return 0;     if (r * 2 > n) r = n - r;     if (r == 0) return 1;     unsigned long long res = n;     for (int i = 2; i <= r; ++i) {       res *= (n - i + 1);       res /= i;     }     return res;   }   int solve() {     long long a, b;     cin >> a >> b;     vector<long long> v1, v2;     for (long long i = a; i <= a * b; i += a) {       v1.push_back(i);     }     for (long long i = b; i <= a * b; i += b) {       v2.push_back(i);     }     long long ans = 0;     for (long long i = 0, j = 0; i < v1.size() && j < v2.size();) {       if (v1[i] == v2[j]) {         if (a > b)           ans++;         else           ans--;         i++, j++;       } else if (v1[i] < v2[j]) {         ans++, i++;       } else {         ans--, j++;       }     }     if (ans > 0)       cout <<  Dasha ;     else if (ans == 0)       cout <<  Equal ;     else       cout <<  Masha ;     return 0;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int t = 1;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   const int IN = 2e5 + 7;   int sum[IN];   int main() {     string str;     cin >> str;     int n;     scanf( %d , &n);     memset(sum, 0, sizeof(sum));     if (str[0] == str[1])       sum[0] = 1;     else       sum[0] = 0;     int k = str.size();     for (int i = 1; i < k - 1; i++) {       if (str[i] == str[i + 1]) {         sum[i] = sum[i - 1] + 1;       } else {         sum[i] = sum[i - 1];       }     }     sum[k - 1] = sum[k - 2];     int l, r;     for (int i = 0; i < n; i++) {       scanf( %d%d , &l, &r);       if (l != 1)         printf( %d n , sum[r - 2] - sum[l - 2]);       else         printf( %d n , sum[r - 2]);     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 200005;   map<string, int> f;   vector<pair<int, string> > v;   int n, cnt = 0;   int main() {     scanf( %d , &n);     for (int i = 0; i < n; ++i) {       string s;       cin >> s;       f[s] = ++cnt;     }     for (map<string, int>::iterator it = f.begin(); it != f.end(); ++it) {       v.push_back(make_pair(it->second, it->first));     }     sort(v.begin(), v.end(), greater<pair<int, string> >());     for (int i = 0; i < v.size(); ++i) cout << v[i].second <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   void fast() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);   }   long long max(long long num) {     long long max = 1, rem;     while (num > 0) {       rem = num % 10;       num /= 10;       if (rem > max) {         max = rem;       }     }     return max;   }   int main() {     fast();     int n;     cin >> n;     vector<long long> vect(n + 1);     long long i, count = 0;     for (i = 1; i <= n; i++) {       vect[i] = 1;     }     for (i = 10; i <= n; i++) {       vect[i] = vect[i - max(i)] + 1;     }     cout << vect[n] <<   n ;     ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int r, c, x = 0, y, z;     cin >> r >> c;     while (r != 0) {       if (r % 2 != 0) {         for (int i = 0; i < c; i++) {           cout <<  # ;         }         cout <<   n ;       } else {         if (!x) {           for (int i = 0; i < c - 1; i++) {             cout <<  . ;           }           cout <<  # ;           cout <<   n ;           x++;         } else {           cout <<  # ;           for (int i = 0; i < c - 1; i++) {             cout <<  . ;           }           cout <<   n ;           x = 0;         }       }       r = r - 1;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     vector<long long> tmp;     int n, k;     cin >> n >> k;     long long mas[n], ans = 0;     for (int i = 0; i < (int)(n); ++i) cin >> mas[i];     vector<pair<long long, long long> > ext;     string s;     cin >> s;     for (int i = 0; i < (int)(s.length()); ++i) {       ext.push_back(make_pair(mas[i], s[i]));     }     for (long long i = 0; i < s.length(); i++) {       long long start = i, loop = k;       while (s[i] == s[i + 1] && i < s.length() - 1) i++;       for (long long j = start; j <= i; j++) {         tmp.push_back(ext[j].first);       }       sort(tmp.begin(), tmp.end());       for (long long i = tmp.size() - 1; i >= 0; i--) {         ans += tmp[i];         loop--;         if (loop <= 0) break;       }       tmp.clear();     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   char Puz[105][105], ch;   bool flag[105][105], ok;   int i, j, k, n, m;   int main() {     scanf( %d%d , &n, &m);     scanf( %c , &ch);     for (i = 1; i <= n; i++) {       for (j = 1; j <= m; j++) {         scanf( %c , &ch);         Puz[i][j] = ch;       }       scanf( %c , &ch);     }     memset(flag, 0, sizeof(flag));     for (i = 1; i <= n; i++)       for (j = 1; j <= m; j++)         if (!flag[i][j]) {           ch = Puz[i][j];           ok = true;           for (k = 1; k <= n; k++)             if (k != i && Puz[k][j] == ch) {               ok = false;               flag[k][j] = false;             }           for (k = 1; k <= m; k++)             if (k != j && Puz[i][k] == ch) {               ok = false;               flag[i][k] = false;             }           flag[i][j] = ok;         }     for (i = 1; i <= n; i++)       for (j = 1; j <= m; j++)         if (flag[i][j]) printf( %c , Puz[i][j]);     printf(  n );   }
#include <bits/stdc++.h>   using namespace std;   template <typename T1, typename T2>   inline void chmin(T1& a, T2 b) {     if (a > b) a = b;   }   template <typename T1, typename T2>   inline void chmax(T1& a, T2 b) {     if (a < b) a = b;   }   const long long MOD = 998244353;   const long long MAX = 200060;   const long double pi = acos(-1);   const long double EPS = 1e-12;   long long fac[MAX], finv[MAX], inv[MAX];   void COMinit() {     fac[0] = fac[1] = 1;     finv[0] = finv[1] = 1;     inv[1] = 1;     for (long long i = 2; i < MAX; i++) {       fac[i] = fac[i - 1] * i % MOD;       inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;       finv[i] = finv[i - 1] * inv[i] % MOD;     }   }   long long COM(long long n, long long k) {     if (n < k) return 0;     if (n < 0 || k < 0) return 0;     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;   }   long long add(long long x, long long y) {     x += y;     if (x >= MOD) return x - MOD;     return x;   }   long long sub(long long x, long long y) {     x -= y;     if (x < 0) return x + MOD;     return x;   }   long long mult(long long x, long long y) { return (x * y) % MOD; }   long long bin_pow(long long x, long long p) {     if (p == 0) return 1;     if (p & 1) return mult(x, bin_pow(x, p - 1));     return bin_pow(mult(x, x), p / 2);   }   vector<long long> G[200020];   long long dfs(long long n, long long pre) {     long long res = 1;     res = mult(res, fac[G[n].size()]);     for (auto nex : G[n]) {       if (nex == pre) continue;       res = mult(res, dfs(nex, n));     }     return res;   }   void solve() {     long long N;     cin >> N;     COMinit();     for (long long i = 0; i < N - 1; i++) {       long long u, v;       cin >> u >> v;       u--, v--;       G[u].push_back(v);       G[v].push_back(u);     }     long long ans = dfs(0, 0);     ans = mult(ans, N);     cout << ans <<   n ;   }   signed main() {     cin.tie(0);     ios::sync_with_stdio(false);     solve();   }
#include <bits/stdc++.h>   using namespace std;   long long int n, a[100] = {}, r = 0, s = 0, m;   int main() {     ios_base::sync_with_stdio(0);     for (long long int i = 1; i <= 5; i++) {       cin >> m;       a[m]++;       s += m;       if (a[m] == 2 || a[m] == 3) r = max(r, m * a[m]);     }     cout << s - r;     return 0;   }
#include <bits/stdc++.h>   const int BUFFSIZE = 10240;   char BUFF[BUFFSIZE + 1], *p = BUFF;   int CHAR, SIGN, BYTES = 0;   using namespace std;   char s1[(int)1e6 + 10];   char s2[(int)1e6 + 10];   vector<int> buf[26];   int main() {     scanf( %s %s , s1, s2);     int l1 = strlen(s1);     int l2 = strlen(s2);     for (int i = 0; i < l1; i++) buf[s1[i] -  a ].push_back(i);     bool f = 1;     for (int i = 0; i < l2; i++)       if ((int)buf[s2[i] -  a ].size() == 0) {         f = false;         break;       }     if (!f)       printf( -1 n );     else {       int ret = 1;       int pos = -1;       for (int j = 0; j < l2; j++) {         char c = s2[j] -  a ;         vector<int>::iterator it;         it = upper_bound(buf[c].begin(), buf[c].end(), pos);         if (it != buf[c].end())           pos = *it;         else {           ret += 1;           pos = buf[c][0];         }       }       printf( %d n , ret);     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 30;   struct Node {     int pos, val;     bool operator<(const Node& a) const { return val < a.val; }   } p[maxn];   int ans[maxn];   int n;   int main() {     cin >> n;     for (int i = 1; i <= n; ++i) cin >> p[i].val, p[i].pos = i;     sort(p + 1, p + n + 1);     for (int i = 2; i <= n; ++i) ans[p[i].pos] = p[i - 1].val;     ans[p[1].pos] = p[n].val;     for (int i = 1; i <= n; ++i) printf( %d  , ans[i]);     puts(  );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   constexpr int N = 3e3 + 1;   int a[N], nxt[N], prv[N], lst[N];   uint16_t dp[N][N];   int main() {     cin.tie(0), ios::sync_with_stdio(0);     int t, n;     cin >> t;     while (t--) {       cin >> n;       for (int i = 0; i < n; ++i) {         cin >> a[i], --a[i];       }       memset(lst, -1, n * sizeof *lst);       n = unique(a, a + n) - a;       memset(prv, -1, n * sizeof *prv);       memset(nxt, 127, n * sizeof *nxt);       for (int i = 0; i < n; ++i) {         if (lst[a[i]] != -1) {           prv[i] = lst[a[i]];           nxt[lst[a[i]]] = i;         }         lst[a[i]] = i;       }       for (int i = n - 1; i > -1; --i)         for (int j = i + 1; j < n; ++j) {           auto t = dp[i + 1][j];           for (int z = nxt[i]; z <= j; z = nxt[z]) {             t = max(t, uint16_t(dp[i + 1][z - 1] + dp[z][j] + 1));           }           dp[i][j] = t;         }       cout << n - dp[0][n - 1] - 1 <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   pair<int, int> T[4 * 200005];   void update(int n, int b, int e, int p, int v) {     if (b == p && e == p) {       T[n] = make_pair(v, p);     } else {       int m = (b + e) / 2;       if (p <= m)         update(2 * n, b, m, p, v);       else         update(2 * n + 1, m + 1, e, p, v);       T[n] = max(T[2 * n], T[2 * n + 1]);     }   }   pair<int, int> query(int n, int b, int e, int l, int r) {     if (b == l && e == r) {       return T[n];     } else {       int m = (b + e) / 2;       if (m >= r) return query(2 * n, b, m, l, r);       if (l > m) return (query(2 * n + 1, m + 1, e, l, r));       return max(query(2 * n, b, m, l, m), query(2 * n + 1, m + 1, e, m + 1, r));     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int n;     cin >> n;     vector<pair<pair<int, int>, int> > arr(n);     vector<pair<int, int> > ori(n);     int a, b;     for (int i = 0; i < n; i++) {       cin >> a >> b;       arr[i] = make_pair(make_pair(a, b), i);       ori[i] = make_pair(a, b);     }     sort(arr.begin(), arr.end());     priority_queue<pair<int, int> > q;     vector<int> result1(n);     vector<int> result2(n);     int index = 0;     map<int, int> comp;     for (int i = 1; i <= n; i++) {       while (index < n && arr[index].first.first == i) {         q.push(make_pair(-1 * arr[index].first.second, arr[index].second));         index++;       }       pair<int, int> current = q.top();       q.pop();       result1[current.second] = i;       comp[i] = current.second;     }     for (int i = 0; i < n; i++) {       result2[i] = result1[i];     }     bool one = true;     for (int i = 1; i <= n; i++) {       int l = ori[comp[i]].first;       int r = ori[comp[i]].second;       pair<int, int> res = query(1, 0, 200005, l, r);       if (res.first >= i) {         one = false;         result2[comp[i]] = result1[comp[res.second]];         result2[comp[res.second]] = result1[comp[i]];         break;       }       update(1, 0, 200005, i, r);     }     if (one) {       cout <<  YES  <<   n ;       for (int i = 0; i < n; i++) {         cout << result1[i] <<    ;       }       cout <<   n ;     } else {       cout <<  NO  <<   n ;       for (int i = 0; i < n; i++) {         cout << result1[i] <<    ;       }       cout <<   n ;       for (int i = 0; i < n; i++) {         cout << result2[i] <<    ;       }       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC target( sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx )   const int N = (int)5e5 + 7, inf = (int)1e9 + 7, mod = (int)1e9 + 7;   const long long linf = (long long)1e18 + 7;   const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1},             dy[] = {0, 1, 0, -1, 1, -1, 1, -1};   using namespace std;   int n;   int main() {     ios_base ::sync_with_stdio(0), cin.tie(0), cout.tie(0);     cin >> n;     int l = 0, r = 0;     for (int i = 1; i <= n; i++) {       int x, y;       cin >> x >> y;       if (x < 0) l++;       if (x > 0) r++;     }     if (max(l, r) >= n - 1)       cout <<  Yes ;     else       cout <<  No ;     exit(0);   }
#include <bits/stdc++.h>   using namespace std;   int h, q;   char s[10];   unordered_map<int, int> a;   double ans;   void add(int v, int x) {     if (a.count(v) == 0)       a[v] = x;     else       a[v] += x;     return;   }   void addToRoot(int v, int x) {     while (v > 0) {       add(v, x);       v >>= 1;     }     return;   }   int getVal(int v) {     if (a.count(v) == 0) return 0;     return a[v];   }   void solve(int v, double p, int prevMax) {     if (v >= (1 << h)) {       ans += p * getVal(v);       return;     }     int curVal = getVal(v);     int leftVal = getVal(2 * v), rightVal = getVal(2 * v + 1);     p /= 2;     if (leftVal * 2 <= curVal || leftVal <= prevMax)       ans += p * max(prevMax, curVal - leftVal);     else       solve(2 * v, p, max(prevMax, curVal - leftVal));     if (rightVal * 2 <= curVal || rightVal <= prevMax)       ans += p * max(prevMax, curVal - rightVal);     else       solve(2 * v + 1, p, max(prevMax, curVal - rightVal));     return;   }   double getAns() {     ans = 0;     solve(1, 1, -1);     return ans;   }   int main() {     scanf( %d%d , &h, &q);     while (q--) {       scanf(  %s  , s);       if (s[0] ==  a ) {         int v, x;         scanf( %d%d , &v, &x);         addToRoot(v, x);       } else         printf( %.12lf n , getAns());     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long n, m, x = 0, y, i = 1;     cin >> n >> m;     if (!m) {       cout << n <<     << n;       return 0;     }     y = (n - 2 * m);     if (y < 0) y = 0;     n--;     while (x < m && n > 0) {       x += i;       i++;       n--;     }     cout << y <<     << n;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 322228;   long long a[N];   int n, k;   int cou[N];   bool solve(int l, int r) {     long long need = cou[l % k];     long long tl = l - k >= 0 ? a[l - k] + 1 : -1000000000000ll;     long long tr = r + k < n ? a[r + k] - 1 : 1000000000000ll;     if (tr - tl + 1 < need) return 0;     if (tl >= 0) {       for (long long i = tl; i < tl + need; i++) a[l + (i - tl) * k] = i;     } else if (tr <= 0) {       for (long long i = tr; i > tr - need; i--) a[r - (tr - i) * k] = i;     } else {       long long ttl = 0, ttr = need - 1;       while (ttl - 1 >= tl && (abs(ttl - 1) <= abs(ttr) || ttr > tr))         ttl--, ttr--;       for (int i = 0; i < need; i++) a[l + i * k] = ttl + i;     }     return 1;   }   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> k;     int tn = ((n - 1) / k + 2) * k;     for (int i = 0; i < tn; i++) {       string s;       if (i < n)         cin >> s;       else if (i < tn - k)         s =  1000000000000 ;       else         s =  1000000000001 ;       if (s ==  ? ) {         cou[i % k]++;       } else {         a[i] = atoll(s.c_str());         if (cou[i % k]) {           if (!solve(i - k * cou[i % k], i - k))             return cout <<  Incorrect sequence , 0;           cou[i % k] = 0;         } else if (i - k >= 0 && a[i] <= a[i - k])           return cout <<  Incorrect sequence , 0;       }     }     for (int i = 0; i < n; i++) cout << a[i] <<    ;   }