malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e13;   void solve() {     long long n;     cin >> n;     vector<pair<long long, long long> > a(n);     for (long long i = 0; i < n; i++) {       cin >> a[i].first;       a[i].second = i;     }     sort(a.begin(), a.end());     long long cnt = 1, ans = 1, w = 1;     for (long long i = 1; i < n; i++) {       if (a[i].first == a[i - 1].first) continue;       w++;       if (a[i].second > a[i - 1].second)         cnt++;       else {         ans = max(ans, cnt);         cnt = 1;       }     }     ans = max(ans, cnt);     cout << w - ans <<   n ;   }   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long q;     cin >> q;     while (q--) solve();   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int tosub = 0;     int pls = 1;     int mins = 0;     string s;     char a;     cin >> a;     while (a !=  = ) {       if (a ==  + ) {         s.push_back(a);         pls++;       } else if (a ==  - ) {         mins++;         s.push_back(a);       }       cin >> a;     }     int tmp;     cin >> tmp;     int mn = pls - mins * tmp;     int mx = pls * tmp - mins;     if (tmp < mn || tmp > mx) {       cout <<  Impossible n ;       return 0;     }     cout <<  Possible n ;     int curr = 0;     for (int i = (-1); i < (int)s.size(); ++i) {       if (!(~i) || s[i] ==  + ) {         if (i >= 0) {           cout << s[i] <<    ;         }         for (int j = 1; j <= tmp; ++j) {           int mn = (pls - 1) - mins * tmp;           int mx = (pls - 1) * tmp - mins;           if (mn <= tmp - (curr + j) && mx >= tmp - (curr + j)) {             cout << j <<    ;             pls--;             curr += j;             break;           }         }       } else {         cout << s[i] <<    ;         for (int j = 1; j <= tmp; ++j) {           int mn = pls - (mins - 1) * tmp;           int mx = pls * tmp - (mins - 1);           if (mn <= tmp - (curr - j) && mx >= tmp - (curr - j)) {             cout << j <<    ;             mins--;             curr -= j;             break;           }         }       }     }     cout <<   =   << tmp <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline const int read() {     int r = 0, k = 1;     char c = getchar();     for (; c <  0  || c >  9 ; c = getchar())       if (c ==  - ) k = -1;     for (; c >=  0  && c <=  9 ; c = getchar()) r = r * 10 + c -  0 ;     return k * r;   }   long long n;   int k, a[110];   bool vis[1000010];   long long dp[110][100000];   long long dfs(int pos, long long n) {     if (pos == k + 1) return n;     if (n <= 0) return 0;     if (n < 100000 && dp[pos][n] != -1) return dp[pos][n];     long long ans = dfs(pos + 1, n) - dfs(pos + 1, n / a[pos]);     if (n < 100000) dp[pos][n] = ans;     return ans;   }   void input() {     memset(dp, -1, sizeof(dp));     cin >> n >> k;     for (int i = (1), _ = (k); i <= _; i++) a[i] = read();     sort(a + 1, a + k + 1, greater<int>());   }   void solve() { cout << dfs(1, n) << endl; }   int main() {     input(), solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   int k;   string s, t;   int dp[100005][2], cnt[2];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> s >> t;     cin >> k;     int n = s.length();     for (int i = 1; i < n; i++) {       int l = n - i;       string tmp = s.substr(i, l) + s.substr(0, i);       if (tmp == t)         cnt[0]++;       else         cnt[1]++;     }     if (s == t)       dp[0][0]++, cnt[0]++;     else       dp[0][1]++, cnt[1]++;     for (int i = 1; i <= k; i++) {       dp[i][0] =           (dp[i - 1][0] * 1ll * (cnt[0] - 1) + dp[i - 1][1] * 1ll * cnt[0]) % mod;       dp[i][1] =           (dp[i - 1][0] * 1ll * cnt[1] + dp[i - 1][1] * 1ll * (cnt[1] - 1)) % mod;     }     printf( %d n , dp[k][0]);   }
#include <bits/stdc++.h>   using namespace std;   long long ar[1000000 + 9];   long long POW1[1000000 + 9];   long long POW2[1000000 + 9];   pair<long long, long long> KEEP[1000000 + 9];   map<pair<long long, long long>, long long> mymap;   struct data {     long long a, b, val;   };   vector<data> vec;   long long query(int beg, int end) {     if (beg == end) return 0;     int mid = (beg + end) >> 1;     long long ans, i, val, a, b, len;     ans = query(beg, mid) + query(mid + 1, end);     vec.clear();     mymap.clear();     for (i = mid; i >= beg; i--) {       if (vec.size() && vec[vec.size() - 1].val == ar[i]) {         vec.pop_back();         a = 0;         b = 0;         if (vec.size()) a = vec[vec.size() - 1].a;         if (vec.size()) b = vec[vec.size() - 1].b;       } else {         a = 0;         b = 0;         if (vec.size()) a = vec[vec.size() - 1].a;         if (vec.size()) b = vec[vec.size() - 1].b;         len = vec.size() + 1;         a += ar[i] * POW1[len];         b += ar[i] * POW2[len];         a %= 1000000007;         b %= 1000000007;         data curr;         curr.a = a;         curr.b = b;         curr.val = ar[i];         vec.push_back(curr);       }       val = mymap[make_pair(a, b)];       mymap[make_pair(a, b)] = val + 1;     }     vec.clear();     for (i = mid + 1; i <= end; i++) {       if (vec.size() && vec[vec.size() - 1].val == ar[i]) {         vec.pop_back();         a = 0;         b = 0;         if (vec.size()) a = vec[vec.size() - 1].a;         if (vec.size()) b = vec[vec.size() - 1].b;       } else {         a = 0;         b = 0;         if (vec.size()) a = vec[vec.size() - 1].a;         if (vec.size()) b = vec[vec.size() - 1].b;         len = vec.size() + 1;         a += ar[i] * POW1[len];         b += ar[i] * POW2[len];         a %= 1000000007;         b %= 1000000007;         data curr;         curr.a = a;         curr.b = b;         curr.val = ar[i];         vec.push_back(curr);       }       val = mymap[make_pair(a, b)];       ans += val;     }     return ans;   }   int main() {     long long i, j, k, l, n, m = 0, tot, temp, curr, val, prev, a, b, c, t, ans,                              expon, flag, x, y, siz, w, h, d, ii, jj, xx, yy, ind,                              len, max_n, q, s, f, g;     POW1[0] = POW2[0] = 1;     for (i = 1; i <= 1000000; i++) POW1[i] = (POW1[i - 1] * 31) % 1000000007;     for (i = 1; i <= 1000000; i++) POW2[i] = (POW2[i - 1] * 37) % 1000000007;     cin >> q;     while (q--) {       scanf( %lld , &n);       for (i = 1; i <= n; i++) scanf( %lld , &ar[i]);       ans = query(1, n);       printf( %lld n , ans);     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100 + 23, maxm = 30000;   int n, K, a[maxn], w[maxn], F[maxn][maxm + 10000];   int main() {     scanf( %d%d , &n, &K);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     for (int i = 1; i <= n; i++) scanf( %d , &w[i]), w[i] = a[i] - w[i] * K;     memset(F, -1, sizeof(F));     F[0][15000] = 0;     for (int i = 1; i <= n; i++) {       for (int j = 0; j <= maxm; j++) {         if (F[i - 1][j] >= 0) F[i][j] = max(F[i][j], F[i - 1][j]);         if (F[i - 1][j - w[i]] >= 0)           F[i][j] = max(F[i][j], F[i - 1][j - w[i]] + a[i]);       }     }     printf( %d n , (F[n][15000] <= 0) ? (-1) : (F[n][15000]));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 10;   const long long INF = (long long)1e17 + 10;   int n, m, s, t;   int a[N], b[N], l[N];   struct edge {     int to, cost;     edge(int to, int cost) : to(to), cost(cost) {}   };   vector<edge> e;   vector<int> g[N];   vector<int> g2[N];   long long diss[N], dist[N];   long long len;   bool vis[N], ans[N];   map<int, long long> mp;   set<pair<pair<long long, long long>, int> > st;   void dijkstra(int sc, vector<int> g[N], long long *dis) {     fill(dis + 1, dis + n + 1, INF);     priority_queue<pair<long long, int> > pq;     pq.push(make_pair(0, sc));     memset(vis, 0, sizeof(vis));     while (!pq.empty()) {       pair<long long, int> tmp = pq.top();       pq.pop();       if (vis[tmp.second]) continue;       vis[tmp.second] = 1;       dis[tmp.second] = -tmp.first;       for (auto j : g[tmp.second]) {         int u = e[j].to;         int c = e[j].cost;         if (vis[u]) continue;         pair<long long, int> nxt = make_pair(-dis[tmp.second] - c, u);         pq.push(nxt);       }     }   }   int main() {     scanf( %d%d%d%d , &n, &m, &s, &t);     for (int i = 0; i < m; ++i) {       scanf( %d%d%d , a + i, b + i, l + i);       g[a[i]].push_back(e.size());       e.push_back(edge(b[i], l[i]));       g2[b[i]].push_back(e.size());       e.push_back(edge(a[i], l[i]));     }     dijkstra(s, g, diss);     dijkstra(t, g2, dist);     len = diss[t];     for (int i = 0; i < m; ++i) {       if (diss[a[i]] + dist[b[i]] + l[i] == len) {         st.insert(make_pair(make_pair(diss[a[i]], diss[b[i]]), i));         ans[i] = 1;       }     }     long long mx = 0;     for (auto k : st) {       mp[k.second] = mx;       mx = max(k.first.second, mx);     }     for (int i = 0; i < m; ++i) {       if (diss[a[i]] + dist[b[i]] + l[i] == len) {         st.erase(make_pair(make_pair(diss[a[i]], diss[b[i]]), i));         auto it = st.lower_bound(make_pair(make_pair(diss[a[i]], -1), -1));         if (!(it == st.end() || it->first.first == diss[b[i]])) {           ans[i] = 0;         }         if (mp[i] > diss[a[i]]) {           ans[i] = 0;         }         st.insert(make_pair(make_pair(diss[a[i]], diss[b[i]]), i));       }     }     for (int i = 0; i < m; ++i) {       if (ans[i]) {         puts( YES );       } else {         long long mn = diss[a[i]] + dist[b[i]];         if (len - 1 > mn) {           printf( CAN %d n , l[i] - (len - 1 - mn));         } else {           puts( NO );         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = INT_MAX;   const long long INFL = LLONG_MAX;   int N, M, X[1000], a, b, c;   int main() {     ios_base::sync_with_stdio(0);     cout.precision(15);     cin >> N >> M;     for (int(i) = 1; (i) <= (N); (i)++) cin >> X[i];     long double answer = 0;     for (int(i) = 1; (i) <= (M); (i)++) {       cin >> a >> b >> c;       answer = max(answer, (long double)(X[a] + X[b]) / c);     }     cout << answer << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, l = 1, a;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a;       if (l == 1) {         if (a % 2 == 1) {           cout << 2 << endl;           l = 1;         } else {           l = 2;           cout << 1 << endl;         }         continue;       }       if (l == 2) {         if (a % 2 == 1) {           l = 2;           cout << 1 << endl;         } else {           l = 1;           cout << 2 << endl;         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAXQ = 2e5;   vector<int> solve(int K, vector<tuple<uint32_t, uint32_t, int> > V) {     uint32_t mask = (((uint32_t)1) << K) - 1;     vector<int> HT(1 << K), LT(1 << K);     for (auto [l, r, v] : V)       if (v) {         uint32_t lhi = l >> K, llo = l & mask;         uint32_t rhi = r >> K, rlo = r & mask;         if (lhi == rhi) {           LT[llo]++;           if (rlo != ((1 << K) - 1)) LT[rlo + 1]--;         } else {           LT[llo]++;           LT[0]++;           if (rlo != ((1 << K) - 1)) LT[rlo + 1]--;         }         HT[lhi]++;         if (rhi != ((1 << K) - 1)) HT[rhi + 1]--;       }     for (int i = 0; i < (1 << K) - 1; ++i) HT[i + 1] += HT[i];     for (int i = 0; i < (1 << K); ++i)       if (HT[i]) HT[i] = 1;     for (int i = 0; i < (1 << K) - 1; ++i) LT[i + 1] += LT[i];     for (int i = 0; i < (1 << K); ++i)       if (LT[i]) LT[i] = 1;     auto ans = LT;     copy(HT.begin(), HT.end(), back_inserter(ans));     for (int i = 0; i < (1 << K) - 1; ++i) HT[i + 1] += HT[i];     for (int i = 0; i < (1 << K) - 1; ++i) LT[i + 1] += LT[i];     auto SH = [&](int L, int R) {       int ans = HT[R];       if (L) ans -= HT[L - 1];       return ans;     };     auto SL = [&](int L, int R) {       int ans = LT[R];       if (L) ans -= LT[L - 1];       return ans;     };     for (auto [l, r, v] : V)       if (!v) {         uint32_t lhi = l >> K, llo = l & mask;         uint32_t rhi = r >> K, rlo = r & mask;         if (lhi == rhi) {           if (SH(lhi, lhi) != 0 && SL(llo, rlo) != 0) return {};         } else {           if (SH(lhi, lhi) != 0 && SL(llo, (1 << K) - 1) != 0) return {};           if (SH(lhi + 1, rhi - 1) != 0 && SL(0, (1 << K) - 1) != 0) return {};           if (SH(rhi, rhi) != 0 && SL(0, rlo) != 0) return {};         }       }     return ans;   }   int K, Q;   uint32_t L[MAXQ], R[MAXQ], V[MAXQ];   int main() {     scanf( %d%d , &K, &Q);     for (int i = 0; i < Q; ++i) {       scanf( %  SCNu32  %  SCNu32  %  SCNu32, L + i, R + i, V + i);     }     vector<vector<int> > ans(16);     for (int i = 0; i < 16; ++i) {       vector<tuple<uint32_t, uint32_t, int> > P;       for (int j = 0; j < Q; ++j) P.emplace_back(L[j], R[j], (V[j] >> i) & 1);       ans[i] = solve(K, P);       if (ans[i].size() == 0) {         puts( impossible );         return 0;       }     }     puts( possible );     for (int i = 0; i < (2 << K); ++i) {       int r = 0;       for (int j = 0; j < 16; ++j)         if (ans[j][i]) r |= 1 << j;       printf( %d n , r);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int rmax = 15;   const int nmax = 100500;   struct DP {     int x;     int y;     int z;     int i;     int j;     int k;   };   bool operator<(const DP& l, const DP& r) {     return l.x < r.x || (l.x == r.x && l.y < r.y) ||            (l.x == r.x && l.y == r.y && l.z < r.z);   }   class SparseTable {    public:     SparseTable(vector<pair<int, int> >& vals) {       N = vals.size();       sparse.assign(N, vector<pair<int, int> >(rmax));       init();       build(vals);     }     void build(vector<pair<int, int> >& vals) {       for (int i = 0; i < vals.size(); ++i) {         sparse[i][0] = vals[i];       }       for (int r = 1; r < rmax; ++r) {         for (int i = 0; i < N; ++i) {           int t = min(N - 1, i + (1 << (r - 1)));           sparse[i][r] = max(sparse[i][r - 1], sparse[t][r - 1]);         }       }     }     pair<int, int> getMax(int l, int r) {       int len = r - l + 1;       int k = deg[len];       return max(sparse[l][k], sparse[l + len - (1 << k)][k]);     }     void init() {       deg.assign(nmax, 0);       deg[0] = -1;       for (int i = 1; i < nmax; ++i) {         deg[i] = deg[i - 1];         if (!(i & (i - 1))) {           ++deg[i];         }       }     }       private:     vector<vector<pair<int, int> > > sparse;     int N = 0;     vector<int> deg;   };   int main() {     ios_base::sync_with_stdio(false);     int n;     cin >> n;     vector<int> vec(n);     vector<pair<int, int> > a;     for (int i = 0; i < n; ++i) {       cin >> vec[i];       a.push_back({vec[i], i});     }     sort((a).begin(), (a).end());     vector<pair<int, int> > vals;     vals.push_back({a[0].first, 0});     for (int i = 1; i < n; ++i) {       vals.push_back({a[i].first - a[i - 1].first, i});     }     SparseTable st(vals);     DP ret;     ret.x = -1;     ret.y = -1;     ret.z = -1;     ret.i = 0;     ret.j = 0;     ret.k = 0;     for (int i = n - 1; i >= 0; --i) {       for (int j = i - 1; j >= 0; --j) {         int len_a = n - 1 - i + 1;         int len_b = i - 1 - j + 1;         if (len_a > 2 * len_b || len_b > 2 * len_a) {           continue;         }         int max_len_c = min({j, 2 * len_a, 2 * len_b});         int min_len_c = max({1, (len_a + 1) / 2, (len_b + 1) / 2});         if (max_len_c < min_len_c) {           continue;         }         pair<int, int> p = st.getMax(j - max_len_c, j - min_len_c);         DP temp;         temp.x = a[i].first - a[i - 1].first;         temp.y = a[j].first - a[j - 1].first;         temp.z = p.first;         temp.i = i;         temp.j = j;         temp.k = p.second;         if (ret < temp) {           ret = temp;         }       }     }     vector<int> ans(n);     for (int i = 0; i < ret.k; ++i) {       ans[a[i].second] = -1;     }     for (int i = ret.k; i < ret.j; ++i) {       ans[a[i].second] = 3;     }     for (int i = ret.j; i < ret.i; ++i) {       ans[a[i].second] = 2;     }     for (int i = ret.i; i < n; ++i) {       ans[a[i].second] = 1;     }     for (int i = 0; i < n; ++i) {       cout << ans[i] <<    ;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC target( sse4,avx )   const int inf = 100000;   int rec(size_t gl, std::vector<int>& odd, std::vector<bool>& flags,           std::vector<std::vector<int>>& graph) {     if (gl == odd.size()) {       return 0;     }     if (flags[gl]) {       return rec(gl + 1, odd, flags, graph);     }     int res = 1000000000;     for (size_t i = gl + 1; i < odd.size(); i++) {       if (!flags[i]) {         flags[i] = true;         res = std::min(res,                        graph[odd[gl]][odd[i]] + rec(gl + 1, odd, flags, graph));         flags[i] = false;       }     }     return res;   }   void run(std::istream& in, std::ostream& out) {     int n, m;     in >> n >> m;     std::vector<std::vector<int>> graph(n, std::vector<int>(n, inf));     for (int i = 0; i < n; i++) graph[i][i] = 0;     std::vector<int> degs(n);     int64_t sum = 0;     for (int i = 0; i < m; i++) {       int x, y, w;       in >> x >> y >> w;       x--;       y--;       degs[x]++;       degs[y]++;       sum += w;       graph[x][y] = std::min(graph[x][y], w);       graph[y][x] = std::min(graph[y][x], w);     }     for (size_t i = 0; i < n; i++) {       for (size_t j = 0; j < n; j++) {         for (size_t k = 0; k < n; k++) {           if (graph[j][k] > graph[j][i] + graph[i][k]) {             graph[j][k] = graph[j][i] + graph[i][k];           }         }       }     }     for (size_t i = 0; i < n; i++) {       if (graph[0][i] == inf && degs[i] != 0) {         out <<  -1  << std::endl;         return;       }     }     std::vector<int> odd;     for (size_t i = 0; i < n; i++) {       if ((degs[i] % 2) != 0) {         odd.push_back(i);       }     }     std::vector<bool> flags(odd.size());     sum += rec(0, odd, flags, graph);     out << sum << std::endl;   }   int main() {     std::cin.sync_with_stdio(false);     std::cin.tie(nullptr);     run(std::cin, std::cout);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void Oli() {     int a;     cin >> a;     vector<pair<int, int>> pr(a);     for (int i = 0; i < a; i++) {       cin >> pr[i].first >> pr[i].second;     }     int s = 0;     int k = 1;     for (int i = 0; i < pr.size(); i++) {       if (pr[i].second >= 1) {         k--;         k += pr[i].second;         s += pr[i].first;         pr.erase(pr.begin() + i);         i--;       }     }     sort(pr.rbegin(), pr.rend());     int i = 0;     while (k > 0 && i < pr.size()) {       s += pr[i].first;       i++;       k--;     }     cout << s << endl;   }   int main() {     int t = 1;     while (t--) {       Oli();     }     return 0;   }
#include <bits/stdc++.h>   int loya[8];   int tloyal[8];   int level[8];   double pb[1 << 8];   int N, K, A;   void init_search(int state, int B, int deepth, int cnt) {     if (deepth == N) {       pb[state] = cnt > (N >> 1) ? 1.0 : A / (double)(A + B);     } else {       init_search(state | (1 << deepth), B, deepth + 1, cnt + 1);       init_search(state, B + level[deepth], deepth + 1, cnt);     }   }   double calcu(double prb, int state, int deepth) {     return (deepth == N)                ? prb * pb[state]                : calcu(prb * (tloyal[deepth] / 10.0), state | (1 << deepth),                        deepth + 1) +                      calcu(prb * (1 - tloyal[deepth] / 10.0), state, deepth + 1);   }   double search(int candy, int deepth) {     double ans = 0.0;     if (deepth == N) {       ans = calcu(1.0, 0, 0);     } else {       int i;       for (i = 0; i <= candy && loya[deepth] + i <= 10; i++) {         tloyal[deepth] = loya[deepth] + i;         double tmp = search(candy - i, deepth + 1);         ans = tmp > ans ? tmp : ans;       }     }     return ans;   }   int main() {     while (scanf( %d %d %d , &N, &K, &A) == 3) {       int i;       for (i = 0; i < N; i++) {         scanf( %d %d , level + i, loya + i);         loya[i] /= 10;       }       init_search(0, 0, 0, 0);       printf( %.10f n , search(K, 0));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long h, n;   long long ret = 0LL;   int a[60];   long long two(int x) {     if (x == 0) return 1LL;     long long half = two(x / 2);     half *= half;     return x % 2 ? half * 2 : half;   }   void solve() {     int c = 0;     --n;     while (n) {       a[c++] = n % 2;       n >>= 1;     }     for (int i = c; i < h; ++i) a[i] = 0;     int e = 0;     for (int i = h - 1; i >= 0; --i) {       if (a[i] != e) {         ret += two(i + 1);       }       if (a[i] == e) {         ret += 1;         e = !e;       }     }     cout << ret << endl;   }   int main() {     cin >> h >> n;     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k, a[101], m, ans;   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> k;       if (k % 2) a[++m] = k;       ans += k;     }     if (m == 0) {       cout << 0 << endl;       return 0;     }     if (m % 2 == 0) {       sort(a + 1, a + m + 1);       ans -= a[1];     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, k;   int a[100010];   struct node {     int x, id;   } p[100010];   int main() {     while (scanf( %d%d , &n, &k) != EOF) {       for (int i = 1; i <= n; i++) {         scanf( %d , &a[i]);       }       int ans = 99999999;       int pos = 1;       for (int i = 1; i <= n; i++) {         bool flag = false;         int cnt = 0;         for (int j = i; j >= 1; j--) {           if (a[i] - (i - j) * k == a[j]) continue;           cnt++;           if (a[i] - (i - j) * k <= 0) {             flag = true;             break;           }         }         if (flag) continue;         int cnt1 = 0;         for (int j = i; j <= n; j++) {           if (a[i] + (j - i) * k == a[j]) continue;           cnt1++;         }         if (cnt1 + cnt < ans) {           ans = cnt1 + cnt;           pos = i;         }       }       printf( %d n , ans);       for (int j = 1; j <= pos; j++) {         if (a[j] + (pos - j) * k == a[pos]) continue;         if (a[j] < a[pos] - (pos - j) * k) {           printf( + %d %d n , j, a[pos] - (pos - j) * k - a[j]);         } else {           printf( - %d %d n , j, a[j] - (a[pos] - (pos - j) * k));         }       }       for (int j = pos; j <= n; j++) {         if (a[pos] + (j - pos) * k == a[j]) continue;         if (a[j] < a[pos] + (j - pos) * k) {           printf( + %d %d n , j, a[pos] + (j - pos) * k - a[j]);         } else {           printf( - %d %d n , j, a[j] - (a[pos] + (j - pos) * k));         }       }     }     return 0;   }