malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int matmul[][6] = {{2, 1, 1, 1, 0, 0}, {1, 2, 1, 1, 0, 0},                            {1, 0, 1, 0, 0, 0}, {0, 1, 0, 1, 0, 0},                            {1, 1, 1, 1, 1, 0}, {2, 2, 2, 2, 1, 1}};   long long N, sx, sy, dx, dy, t;   struct matrix {     int m, n;     long long d[13][13];     matrix() {       m = 0;       n = 0;       memset(d, 0, sizeof d);     }     matrix(int m, int n) {       this->m = m;       this->n = n;       memset(d, 0, sizeof d);     }     matrix operator*(const matrix &a) const {       int x = m;       int y = n;       int z = a.n;       matrix res = matrix(x, z);       for (int i = 0; i < (x); i = i + 1)         for (int j = 0; j < (z); j = j + 1)           for (int k = 0; k < (y); k = k + 1)             res.d[i][j] = (res.d[i][j] + d[i][k] * a.d[k][j]) % N;       return (res);     }     matrix operator^(long long k) const {       matrix res = matrix(m, n);       matrix mul = (*this);       for (int i = 0; i < (m); i = i + 1) res.d[i][i] = 1;       while (k > 0) {         if (k % 2 == 1) res = res * mul;         mul = mul * mul;         k = k >> 1;       }       return (res);     }     void print(void) const {       for (int i = 0; i < (m); i = i + 1) {         for (int j = 0; j < (n); j = j + 1) cout << d[i][j] <<    ;         cout <<   n ;       }       cout <<   n ;     }   };   matrix fst, mul;   void process(void) {     cin >> N >> sx >> sy >> dx >> dy >> t;     if (N == 1) {       cout <<  1 1 ;       return;     }     fst = matrix(1, 6);     mul = matrix(6, 6);     for (int i = 0; i < (6); i = i + 1)       for (int j = 0; j < (6); j = j + 1) mul.d[i][j] = matmul[i][j] % N;     fst.d[0][0] = sx - 1;     fst.d[0][1] = sy - 1;     fst.d[0][2] = (dx % N + N) % N;     fst.d[0][3] = (dy % N + N) % N;     fst.d[0][4] = 0;     fst.d[0][5] = 1;     fst = fst * (mul ^ t);     cout << fst.d[0][0] + 1 <<     << fst.d[0][1] + 1;   }   int main(void) {     process();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     int n, m;     cin >> n >> m;     int ver[n + 1];     ver[n] = 1e9;     for (int i = 0; i < n; i++) cin >> ver[i];     int hor[m];     for (int i = 0; i < m; i++) {       int x1, x2, y;       cin >> x1 >> x2 >> y;       if (x1 > 1)         hor[i] = 0;       else         hor[i] = x2;     }     if (m == 0) {       cout << 0 << endl;       return 0;     }     sort(ver, ver + n);     sort(hor, hor + m);     int wy = 10000000;     int poz = m;     int a = 0;     for (int i = 0; i < n + 1; i++) {       while (a < m and hor[a] < ver[i]) {         poz--;         a++;       }       wy = min(wy, poz + i);     }     cout << wy << endl;     return 0;   }
#include <bits/stdc++.h>   const int md = 1e9 + 7;   const long long hs = 199;   using namespace std;   int n, x;   set<int> a;   int main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     cin >> n;     for (int i = 1; i <= n; i++) a.insert(i);     cout <<  1  ;     while (--n) {       cin >> x;       a.erase(x);       auto it = a.end();       it--;       cout << 1 + *it - n <<   n ;     }     cout << 1 <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int setBite(int r, int pos) { return r | (1 << pos); }   int resetBit(int r, int pos) { return r & ~(1 << pos); }   bool checkBit(int r, int pos) { return (r & (1 << pos)); }   bool leap(long long x) {     if ((x % 4 == 0 && x % 100 != 0) || x % 400 == 0) return true;     return false;   }   long long bigmod(long long a, long long b, long long mod) {     if (b == 0) return 1;     if (b % 2 == 0) {       long long ret = bigmod(a, b / 2, mod);       return ((ret % mod) * (ret % mod)) % mod;     } else       return ((a % mod) * (bigmod(a, b - 1, mod) % mod)) % mod;   }   template <class T>   inline T gcd(T a, T b) {     if (a < 0) return gcd(-a, b);     if (b < 0) return gcd(a, -b);     return (b == 0) ? a : gcd(b, a % b);   }   template <class T>   inline T lcm(T a, T b) {     if (a < 0) return lcm(-a, b);     if (b < 0) return lcm(a, -b);     return a * (b / gcd(a, b));   }   template <class T>   inline T sqr(T x) {     return x * x;   }   template <class T>   inline T power(T r, T p) {     T ans = 1;     for (T i = 0; i < p; i++) {       ans *= r;     }     return ans;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     int g[2 * n + 5][2 * n + 5];     for (int i = 0; i < 2 * n + 5; i++) {       for (int j = 0; j < 2 * n + 5; j++) {         g[i][j] = 0;       }     }     for (int i = 1; i <= n - 1; i++) {       int a;       cin >> a;       g[i][i + 1] = a;       g[i + 1][i] = a;     }     for (int i = n + 1; i <= 2 * n - 1; i++) {       int a;       cin >> a;       g[i][i + 1] = a;       g[i + 1][i] = a;     }     for (int i = 1; i <= n; i++) {       int a;       cin >> a;       g[i][i + n] = a;       g[i + n][i] = a;     }     vector<int> v;     for (int i = 1; i <= n; i++) {       int ans = 0;       for (int j = 1; j <= i - 1; j++) {         ans += g[j][j + 1];       }       ans += g[i][i + n];       for (int j = i + n; j <= 2 * n - 1; j++) {         ans += g[j][j + 1];       }       v.push_back(ans);     }     sort(v.begin(), v.end());     cout << v[0] + v[1];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int m;   long long int a;   long long int b;   set<int> s;   long long int im(long long int val, int dv) {     long long int z = 0;     long long int U = (1LL + val / dv) * (val / dv) / 2LL;     U *= dv;     U -= (val / dv) * (dv - (val % dv) - 1);     return U;     for (int i = 0; i <= val; i++) {       z += i / dv;     }     return z;   }   long long int cn(int star, int ds) {     long long int ret = im(m - ds, b) - im(star - ds - 1, b);     ret += m - star + 1;     return ret;   }   int main() {     cin >> m >> a >> b;     long long int mx = 0;     long long int cur = 0;     swap(a, b);     long long int ans = cn(0, 0);     s.insert(0);     while (true) {       if (cur < a) {         cur += b * ((a - cur + b - 1) / b);       }       mx = max(mx, cur);       cur -= a;       cur %= b;       if (mx > m) break;       if (s.count(cur)) break;       s.insert(cur);       ans += cn(mx, cur);     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n;     int a = 0;     cin >> n;     long long tp = n;     for (long long i = 2; i <= sqrt(tp); i++) {       if (tp % i == 0) {         while (tp % i == 0) tp /= i;         a = i;         break;       }     }     if (a == 0)       cout << n;     else if (tp != 1) {       printf( 1 );     } else       printf( %d , a);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<string, int> Map;   char str[2200][22];   int p[2200], q[2200];   int main() {     int num, n, k1, k2, cnt;     char s1[22], s2[22];     while (scanf( %d , &n) != EOF) {       memset(p, 0, sizeof(p));       memset(q, 0, sizeof(q));       cnt = 1;       num = 0;       while (n--) {         scanf( %s %s , s1, s2);         if (Map[s2] > 0) continue;         if ((k1 = Map[s1]) > 0) {           Map[s1] = 0;           strcpy(str[cnt++], s2);           p[q[k1]] = cnt - 1;           q[cnt - 1] = q[k1];           Map[s2] = cnt - 1;         } else {           strcpy(str[cnt++], s1);           strcpy(str[cnt++], s2);           p[cnt - 2] = cnt - 1;           q[cnt - 1] = cnt - 2;           Map[s2] = cnt - 1;           num++;         }       }       printf( %d n , num);       int i;       for (i = 0; i < cnt; i++)         if (p[i]) printf( %s %s n , str[i], str[p[i]]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[100002];   int gcd(int a, int b) {     int c;     while (a != 0) {       c = a;       a = b % a;       b = c;     }     return b;   }   int main() {     int n;     int mina = 2000000009;     cin >> n;     cin >> a[1];     int ucln;     ucln = a[1];     for (long long int i = 2; i <= n; i++) {       scanf( %d , a + i);       ucln = gcd(ucln, a[i]);     }     int res0 = 1;     for (long long int i = 1; i <= n; i++) {       if (a[i] % ucln != 0) {         res0 = 0;       }     }     if (ucln == 1) {       res0 = 0;     }     if (res0 == 1) {       cout <<  YES n ;       cout << 0;     } else {       a[n + 1] = 2;       int res = 0;       for (int i = 1; i <= n;) {         if (a[i] % 2 == 0) {           i++;         } else {           if (a[i + 1] % 2 == 1) {             res += 1;             i += 2;           } else {             res += 2;             i += 2;           }         }       }       cout <<  YES n ;       cout << res;     }   }
#include <bits/stdc++.h>   using namespace std;   int maxx = 1e6 + 10;   int up(int a, int b) {     if (a % b)       return a / b + 1;     else       return a / b;   }   int main() {     int t;     scanf( %d , &t);     while (t--) {       int n, d;       scanf( %d%d , &n, &d);       bool flag = 0;       for (int x = 0; x < maxx; x++) {         if ((x + up(d, x + 1)) <= n) {           flag = 1;           break;         }       }       if (flag)         printf( YES n );       else         printf( NO n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int mod = 998244353;   long long int expo(long long int base, long long int exponent,                      long long int mod) {     long long int ans = 1;     while (exponent != 0) {       if (exponent & 1) ans = (1LL * ans * base) % mod;       base = (1LL * base * base) % mod;       exponent >>= 1;     }     return ans % mod;   }   vector<long long int> g[100005];   long long int val[100005], dist[100005];   void dfs(long long int node, long long int par, long long int d) {     dist[node] = d;     if (g[node].size() == 1) val[par]++;     for (auto x : g[node]) {       if (x != par) dfs(x, node, d + 1);     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int tests = 1;     while (tests--) {       long long int i, j, u, v, n;       cin >> n;       for (long long int i = 1; i <= n - 1; i++) {         cin >> u >> v;         g[u].push_back(v);         g[v].push_back(u);       }       long long int root = -1;       for (long long int i = 1; i <= n; i++) {         if (g[i].size() > 1) {           root = i;           break;         }       }       dfs(root, 0, 0);       long long int mx = n - 1, mn;       long long int odd = 0, even = 0;       for (long long int i = 1; i <= n; i++) {         if (g[i].size() > 1) continue;         if (dist[i] % 2)           odd++;         else           even++;       }       if (odd == 0 || even == 0)         mn = 1;       else         mn = 3;       for (long long int i = 1; i <= n; i++) {         mx -= max(0LL, val[i] - 1);       }       cout << mn <<     << mx;     }     cerr <<   nTime elapsed:   << 1000 * clock() / CLOCKS_PER_SEC <<  ms n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int Maxn = 55;   long long dp[Maxn][10];   int main() {     string k;     cin >> k;     int n = k.length();     for (int i = 0; i < 10; i++) {       dp[0][i] = 1;     }     for (int i = 1; i < n; i++) {       int t = k[i] -  0 ;       for (int j = 0; j < 10; j++) {         int l = (t + j) / 2, r = (t + j + 1) / 2;         dp[i][l] += dp[i - 1][j];         if (l != r) dp[i][r] += dp[i - 1][j];       }     }     bool flag = false;     for (int i = 1; i < n; i++) {       int t = k[i] -  0 , j = k[i - 1] -  0 ;       if ((t + j + 1) / 2 != t && (t + j) / 2 != t) flag = true;     }     long long ans = (long long)-1 + flag;     for (int i = 0; i <= 9; i++) {       ans = (long long)ans + (long long)dp[n - 1][i];     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long M = 1000000007;   const double pi = acos(-1);   const int N = 2e5 + 10;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     ;     long long n, k, m, d, q = 1, ans = 0;     cin >> n >> k >> m >> d;     for (long long i = 1; i < d + 1; i++) {       long long mx1 = m;       long long mx2 = n / q;       long long w = min(mx1, mx2) * i;       ans = max(ans, w);       q += k;       if (q > n) break;     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 105;   const int M = 1005;   int n, m, x[N], s;   double p[N * M], tmp[N * M];   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; ++i) scanf( %d , &x[i]);     for (int i = 1; i <= n; ++i) s += x[i];     if (m == 1) {       puts( 1.0000000000 );       return 0;     }     p[0] = 1;     for (int i = 1; i <= n; ++i) {       double now = 0;       for (int j = 1; j < s; ++j) {         now += p[j - 1];         if (x[i] <= j) now -= p[j - x[i]];         if (x[i] < j) now += p[j - x[i] - 1];         if (m < j) now -= p[j - m - 1];         tmp[j] = now / (m - 1);       }       for (int j = 0; j <= s; ++j) p[j] = tmp[j];       copy(tmp, tmp + s, p);     }     double ans = 0;     for (int i = 1; i <= s; ++i) ans += p[i];     ans = ans * (m - 1) + 1;     printf( %.10f n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 10;   const int M = 1e6 + 10;   int n, m, x, y, a[N], f[M];   bitset<N> ans, tmp;   int main() {     scanf( %d%d%d , &n, &x, &y);     for (int i = 1; i <= n + 1; i++) {       scanf( %d , &a[i]);       tmp.set(a[i]);     }     for (int i = 1; i <= n + 1; i++) {       ans |= tmp >> a[i];     }     for (int i = 1; i <= x; i++)       if (ans[i]) f[2 * (i + y)] = 2 * (i + y);     for (int i = 1; i < M; i++)       for (int j = i; j < M; j += i) f[j] = max(f[j], f[i]);     scanf( %d , &m);     while (m--) {       scanf( %d , &x);       if (f[x])         printf( %d  , f[x]);       else         printf( -1  );     }   }
#include <bits/stdc++.h>   using namespace std;   int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long int n, m;     cin >> n >> m;     string s;     char x, y;     cin >> s;     char ch[26];     for (long long int i = 0; i < 26; i++) {       ch[i] = i +  a ;     }     for (long long int i = 0; i < m; i++) {       cin >> x >> y;       for (long long int j = 0; j < 26; j++) {         if (x == ch[j]) {           ch[j] = y;         } else if (y == ch[j]) {           ch[j] = x;         }       }     }     for (long long int i = 0; i < s.size(); i++) {       cout << ch[s[i] -  a ];     }     return 0;   }
#include <bits/stdc++.h>   const int N = 200010;   std::vector<int> e[N];   int color[N], dep[N];   bool vis[N];   int n, k;   int max = 0;   void dfs(int u, int fa) {     max = std::max(max, dep[u]);     for (auto v : e[u]) {       if (vis[v] || v == fa) {         continue;       }       dep[v] = dep[u] + 1;       dfs(v, u);     }   }   std::vector<int> stack;   std::vector<int> diameter;   void find_diameter(int u, int fa, int t) {     stack.push_back(u);     if (u == t) {       diameter = stack;     }     for (auto v : e[u]) {       if (v == fa) {         continue;       }       find_diameter(v, u, t);     }     stack.pop_back();   }   void solve(int u, int fa, int add) {     for (auto v : e[u]) {       if (vis[v] || v == fa) {         continue;       }       color[v] = (color[u] + add + k) % k;       solve(v, u, add);     }   }   int main() {     scanf( %d%d , &n, &k);     for (int i = 0, u, v; i < n - 1; ++i) {       scanf( %d%d , &u, &v);       e[u].push_back(v);       e[v].push_back(u);     }     if (k == 2) {       solve(1, 0, 1);       puts( Yes );       for (int i = 1; i <= n; ++i) {         printf( %d%c , color[i] + 1,    n [i == n]);       }       return 0;     }     dfs(1, 0);     int s = std::max_element(dep + 1, dep + n + 1) - dep;     dep[s] = 0;     dfs(s, 0);     int t = std::max_element(dep + 1, dep + n + 1) - dep;     find_diameter(s, 0, t);     int sz = diameter.size();     for (int i = 0; i < sz; ++i) {       color[diameter[i]] = i % k;       vis[diameter[i]] = true;     }     for (int i = 0; i < sz; ++i) {       dep[diameter[i]] = 0;       max = 0;       dfs(diameter[i], 0);       if (max == 0) {         continue;       }       if (max + i + 1 < k) {         solve(diameter[i], 0, -1);       } else if (max + sz - i < k) {         solve(diameter[i], 0, 1);       } else {         puts( No );         return 0;       }     }     puts( Yes );     for (int i = 1; i <= n; ++i) {       printf( %d%c , color[i] + 1,    n [i == n]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long n1, m;     cin >> n1 >> m;     string s;     cin >> s;     long long n;     n = s.size();     long long lps[n];     lps[0] = 0;     long long i, j;     if (m == 0) {       long long ans3 = 1;       for (i = 1; i <= n1; i++) {         ans3 = (ans3 * 26) % 1000000007;       }       cout << ans3 << endl;       return 0;     }     i = 0;     i++;     long long len = 0;     j = 0;     while (i < n) {       if (s[i] == s[len]) {         len++;         lps[i] = len;         i++;       } else {         if (len != 0) {           len = lps[len - 1];         } else {           lps[i] = 0;           i++;         }       }     }     vector<long long> v;     for (i = 0; i < m; i++) {       long long x;       cin >> x;       v.push_back(x);     }     if (s.size() == 1) {       long long ans3 = 1;       for (i = 1; i <= n1 - m; i++) {         ans3 = (ans3 * 26) % 1000000007;       }       cout << ans3 << endl;       return 0;     }     if (s.size() == 1 && m == 1) {       cout << 1 << endl;       return 0;     }     long long vis[n1];     for (i = 0; i < n1; i++) {       vis[i] = 0;     }     long long r;     r = -1;     for (i = 0; i < m; i++) {       long long x;       x = v[i];       x--;       if (x > r) {         if (x + n - 1 >= n1) {           cout << 0 << endl;           return 0;         }         for (j = x; j < x + n; j++) {           vis[j] = 1;         }         r = x + n - 1;       } else {         if (r + (n - (r - x + 1)) >= n1) {           cout << 0 << endl;           return 0;         }         for (j = r + 1; j <= r + (n - (r - x + 1)); j++) {           vis[j] = 1;         }         r = r + (n - (r - x + 1));       }     }     long long c = 0LL;     for (i = 0; i < n1; i++) {       if (vis[i] == 0) c++;     }     long long arr[c + 1];     arr[0] = 1;     for (i = 1; i <= c; i++) {       arr[i] = (arr[i - 1] * 26) % 1000000007;     }     map<long long, long long> m1;     long long k1;     k1 = lps[n - 1];     while (k1 > 0) {       m1[n - k1] = 1;       k1 = lps[k1 - 1];     }     if (m == 1) {       cout << arr[c] << endl;       return 0;     }     r = v[0] - 1;     for (i = 1; i < m; i++) {       long long x;       x = v[i];       x--;       if (r + n - 1 < x) {         r = x;       } else {         long long pos;         pos = x - r;         if (m1.find(pos) == m1.end()) {           cout << 0 << endl;           return 0;         } else           r = x;       }     }     cout << arr[c] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100010;   const int INF = 0x7f7f7f7f;   const double pi = 4.0 * atan(1.0);   int cases;   struct Segment_Tree {     long long lazy[MAXN << 2];     long long data[MAXN << 2];     long long flag[MAXN << 2];     void pushup(int o) {       data[o] = data[(o << 1)] + data[(o << 1) | 1];       if (flag[(o << 1)] != flag[(o << 1) | 1]) {         flag[o] = 0;       } else {         flag[o] = flag[(o << 1)];       }     }     void setlazy(int o, int m, long long v) {       lazy[o] += v;       data[o] += m * v;     }     void pushdown(int o, int m) {       if (lazy[o]) {         setlazy((o << 1), m - (m >> 1), lazy[o]);         setlazy((o << 1) | 1, m >> 1, lazy[o]);         flag[(o << 1)] = flag[(o << 1) | 1] = flag[o];         lazy[o] = 0;       }     }     void build_tree(int o, int l, int r) {       if (l == r) {         flag[o] = l;         return;       }       int mid = (l + r) >> 1;       build_tree((o << 1), l, mid);       build_tree((o << 1) | 1, mid + 1, r);       pushup(o);     }     void update(int o, int l, int r, int x, int y, long long v) {       if (x <= l && r <= y && flag[o] != 0) {         lazy[o] += abs(flag[o] - v);         data[o] += (long long)(r - l + 1) * abs(flag[o] - v);         flag[o] = v;         return;       }       pushdown(o, r - l + 1);       int mid = (l + r) >> 1;       if (x <= mid) update((o << 1), l, mid, x, y, v);       if (y > mid) update((o << 1) | 1, mid + 1, r, x, y, v);       pushup(o);     }     long long query(int o, int l, int r, int x, int y) {       if (x <= l && r <= y) {         return data[o];       }       pushdown(o, r - l + 1);       int mid = (l + r) >> 1;       if (y <= mid) return query((o << 1), l, mid, x, y);       if (x > mid) return query((o << 1) | 1, mid + 1, r, x, y);       return query((o << 1), l, mid, x, y) +              query((o << 1) | 1, mid + 1, r, x, y);     }   } segtree;   int main() {     int n, m, op, x, y;     long long z;     scanf( %d%d , &n, &m);     segtree.build_tree(1, 1, n);     for (int i = 0; i < m; i++) {       scanf( %d , &op);       if (op == 1) {         scanf( %d%d%lld , &x, &y, &z);         segtree.update(1, 1, n, x, y, z);       } else if (op == 2) {         scanf( %d%d , &x, &y);         printf( %lld n , segtree.query(1, 1, n, x, y));       }     }   }
#include <bits/stdc++.h>   using namespace std;   int n, a[100001], c[100001];   int main() {     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i];     int s = 0;     for (int i = n - 1; i >= 0; i--)       if (s > 0)         s -= a[i];       else {         c[i] = 1;         s += a[i];       }     if (s < 0)       for (int i = 0; i < n; i++) c[i] ^= 1;     for (int i = 0; i < n; i++) cout << (c[i] ?  +  :  - );     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1000000007;   const long double eps = 1e-9;   const long double pi = 3.141592653589793;   const long double e = 2.718281828459045;   int dp[100005], h[100005];   int n, mmm;   int main() {     memset(dp, -1, sizeof(dp));     memset(h, 0, sizeof(h));     mmm = 0;     scanf( %d , &n);     dp[0] = 0;     dp[n + 1] = 0;     for (int i = 1; i <= n; i++) {       scanf( %d , &h[i]);     }     for (int i = 1; i <= n; i++) {       dp[i] = min(dp[i - 1] + 1, h[i]);     }     for (int i = n; i >= 1; i--) {       dp[i] = min(dp[i], dp[i + 1] + 1);       mmm = max(mmm, dp[i]);     }     cout << mmm << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inft = 1000000009;   const int MAXN = 1000006;   int n, T[MAXN], A[MAXN], B[MAXN];   int main() {     scanf( %d , &n);     for (int i = 0; i < (n); ++i) scanf( %d , &T[i]);     A[0] = 1;     for (int i = 1; i < n; ++i) A[i] = min(A[i - 1] + 1, T[i]);     B[n - 1] = 1;     for (int i = n - 2; i >= 0; --i) B[i] = min(B[i + 1] + 1, T[i]);     int ret = 0;     for (int i = 0; i < (n); ++i) ret = max(ret, min(A[i], B[i]));     printf( %d n , ret);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   T mymax(T a, T b) {     return a > b ? a : b;   }   template <class T>   T mymin(T a, T b) {     return a < b ? a : b;   }   int main() {     int n;     int a[1001];     int s[1001] = {0}, sz, ymax = -1;     int i, j, k;     cin >> n;     for (i = 1; i <= n; i++) {       cin >> a[i];       s[i] = a[i] + s[i - 1];     }     sz = s[n] + 1;     char M[2002][sz];     for (j = 2001; j >= 1; j--) {       for (i = 0; i <= sz - 1; i++) {         M[j][i] =    ;       }     }     int x = 1, y = 1000;     for (i = 1; i <= n; i++) {       j = a[i];       int al;       if (i % 2 == 1) {         for (al = 1; al <= j; al++) {           M[y][x] =  / ;           x++;           y++;         }         y--;       } else {         for (al = 1; al <= j; al++) {           M[y][x] =     ;           x++;           y--;         }         y++;       }     }     for (j = 2001; j >= 1; j--) {       int f = 0;       for (i = 1; i <= s[n]; i++) {         if (M[j][i] !=    ) f = 1;       }       if (f) {         for (i = 1; i <= s[n]; i++) {           cout << M[j][i];         }         cout <<   n ;       }     }     return 0;   }