malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   vector<int> G[500005];   void solve() {     int n, m, i, a, b;     cin >> n >> m;     vector<pair<int, int>> topics(n + 1);     vector<int> assigned(n + 1, 1);     vector<bool> done(n + 1, 0);     for (i = 0; i < m; ++i) {       cin >> a >> b;       G[a].push_back(b);       G[b].push_back(a);     }     for (i = 1; i <= n; ++i) {       cin >> topics[i].first;       topics[i].second = i;     }     sort(topics.begin() + 1, topics.end());     for (i = 1; i <= n; ++i) {       if (assigned[topics[i].second] != topics[i].first) {         cout << -1 << endl;         return;       }       done[topics[i].second] = 1;       for (int child : G[topics[i].second]) {         if (!done[child] && assigned[child] == assigned[topics[i].second])           assigned[child] = assigned[topics[i].second] + 1;       }     }     for (i = 1; i <= n; ++i) cout << topics[i].second <<    ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     solve();   }
#include <bits/stdc++.h>   using namespace std;   long long a, b, c, d, e, i, j, n;   int main() {     map<string, long long> m, m1;     cin >> a >> b;     string s;     for (i = 1; i <= a; i++) {       cin >> s;       m[s]++;     }     d = b;     for (i = 1; i <= b; i++) {       cin >> s;       if (m[s] > 0) {         n++;         a--;         d--;         m[s]--;       }     }     if (n % 2 == 1) {       if (d > a)         cout <<  NO ;       else         cout <<  YES ;     } else {       if (a > d)         cout <<  YES ;       else         cout <<  NO ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int y1, m1, d1, y2, m2, d2;     scanf( %d:%d:%d n%d:%d:%d , &y1, &m1, &d1, &y2, &m2, &d2);     if (m1 < 3) y1--, m1 += 12;     long long ans1 =         365 * y1 + y1 / 4 - y1 / 100 + y1 / 400 + (153 * m1 - 457) / 5 + d1 - 306;     if (m2 < 3) y2--, m2 += 12;     long long ans2 =         365 * y2 + y2 / 4 - y2 / 100 + y2 / 400 + (153 * m2 - 457) / 5 + d2 - 306;     printf( %lld , (ans1 - ans2) > 0 ? (ans1 - ans2) : (ans2 - ans1));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using pii = pair<int, int>;   const double PI = 4 * atan(1);   const int INF = 0x3f3f3f3f;   const ll LINF = 0x3f3f3f3f3f3f3f3f;   const int MOD = 1e9 + 7;   const int MAX_N = 2e6 + 10;   int n;   int a[MAX_N], b[MAX_N], p[MAX_N];   void solve() {     for (int i = 1; i <= n; ++i) {       p[b[i]] = i;     }     if (p[1]) {       int i = 2;       for (; p[i] == p[1] + i - 1; ++i)         ;       if (p[i - 1] == n) {         int j;         for (j = i; j <= n && p[j] <= j - i; ++j)           ;         if (j > n) {           cout << n - i + 1 <<   n ;           return;         }       }     }     int ans = 0;     for (int i = 1; i <= n; ++i) ans = max(ans, p[i] - i + 1 + n);     cout << ans <<   n ;   }   int main() {     cin >> n;     for (int i = 1; i <= n; ++i) cin >> a[i];     for (int i = 1; i <= n; ++i) cin >> b[i];     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 100 * 1000 * 1000;   int n1, n2, k1, k2;   long long dp[2][101][101];   int solve(int a, int b, int c) {     if (b == 0 || c == 0) {       if (a == 0) {         dp[a][b][c] = (b <= k1);         return dp[a][b][c];       }       dp[a][b][c] = (c <= k2);       return dp[a][b][c];     }     if (dp[a][b][c] != -1) return dp[a][b][c];     long long ret = 0LL;     if (a == 0) {       for (int i = 1; (i <= k1 && i <= b); ++i)         ret = (ret + solve(1, b - i, c)) % MOD;     }     if (a == 1) {       for (int i = 1; (i <= k2 && i <= c); ++i)         ret = (ret + solve(0, b, c - i)) % MOD;     }     dp[a][b][c] = ret;     return dp[a][b][c];   }   int main() {     memset(dp, -1, sizeof(dp));     cin >> n1 >> n2 >> k1 >> k2;     int ans = (solve(0, n1, n2) + solve(1, n1, n2)) % MOD;     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   typedef int (*uniopi)(int);   typedef long long (*uniopl)(long long);   typedef int (*binopi)(int, int);   typedef long long (*binopl)(long long, long long);   typedef int (*tupopi)(int, int, int);   typedef long long (*tupopl)(long long, long long, long long);   const long double PI = acos(0) * 2;   const int INF = 0x3f2f1f0f;   const long long LINF = 1ll * INF * INF;   int X4[] = {-1, 0, 1, 0}, Y4[] = {0, -1, 0, 1};   int X8[] = {-1, -1, -1, 0, 1, 1, 1, 0}, Y8[] = {-1, 0, 1, 1, 1, 0, -1, -1};   template <typename T>   inline bool uax(T& a, T b) {     return a < b ? (a = b, 1) : 0;   }   template <typename T>   inline bool uin(T& a, T b) {     return a > b ? (a = b, 1) : 0;   }   template <typename T1, typename T2>   istream& operator>>(istream& is, pair<T1, T2>& p) {     return is >> p.first >> p.second;   }   template <typename T1, typename T2>   ostream& operator<<(ostream& os, const pair<T1, T2>& p) {     return os <<  (  << p.first <<  ,   << p.second <<  ) ;   }   template <typename T>   ostream& operator<<(ostream& os, const vector<T>& v) {     for (int i = 0; i < (int)v.size(); i++) {       os << v[i];       if (i + 1 < (int)v.size()) os <<    ;     }     return os;   }   const int MAX_N = 3e5 + 1;   int N, A[MAX_N], B[MAX_N];   long long D[MAX_N][3];   int main() {     ios::sync_with_stdio(0);     cin.tie(nullptr);     cout << std::setprecision(10);     cout << fixed;     int q;     cin >> q;     while (q--) {       cin >> N;       for (int i = 1; i <= N; i++) cin >> A[i] >> B[i];       for (int i = N; i >= 0; i--) {         for (int j = 0; j < 3; j++) {           long long& d = D[i][j] = LINF;           int a = A[i] + j, b = B[i], c = j * b, na = A[i + 1];           if (a != na) uin(d, D[i + 1][0] + c);           if (a != na + 1) uin(d, D[i + 1][1] + c);           if (a != na + 2) uin(d, D[i + 1][2] + c);         }       }       cout << D[0][0] << endl;       for (int i = 1; i <= (N); i++)         for (int j = 0; j < (3); j++) D[i][j] = 0;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct BIT {     vector<pair<int, int> > f;     void init() {       f.push_back(make_pair(-1e9, 0));       f.push_back(make_pair(0, 0));       f.push_back(make_pair(1e9, 0));       sort(f.begin(), f.end());     }     void update(int i, int val, bool fake = 0) {       if (fake) {         f.push_back(make_pair(i, 0));         return;       }       i = lower_bound(f.begin(), f.end(), make_pair(i, 0)) - f.begin();       for (; i < f.size(); i += i & -i) f[i].second = max(f[i].second, val);     }     int get(int i, bool fake = 0) {       if (fake) {         f.push_back(make_pair(i, 0));         return 0;       }       i = lower_bound(f.begin(), f.end(), make_pair(i, 0)) - f.begin();       int ret = 0;       for (; i; i -= i & -i) ret = max(ret, f[i].second);       return ret;     }   } f[100005];   struct data {     int u, v, c;     data(int _u, int _v, int _c) : u(_u), v(_v), c(_c){};   };   int n, m;   vector<data> e;   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> m;     for (int i = 1; i <= m; i++) {       int u, v, c;       cin >> u >> v >> c;       e.push_back(data(u, v, c));     }     for (auto &it : e) {       f[it.u].get(it.c - 1, 1);       f[it.v].update(it.c, 0, 1);     }     for (int i = 1; i <= n; i++) f[i].init();     int ans = 0;     for (auto &it : e) {       int rec = f[it.u].get(it.c - 1);       ans = max(ans, rec + 1);       f[it.v].update(it.c, rec + 1);     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int t, n, k, d, a[200010];   int num[1000010];   bool check(int mid) {     int l = 1, r = 1, nl = 1, nr = 1, cnt = 1;     num[a[1]]++;     while (nr < n) {       nr++;       num[a[nr]]++;       if (num[a[nr]] == 1) {         cnt++;       }       while (cnt > mid) {         num[a[nl]]--;         if (num[a[nl]] == 0) {           cnt--;         }         nl++;       }       if (r - l + 1 < nr - nl + 1) {         l = nl, r = nr;       }     }     for (register int i = nl; i <= nr; i++) {       num[a[i]]--;     }     return r - l + 1 >= d;   }   int main() {     scanf( %d , &t);     while (t--) {       scanf( %d%d%d , &n, &k, &d);       for (register int i = 1; i <= n; i++) {         scanf( %d , &a[i]);       }       int l = 1, r = n, mid, res;       while (l <= r) {         mid = (l + r) >> 1;         if (check(mid)) {           res = mid;           r = mid - 1;         } else {           l = mid + 1;         }       }       printf( %d n , res);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a, b, c, d, e, z[509], x[509], pi, g, s;   vector<int> v[509];   bool m, rr;   pair<int, int> p[509];   void dfs(int w) {     if (m == 1) return;     z[w] = 1;     for (vector<int>::iterator it = v[w].begin(); it != v[w].end(); it++) {       if (x[(*it)] == c) {         p[pi].first = w;         p[pi].second = (*it);         pi++;         m = 1;         g = (*it);         return;       }       if (z[(*it)] == 0) {         x[(*it)] = c;         p[pi].first = w;         p[pi].second = (*it);         pi++;         dfs((*it));         if (m == 1) return;       }     }     x[w] = 0;   }   void dfss(int w) {     if (rr == 1) {       x[w] = 0;       return;     }     z[w] = d + 1;     for (vector<int>::iterator it = v[w].begin(); it != v[w].end(); it++) {       if ((((*it) == p[d].second && w == p[d].first))) continue;       if (x[(*it)] == d + 1) {         s = 1;         rr = 1;         x[w] = 0;         return;       }       if (z[(*it)] != d + 1) {         x[(*it)] = d + 1;         dfss((*it));         if (rr == 1) {           x[w] = 0;           return;         }       }     }     x[w] = 0;   }   int main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     cin >> a >> b;     for (c = 1; c <= b; c++) {       cin >> d >> e;       v[d].push_back(e);     }     for (c = 1; c <= a; c++) {       if (z[c] == 0) {         x[c] = c;         dfs(c);         if (m == 1) break;       }     }     if (g == 0) {       cout <<  YES ;       return 0;     }     for (d = 0; d < pi; d++) {       if (p[d].first == g) break;     }     for (c = 0; c <= 502; c++) z[c] = 0, x[c] = 0;     for (d = d; d < pi; d++) {       for (c = 1; c <= a; c++) {         if (z[c] != d + 1) {           x[c] = d + 1;           rr = 0;           dfss(c);           if (rr == 1) break;         }       }       if (rr == 0) {         cout <<  YES ;         return 0;       }     }     cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int arr[101];   vector<int> vec;   int main(void) {     int n;     long long k;     long long sum;     scanf( %d %lld , &n, &k);     sum = k;     vec.push_back(1);     for (int i = 0; i < n; i++) {       scanf( %d , &arr[i]);       sum += arr[i];       vec.push_back(arr[i]);       for (int j = 2; j * j <= arr[i]; j++) {         if (arr[i] % j == 0) {           vec.push_back(j);           vec.push_back(arr[i] / j);         } else {           vec.push_back(j);           vec.push_back(arr[i] / j + 1);         }       }     }     sort(vec.begin(), vec.end());     vec.resize(unique(vec.begin(), vec.end()) - vec.begin());     int len = vec.size();     long long ans = 0;     for (int i = len - 1; i >= 0; i--) {       long long llsum = 0;       for (int j = 0; j < n; j++) {         llsum += (arr[j] / vec[i]);         if (arr[j] % vec[i] != 0) llsum++;       }       long long d = sum / llsum;       if (d >= vec[i]) {         ans = max(ans, d);       }     }     printf( %lld , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int m[200];   int n;   int S, E;   bool is_ok(int lim) {     int s = 0, e = 0;     for (int i = 0; i < lim; ++i) s += m[i];     for (int j = lim; j <= n; ++j) e += m[j];     return s <= E && e <= E && s >= S && e >= S;   }   int main() {     cin >> n;     for (int i = 1; i <= n; ++i) cin >> m[i];     cin >> S >> E;     for (int i = 1; i <= n; ++i)       if (is_ok(i)) {         cout << i << endl;         break;       } else if (i == n)         cout << 0 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int C[50][50];   int main() {     C[0][0] = 1;     for (int i = 1; i <= 30; i++) {       C[i][0] = C[i][i] = 1;       for (int j = 1; j <= 30; j++) {         C[i][j] = C[i - 1][j] + C[i - 1][j - 1];       }     }     string p =  aaaaaaaaab ;     int pSize = (int)p.size() - 1;     string result =   ;     int n;     cin >> n;     for (int i = 30; i >= 9; i--) {       while (n >= C[i][pSize]) {         n -= C[i][pSize];         result +=  b ;       }       result +=  a ;     }     reverse(result.begin(), result.end());     result = p.substr(0, pSize - 1) + result;     long long cnt = 0;     int aCnt = 0;     for (int i = 0; i < result.size(); i++) {       aCnt += result[i] ==  a ;       if (result[i] ==  b ) cnt += C[aCnt][pSize];     }     cout << result <<     << p <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long b[1510100], n, x;   long long Mod, C;   long long power(long long a, long long n, long long mod) {     if (n == 0) return 1;     long long y;     y = power(a, n / 2, mod);     if (n & 1) {       return (((y * y) % mod) * a) % mod;     } else {       return (y * y) % mod;     }   }   bool func(int mid) {     int i, j, k;     long long EX, sum;     EX = power(x, mid, Mod);     sum = 0;     for (i = 0; i < n; i++) {       if (b[i] >= mid)         break;       else {         sum += power(x, b[i], EX);         sum %= EX;       }     }     if (sum == 0)       return true;     else       return false;   }   int main() {     int i, j, k;     scanf( %d , &n);     scanf( %d , &x);     long long mx, quan;     mx = 0;     quan = 0;     int a[n];     for (i = 0; i < n; i++) {       scanf( %d , &a[i]);       mx = max(mx, (long long)a[i]);       quan += a[i];     }     quan = quan - mx;     for (i = 0; i < n; i++) {       b[i] = mx - a[i];     }     sort(b, b + n);     int hi, lo, mid;     hi = mx;     lo = 0;     Mod = 1000000007;     while (hi != lo) {       mid = (hi + lo + 1) / 2;       if (func(mid)) {         lo = mid;       } else {         hi = mid - 1;       }     }     quan += hi;     cout << power(x, quan, Mod);   }
#include <bits/stdc++.h>   using namespace std;   const int Max = 3e5 + 10;   const int E = Max * 2;   int son[Max], maxson[Max], fa[Max], zx[Max];   int head[Max], nex[E], pnt[E], edge;   int vis[Max];   void Init() {     edge = 0;     memset(son, 0, sizeof(son));     memset(maxson, 0, sizeof(maxson));     memset(fa, -1, sizeof(fa));     memset(head, -1, sizeof(head));     memset(vis, 0, sizeof(vis));   }   void Addedge(int u, int v) {     pnt[edge] = v;     nex[edge] = head[u];     head[u] = edge++;   }   void dfs1(int u) {     son[u] = 1;     vis[u] = 1;     maxson[u] = 0;     int v;     for (int e = head[u]; e != -1; e = nex[e]) {       v = pnt[e];       if (!vis[v]) {         dfs1(v);         son[u] += son[v];         maxson[u] = max(maxson[u], son[v]);       }     }   }   bool is_ok(int u, int v) {     if (son[u] >= maxson[v] * 2 && son[u] >= (son[u] - son[v]) * 2) return 1;     return 0;   }   void dfs2(int u) {     vis[u] = 1;     if (son[u] == 1) {       zx[u] = u;       return;     }     int v, z = u;     for (int e = head[u]; e != -1; e = nex[e]) {       v = pnt[e];       if (!vis[v]) {         dfs2(v);         if (maxson[u] == son[v]) {           z = zx[v];         }       }     }     while (!is_ok(u, z) && fa[z] != -1) {       z = fa[z];     }     zx[u] = z;   }   int main() {     int n, m;     while (~scanf( %d%d , &n, &m)) {       Init();       int u, v;       for (int i = 2; i <= n; i++) {         scanf( %d , &u);         fa[i] = u;         Addedge(u, i);         Addedge(i, u);       }       dfs1(1);       memset(vis, 0, sizeof(vis));       dfs2(1);       while (m--) {         scanf( %d , &u);         printf( %d n , zx[u]);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m;   int main() {     cin >> n >> m;     if (n > m) swap(n, m);     if (n == 1) {       cout << 6 * (m / 6) + 2 * max(m % 6 - 3, (long long)0);       return 0;     }     if (n == 2) {       if (m == 2) {         cout << 0;         return 0;       }       if (m == 3) {         cout << 4;         return 0;       }       if (m == 7) {         cout << 12;         return 0;       }     }     if (n % 2 == 0 || m % 2 == 0) {       cout << n * m;       return 0;     }     cout << n * m - 1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T1, class T2>   bool chmin(T1 &a, T2 b) {     return b < a && (a = b, true);   }   template <class T1, class T2>   bool chmax(T1 &a, T2 b) {     return a < b && (a = b, true);   }   int main() {     int n;     cin >> n;     static long long dp[100][100][100][4];     dp[1][1][1][0] = 1;     dp[1][1][1][1] = 1;     dp[1][1][1][2] = 1;     dp[1][1][1][3] = 1;     for (int i = (1); i < (2 * n - 2); i++)       for (int j = 0; j < (n + 1); j++)         for (int k = 0; k < (100); k++)           for (int l = 0; l < (4); l++) {             for (int x = 0; x < (4); x++) {               if (l == x) {                 dp[i + 1][j + 1][max(k, j + 1)][x] += dp[i][j][k][l];               } else {                 dp[i + 1][1][max(k, 1)][x] += dp[i][j][k][l];               }             }           }     long long ans = 0;     for (int j = 0; j < (n + 1); j++)       for (int i = 0; i < (4); i++) ans += dp[2 * n - 2][j][n][i];     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     cin.tie(0);     cout.tie(0);     iostream::sync_with_stdio(false);     long long n, m;     cin >> n >> m;     set<int> taken_lines, taken_cols;     long long base = n * n;     for (int i = 0; i < m; ++i) {       int x, y;       cin >> x >> y;       bool lined = false, coled = false;       if (taken_lines.count(x) == 0) lined = true;       if (taken_cols.count(y) == 0) coled = true;       if (lined) {         base -= n - taken_cols.size();       }       if (coled) {         base -= n - taken_lines.size();       }       if (lined && coled) {         base++;       }       taken_lines.insert(x);       taken_cols.insert(y);       cout << base <<    ;     }     cout <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int a[n];     for (int i = 0; i < n; i++) cin >> a[i];     int l = 0;     int r = n - 1;     while (l < n - 1 && a[l] < a[l + 1]) l++;     while (r > 0 && a[r] < a[r - 1]) r--;     for (int i = l + 1; i <= r; i++) {       if (a[l] != a[i]) {         cout <<  NO ;         return 0;       }     }     cout <<  YES ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e3 + 10;   int a[maxn], b[maxn];   int dp[2][maxn][55][55];   inline int ip(int k) { return k > 0 ? k : 0; }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n, p, k;     cin >> n >> p >> k;     int r, s;     cin >> r;     for (int i = 0; i < r; i++) {       int t;       cin >> t;       a[t] = 1;     }     cin >> s;     for (int i = 0; i < s; i++) {       int t;       cin >> t;       b[t] = 1;     }     p = min(p, (2 * n) / k + ((2 * n % k) > 0 ? 1 : 0));     int f = 0;     memset(dp, -0x3f, sizeof(dp));     dp[0][0][0][0] = 0;     for (int i = 1; i <= n; i++) {       for (int j = 0; j <= p; j++) {         for (int x = 0; x < k; x++) {           for (int y = 0; y < k; y++) {             dp[!f][j][ip(x - 1)][ip(y - 1)] =                 max(dp[!f][j][ip(x - 1)][ip(y - 1)],                     dp[f][j][x][y] + ((x > 0 && a[i]) || (y > 0 && b[i])));             dp[!f][j + 1][k - 1][ip(y - 1)] =                 max(dp[!f][j + 1][k - 1][ip(y - 1)],                     dp[f][j][x][y] + (a[i] || (y > 0 && b[i])));             dp[!f][j + 1][ip(x - 1)][k - 1] =                 max(dp[!f][j + 1][ip(x - 1)][k - 1],                     dp[f][j][x][y] + (b[i] || (x > 0 && a[i])));           }         }       }       memset(dp[f], -0x3f, sizeof(dp[f]));       f = !f;     }     int ans = 0;     for (int l = 0; l <= p; l++)       for (int i = 0; i < k; i++)         for (int j = 0; j < k; j++) ans = max(ans, dp[f][l][i][j]);     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int Left[1000010];   int mini[1000010];   int main(void) {     cin.tie(0);     ios::sync_with_stdio(false);     int n;     cin >> n;     string S;     cin >> S;     for (int i = 0; i < S.length(); i++) {       if (S[i] ==  ( )         Left[i + 1] = Left[i] + 1;       else         Left[i + 1] = Left[i] - 1;     }     for (int i = 0; i < 1000010; i++) mini[i] = 2000000000;     int ans = 0;     if (Left[n] == 2) {       for (int i = n; i >= 0; i--) mini[i] = min(mini[i + 1], Left[i]);       for (int i = 0; i < n; i++) {         if (i != 0 && Left[i - 1] < 0) break;         if (S[i] ==  (  && mini[i + 1] >= 2 && Left[n] == 2) ans++;       }     } else if (Left[n] == -2) {       for (int i = n; i >= 0; i--) mini[i] = min(mini[i + 1], Left[i]);       for (int i = 0; i < n - 1; i++) {         if (i != 0 && Left[i - 1] < 0) break;         if (S[i] ==  )  && mini[i] >= -2) ans++;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1111;   int a[maxn], b[maxn];   int main() {     int n, k;     cin >> n >> k;     for (int i = 1; i <= n; i++) cin >> a[i];     int maxim = 0, num = -1;     for (int i = 1; i <= n; i++) {       b[i] = a[i];       for (int j = 1; j <= n; j++) b[j] = a[i] + (j - i) * k;       int kol = 0;       for (int j = 1; j <= n; j++)         if (a[j] == b[j]) kol++;       if (b[1] > 0 && kol > maxim) {         maxim = kol;         num = i;       }     }     cout << n - maxim << endl;     for (int i = 1; i <= n; i++) {       if (a[num] + (i - num) * k == a[i]) continue;       if (a[num] + (i - num) * k > a[i])         cout <<  +   << i <<     << -(a[i] - a[num] - (i - num) * k) << endl;       else         cout <<  -   << i <<     << -(a[num] + (i - num) * k - a[i]) << endl;     }     cin >> n;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, S[2005];   bool mark[2005][2005];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     char c;     cin >> n >> m;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) {         cin >> c;         mark[i][j] = c -  0 ;         if (mark[i][j]) S[j]++;       }     bool flag;     for (int i = 1; i <= n; i++) {       flag = 0;       for (int j = 1; j <= m; j++)         if (mark[i][j]) S[j]--;       for (int j = 1; j <= m; j++)         if (S[j] == 0) {           flag = 1;           break;         }       if (!flag) {         cout <<  YES ;         return 0;       }       for (int j = 1; j <= m; j++)         if (mark[i][j]) S[j]++;     }     cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 400500;   long long A[N];   long long B[N];   inline long long mymod2(long long x) {     if (x % 2 == 0)       return 0;     else       return 1;   }   inline long long mydiv2(long long x) {     if (x >= 0)       return x / 2;     else {       if (x % 2 == 0)         return x / 2;       else         return x / 2 - 1;     }   }   void buildB() {     for (int i = 0; i < N; i++) B[i] = A[i];     for (int i = 0; i < N - 1; i++) {       B[i + 1] += mydiv2(B[i]);       B[i] = mymod2(B[i]);     }   }   int main() {     int n, k;     scanf( %d %d , &n, &k);     for (int i = 0; i <= n; i++) {       int x;       scanf( %d , &x);       A[i] = x;     }     buildB();     if (B[N - 1]) {       for (int i = 0; i <= n; i++) A[i] = -A[i];       buildB();     }     int fst = 0;     while (fst != N && B[fst] == 0) {       fst++;     }     assert(fst != N);     long long cur = 0;     bool bad = false;     for (int i = fst; i < N; i++) {       if (B[i]) {         int p = i - fst;         if (p > 40) {           bad = true;           break;         }         cur += 1ll << p;       }     }     int cnt = 0;     if (!bad) {       for (int i = fst; i >= 0; i--) {         if (cur > (1ll << 32)) break;         long long nA = A[i] - cur;         if (abs(nA) <= k && (i != n || nA != 0) && (i <= n)) cnt++;         cur <<= 1;       }     }     printf( %d n , cnt);   }