malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int inf = 1e9 + 7;   inline void rvi(vector<int>& v, int n) {     int temp;     for (int i = 0; i < n; i++) {       cin >> temp;       v.push_back(temp);     }   }   inline void rvll(vector<long long int>& v, int n) {     long long int temp;     for (int i = 0; i < n; i++) {       cin >> temp;       v.push_back(temp);     }   }   inline void prvi(vector<int>& a) {     for (int i = 0; i < a.size(); i++) {       cout << a[i] <<    ;     }     cout << endl;   }   inline void prvll(vector<long long int>& a) {     for (int i = 0; i < a.size(); i++) {       cout << a[i] <<    ;     }     cout << endl;   }   inline void prmii(map<int, int>& m) {     for (auto x : m) {       cout << x.first <<     << x.second << endl;     }   }   inline vector<long long int> prefixsum(vector<int>& a) {     vector<long long int> b;     b.push_back(a[0]);     for (int i = 1; i < a.size(); i++) {       b.push_back(a[i] + b[i - 1]);     }     return b;   }   inline vector<long long int> suffixsum(vector<int>& a) {     vector<long long int> b((a.size()));     b[(a.size()) - 1] = a[(a.size()) - 1];     for (int i = (a.size()) - 1 - 1; i >= 0; i--) {       b[i] = a[i] + b[i + 1];     }     return b;   }   inline vector<long long int> prefixsum(vector<long long int>& a) {     vector<long long int> b;     b.push_back(a[0]);     for (int i = 1; i < a.size(); i++) {       b.push_back(a[i] + b[i - 1]);     }     return b;   }   inline vector<long long int> suffixsum(vector<long long int>& a) {     vector<long long int> b((a.size()));     b[(a.size()) - 1] = a[(a.size()) - 1];     for (int i = (a.size()) - 1 - 1; i >= 0; i--) {       b[i] = a[i] + b[i + 1];     }     return b;   }   void solve();   int main() {     solve();     return 0;   }   void solve() {     int t;     cin >> t;     while (t--) {       int d;       cin >> d;       double a, b;       if (d * d - 4 * d < 0) {         cout <<  N n ;       } else {         a = (d + sqrt(d * d - 4 * d)) / 2;         b = d - a;         printf( Y %.10lf %.10lf n , a, b);       }     }   }
#include <bits/stdc++.h>   using namespace std;   int a[111111];   map<int, int> cnt;   map<int, int> m;   int main() {     int n;     scanf( %d , &n);     m.clear();     cnt.clear();     for (int i = 0; i < n; i++) scanf( %d , &a[i]);     sort(a, a + n);     int ma = INT_MIN;     for (int i = 0; i < n; i++) {       m[a[i]] += 1;       ma = max(ma, a[i]);     }     vector<int> v;     for (int i = 0; i < n; i++)       if (cnt[a[i]] != 1) {         v.push_back(a[i]);         cnt[a[i]] = 1;         m[a[i]] = m[a[i]] - 1;       }     cnt.clear();     for (int i = n - 1; i >= 0; i--)       if (a[i] != ma && m[a[i]] > 0 && cnt[a[i]] != 1) {         v.push_back(a[i]);         cnt[a[i]] = 1;       }     printf( %d n , v.size());     for (int i = 0; i < v.size(); i++) printf( %d  , v[i]);     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void Read(int &n) {     int sign = 1;     n = 0;     char c;     do {       c = getchar();     } while (!isdigit(c) && c !=  - );     if (c ==  - ) {       c = getchar();       sign = -1;     }     do {       n = n * 10 + c - 48;       c = getchar();     } while (isdigit(c));     n *= sign;   }   void Read(long long &n) {     int sign = 1;     n = 0;     char c;     do {       c = getchar();     } while (!isdigit(c) && c !=  - );     if (c ==  - ) {       c = getchar();       sign = -1;     }     do {       n = n * 10ll + c - 48;       c = getchar();     } while (isdigit(c));     n *= sign;   }   void Write(int n) {     if (n == 0) {       putchar( 0 );       return;     } else if (n < 0)       putchar( - ), n = -n;     char C[30];     int d = 0;     while (n) {       C[++d] = (n % 10) + 48;       n /= 10;     }     for (int i = d; i >= 1; --i) putchar(C[i]);   }   void Write(long long n) {     if (n == 0) {       putchar( 0 );       return;     } else if (n < 0)       putchar( - ), n = -n;     char C[30];     int d = 0;     while (n) {       C[++d] = (n % 10ll) + 48;       n /= 10ll;     }     for (int i = d; i >= 1; --i) putchar(C[i]);   }   const int maxn = 1e4 + 5;   const long long INFL = 0x3f3f3f3f3f3f3f3f;   int n, c;   long long f[maxn], g[maxn];   int p[maxn], s[maxn];   int main() {     scanf( %d%d , &n, &c);     for (int i = 0; i < n; ++i) scanf( %d , &p[i]);     for (int i = 0; i < n; ++i) scanf( %d , &s[i]);     memset(f, INFL, sizeof f);     f[0] = 0;     for (int i = 0; i < n; ++i) {       for (int j = 0; j <= i; ++j) g[j] = f[j], f[j] = INFL;       for (int j = 0; j <= i; ++j) {         f[j + 1] = min(g[j] + s[i], f[j + 1]);         f[j] = min(f[j], g[j] + p[i] + (long long)j * c);       }     }     long long ans = INFL;     for (int i = 0; i <= n; ++i) ans = min(ans, f[i]);     printf( %I64d , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int n, t;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> n;     long long int f[26] = {0}, x = 0;     while (n > 1) {       int j = 0, sum = 0;       while (sum + j + 2 <= n) j = j + 2, sum += j;       f[x++] = (j - 2) / 2 + 2;       f[x++] = (j - 2) / 2 + 2;       n -= sum;     }     if (n == 1) {       f[x++] = 2;     }     long long int flag = 0;     for (int i = 0; i < x; i++) {       char c = i + 97;       while (f[i]) cout << c, f[i]--, flag = 1;     }     if (flag == 0) cout <<  x ;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using lli = long long int;   using str = string;   const ll MOD = 1e9 + 7;   void solve() {     ll a, b, c;     cin >> a >> b >> c;     cout << a + b + c - 1 <<   n ;     return;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout << setprecision(15) << fixed;     ll t = 1;     cin >> t;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int64_t MAXN = 1000000007LL;   int n;   vector<int64_t> a(5), b(5), c(5), s(5);   int64_t maxscore(int64_t s, int64_t n) {     if (s * 2 > n) return 500;     if (s * 4 > n) return 1000;     if (s * 8 > n) return 1500;     if (s * 16 > n) return 2000;     if (s * 32 > n) return 2500;     return 3000;   }   bool win(int64_t mid) {     int64_t sa = 0, sb = 0;     for (int i = 0; i < 5; i++) {       int64_t m = maxscore(s[i] + c[i] * mid, n + mid);       if (a[i] >= 0) sa += m * (250 - a[i]) / 250;       if (b[i] >= 0) sb += m * (250 - b[i]) / 250;     }     return sa > sb;   }   int main(int argc, char **argv) {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> n;     for (int i = 0; i < n; i++) {       for (int j = 0; j < 5; j++) {         int64_t x;         cin >> x;         if (x >= 0) s[j]++;         if (i == 0) a[j] = x;         if (i == 1) b[j] = x;       }     }     int64_t minx = -1;     for (int i = 0; i < 32; i++) {       bool ok = true;       for (int j = 0; j < 5; j++) {         c[j] = (i >> j) & 1;         if (c[j] && a[j] < 0) ok = false;       }       if (!ok) continue;       int64_t x;       for (x = 0; x < 100000; x++)         if (win(x)) break;       if (x == 100000) x = -1;       for (int j = 0; j < 5; j++) cerr << c[j];       cerr <<     << x << endl;       minx = x >= 0 && (minx < 0 || x < minx) ? x : minx;     }     cout << minx << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     double r1, r2, p1, p2;     double A, B;     int n;     scanf( %d , &n);     double x;     r1 = 0;     for (int i = 0; i < n; i++) {       scanf( %lf , &x);       if (x > r1) r1 = x;     }     int m;     scanf( %d , &m);     p1 = 0;     for (int i = 0; i < m; i++) {       scanf( %lf , &x);       if (x > p1) p1 = x;     }     int z;     scanf( %d , &z);     p2 = 5005;     for (int i = 0; i < z; i++) {       scanf( %lf , &x);       if (x < p2) p2 = x;     }     scanf( %lf %lf , &A, &B);     r2 = (A * p2) / (B * p1) + 1;     r2 = r1 * r1 / r2;     r2 = sqrt(r2);     printf( %.12lf n , r2);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n = 4;     int a[4];     for (int i = 0; i < 4; i++) {       cin >> a[i];     }     sort(a, a + n);     for (int i = 0; i < 3; i++) {       cout << a[3] - a[i] <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   char s[int(3e5 + 5)];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     int t;     cin >> t;     while (t--) {       int n, m;       cin >> n >> m;       cin >> (s + 1);       bool flag = true;       int tmp1 = 0, tmp = 0;       for (int i = 1; i <= m; i++)         if (s[i] ==  1 )           tmp1++;         else if (s[i] ==  ? )           tmp++;       if (tmp1 + tmp < m / 2 or tmp1 > m / 2) flag = false;       for (int i = 1; i <= m and flag == true; i++) {         char ch =  ? ;         for (int j = i; j <= n and flag == true; j += m) {           if (s[j] ==  ? ) continue;           if (ch ==  ? )             ch = s[j];           else {             if (ch == s[j])               continue;             else               flag = false;           }         }         if (flag == true)           for (int j = i; j <= n; j += m) s[j] = ch;       }       tmp1 = tmp = 0;       for (int i = 1; i <= m; i++)         if (s[i] ==  1 )           tmp1++;         else if (s[i] ==  ? )           tmp++;       if (tmp1 + tmp < m / 2 or tmp1 > m / 2) flag = false;       if (flag == true)         cout <<  YES  << endl;       else         cout <<  NO  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 30;   int a[maxn];   int num[maxn] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};   int ans;   void dfs(string s, int v, int cnt) {     int n = s.length();     if (v == n) {       ans += cnt;       return;     }     if (v < n - 2 && (s[v] -  0  + a[v]) >= 1) {       a[v + 2] += 1;       dfs(s, v + 1, cnt * num[s[v] -  0  + a[v] * 10 - 1]);       a[v + 2] -= 1;     }     dfs(s, v + 1, cnt * num[s[v] -  0  + a[v] * 10]);   }   int main() {     int kase;     cin >> kase;     while (kase--) {       ans = 0;       string s;       cin >> s;       dfs(s, 0, 1);       cout << ans - 2 << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   void c_p_c() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);   }   int32_t main() {     c_p_c();     long long int t;     cin >> t;     while (t--) {       long long int n, k;       cin >> n >> k;       vector<long long int> a(n), b(k);       for (long long int i = 0; i < (long long int)n; i++) cin >> a[i];       for (long long int i = 0; i < (long long int)k; i++) cin >> b[i];       map<long long int, long long int> pos, present;       for (auto it : b) present[it] = 1;       for (long long int i = 0; i < (long long int)n; i++) pos[a[i]] = i;       long long int ans = 1;       for (long long int i = 0; i < (long long int)k; i++) {         long long int p = pos[b[i]];         long long int temp = 0;         if (p == 0) {           if (!present[a[1]]) temp++;         } else if (p == n - 1) {           if (!present[a[n - 2]]) temp++;         } else {           if (!present[a[p - 1]]) temp++;           if (!present[a[p + 1]]) temp++;         }         ans = (ans * temp) % 998244353;         present[b[i]] = 0;       }       cout << ans <<   n ;     }     cerr <<  Time :   << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC          <<  ms n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxN = 2e5 + 9, MOD = 1e9 + 7;   int n;   long long arr[maxN], ot[maxN];   long long maxsub(long long *arr, int n) {     long long cr = LLONG_MIN / 4, maxi = LLONG_MIN / 4;     for (int i = 0; i < n; i++) {       cr = max(arr[i], cr + arr[i]);       maxi = max(maxi, cr);     }     return maxi;   }   long long trr(long long *arr, int sta) {     int ct = 0;     for (int i = sta, cnd = 1; i + 1 < n; i++, cnd *= -1) {       ot[ct++] = abs(arr[i] - arr[i + 1]) * cnd;     }     return maxsub(ot, ct);   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0), cout.tie(0);     cin >> n;     for (int i = 0; i < n; i++) {       cin >> arr[i];     }     cout << max(trr(arr, 0), trr(arr, 1)) <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 3e5 + 5;   const long long mod = 1e9 + 7;   const long long INF = 0x7f7f7f7f7f7f7f7f;   const int INFi = 0x7f7f7f7f;   long long n, m, vis[N];   void solve() {     cin >> n >> m;     for (int i = 1; i <= 3 * n; i++) vis[i] = 0;     vector<long long> match;     for (int i = 1; i <= m; i++) {       int u, v;       cin >> u >> v;       if (!vis[u] && !vis[v]) {         vis[u] = 1;         vis[v] = 1;         match.push_back(i);       }     }     if (match.size() >= n) {       cout <<  Matching             <<   n ;       for (int i = 0; i < n; i++) cout << match[i] <<    ;       cout <<   n ;       ;     } else {       cout <<  IndSet             <<   n ;       for (int i = 1, j = 0; i <= 3 * n; i++) {         if (vis[i]) continue;         if (j == n) break;         cout << i <<    ;         j++;       }       cout <<   n ;       ;     }   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cout << fixed;     cout << setprecision(15);     ;     int test = 1;     cin >> test;     for (int i = 1; i <= test; i++) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 5005, MOD = (int)1e9 + 7;   int dp[MAX][MAX], pref[MAX];   int main() {     int n, k, poc, kraj, i, j, raz;     scanf( %d%d%d%d , &n, &poc, &kraj, &k);     for (i = 1; i <= n; i++) dp[0][i] = 1;     for (i = 1; i <= k; i++) {       for (j = 1; j <= n; j++) {         pref[j] = pref[j - 1] + dp[i - 1][j];         if (pref[j] >= MOD) pref[j] -= MOD;       }       for (j = 1; j <= n; j++) {         raz = abs(j - kraj) - 1;         if (!raz)           dp[i][j] = 0;         else {           dp[i][j] = pref[min(n, j + raz)] - pref[max(0, j - raz - 1)];           if (dp[i][j] < 0)             dp[i][j] += MOD;           else if (dp[i][j] >= MOD)             dp[i][j] -= MOD;           dp[i][j] -= dp[i - 1][j];           if (dp[i][j] < 0)             dp[i][j] += MOD;           else if (dp[i][j] >= MOD)             dp[i][j] -= MOD;         }       }     }     printf( %d n , dp[k][poc]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, K;   long long dp[1005];   long long quick_sqr(long long g, int K) {     long long ret = 1;     while (K) {       if (K & 1) ret = ret * g % 1000000007;       g = g * g % 1000000007;       K >>= 1;     }     return ret;   }   long long sum[1000050], psum[1000050];   inline long long C(int a, int b) {     return sum[a] * psum[b] % 1000000007 * psum[a - b] % 1000000007;   }   int main() {     sum[0] = psum[0] = 1;     for (int i = 1; i < 1000050; i++) {       sum[i] = sum[i - 1] * i % 1000000007;       psum[i] = quick_sqr(sum[i], 1000000007 - 2);     }     scanf( %d%d%d , &n, &m, &K);     for (int i = 1; i <= n; i++) {       dp[i] = quick_sqr(i, n);       for (int k = 1; k < i; k++) {         dp[i] += 1000000007 - C(i, k) * dp[k] % 1000000007;         dp[i] %= 1000000007;       }     }     long long A = 1, ans = 0;     if (m == 1) {       printf( %I64d n , quick_sqr(K, n));       return 0;     }     if (m == 2) {       for (int j = 1, i = 0; i + j * 2 <= K && i + j <= n; j++) {         ans += dp[i + j] * dp[i + j] % 1000000007 * C(K, i) % 1000000007 *                C(K - i, j) % 1000000007 * C(K - i - j, j) % 1000000007 *                quick_sqr(i, n * (m - 2)) % 1000000007;         if (ans >= 1000000007) ans -= 1000000007;       }     }     for (int i = 1; i <= min(n, K); i++)       for (int j = 0; i + j * 2 <= K && i + j <= n; j++) {         ans += dp[i + j] * dp[i + j] % 1000000007 * C(K, i) % 1000000007 *                C(K - i, j) % 1000000007 * C(K - i - j, j) % 1000000007 *                quick_sqr(i, n * (m - 2)) % 1000000007;         if (ans >= 1000000007) ans -= 1000000007;       }     printf( %I64d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, b, mod, a[509], dp[509][509], ans;   int main() {     cin >> n >> m >> b >> mod;     dp[0][0] = 1;     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; i < n; i++) {       for (int j = 1; j <= m; j++) {         for (int k = 0; k <= b - a[i]; k++) {           dp[j][k + a[i]] = (dp[j - 1][k] + dp[j][k + a[i]]) % mod;         }       }     }     for (int i = 0; i <= b; i++) ans += dp[m][i], ans %= mod;     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     pair<int, int> p[10];     int i, j, w1, w2, cnt2;     for (i = 0; i < 4; i++) scanf( %d%d , &p[i].first, &p[i].second);     for (i = cnt2 = 0; i < 2; i++) {       w1 = w2 = 0;       for (j = 0; j < 2; j++) {         if (p[0].first > p[2].second && p[1].second > p[3].first) w1++;         if (p[0].first < p[2].second && p[1].second < p[3].first) w2++;         swap(p[2], p[3]);       }       if (w2) cnt2++;       if (w1 == 2) break;       swap(p[0], p[1]);     }     if (i < 2)       puts( Team 1 );     else if (cnt2 == 2)       puts( Team 2 );     else       puts( Draw );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int j, t;     cin >> t;     for (j = 0; j < t; j++) {       long long int n;       cin >> n;       long long int a[n], i;       for (i = 0; i < n; i++) cin >> a[i];       long long int p = a[0], sum = a[0];       for (i = 1; i < n; i++) {         if (p < 0 && a[i] < 0) {           if (a[i] > p) {             sum += a[i];             sum -= p;             p = a[i];           }         } else if (p < 0 && a[i] > 0) {           sum += a[i];           p = a[i];         } else if (p > 0 && a[i] > 0) {           if (a[i] > p) {             sum -= p;             sum += a[i];             p = a[i];           }         } else if (p > 0 && a[i] < 0) {           sum += a[i];           p = a[i];         }       }       cout << sum << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int a[200005];   long long oddpref[200005];   long long evenpref[200005];   long long evensuff[200005];   long long oddsuff[200005];   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     for (int i = 1; i <= n; i++) {       oddpref[i] = oddpref[i - 1];       evenpref[i] = evenpref[i - 1];       if (i % 2)         oddpref[i] += a[i];       else         evenpref[i] += a[i];     }     for (int i = n; i >= 1; i--) {       oddsuff[i] = oddsuff[i + 1];       evensuff[i] = evensuff[i + 1];       if (i % 2)         oddsuff[i] += a[i];       else         evensuff[i] += a[i];     }     int cnt = 0;     for (int i = 1; i <= n; i++) {       if (oddpref[i - 1] + evensuff[i + 1] == evenpref[i - 1] + oddsuff[i + 1]) {         cnt++;       }     }     cout << cnt;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[501102];   int ans, cnt, sum, d;   void solve() {     ans = 0;     cnt = 0;     sum = 0;     d = 0;     int n;     cin >> n;     for (int i = 1; n >= i; i++) {       cin >> a[i];       if (a[i] % 2 == 1) {         ans++;         if (a[i] * n % 2 == 1) d = 1;       } else         cnt++;       sum += a[i];     }     if (ans >= cnt && ans != n || sum % 2 == 1 || d != 0 ||         ans != 0 && cnt != 0) {       cout <<  YES  << endl;       return;     }     cout <<  NO  << endl;   }   int main() {     int t;     cin >> t;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  stack:200000000 )   #pragma GCC optimize( Ofast )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native )   using namespace std;   long long freq[3000005], mul[3000005], n, q, x;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n;     for (int i = n; i--; ++freq[x]) cin >> x;     for (int i = 1; i < 3000005; ++i)       if (freq[i])         for (int j = i; j < 3000005; j += i)           mul[j] += freq[i] * (freq[j / i] - (i == j / i));     for (int i = 1; i < 3000005; ++i) mul[i] += mul[i - 1];     for (cin >> q; q--; cout << n * (n - 1) - mul[x - 1] <<   n ) cin >> x;   }
#include <bits/stdc++.h>   using namespace std;   #define fore(i, a, b) for(int i = a; i <= b; i++)   #define Fore(i, a, b) for(int i = a; i < b; i++)   #define pii pair<int, int>   #define fi first   #define se second   #define MP make_pair   #define EP emplace_back   #define li long long      const int MAXN = 2100, mod = 998244353;      inline int input(){       char c = getchar(); int o; bool f = 0;       while(c > 57 || c < 48)           f |= (c ==  - ), c = getchar();       for(o = 0; c > 47 && c < 58; c = getchar())           o = (o << 1)+(o << 3)+(c - 48);       return f ? -o : o;   }      li C[MAXN * 2][MAXN * 2];      int main(){       int n = input(), m = input();       li ans = 0;       C[0][0] = 1;       fore(i, 1, n + m){           C[i][0] = 1;           fore(j, 1, i)               C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;               // cout << C[i][j] <<    n [j == i];       }       Fore(r, 1, n){           li F = 0;           for(int c = m - 1; c >= 1; c--){               F = (F + C[n - r + m - c - 1][n - r] * C[n - r - 1 + c][n - r - 1] % mod) % mod;               ans = (ans + F * (C[r + c - 1][r] * C[r + m - c - 1][r - 1] % mod) % mod) % mod;           }       }       swap(n, m);       Fore(r, 1, n){           li F = 0;           for(int c = m - 1; c >= 1; c--){               ans = (ans + F * (C[r + c - 1][r] * C[r + m - c - 1][r - 1] % mod) % mod) % mod;               F = (F + C[n - r + m - c - 1][n - r] * C[n - r - 1 + c][n - r - 1] % mod) % mod;           }       }       printf( %lld , (ans << 1) % mod);   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long n, x;     cin >> n;     long long a[n + 1];     for (long long i = 0; i < n; i++) {       cin >> a[i + 1];     }     long long dp[n + 2];     dp[0] = 0;     dp[n + 1] = 0;     for (long long i = 1; i <= n; i++) dp[i] = min(dp[i - 1] + 1, a[i]);     for (long long i = n; i >= 1; i--) dp[i] = min(dp[i + 1] + 1, dp[i]);     long long mx = dp[1];     for (long long i = 2; i <= n; i++) mx = max(mx, dp[i]);     cout << mx;     return;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     ;     long long t;     t = 1;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, ans, u, v, i, root_u, root_v, arr[100001], len[100001], c[100001],       k;   vector<pair<long long, long long> > in;   long long find(long long x) {     if (arr[x] == x) return x;     return arr[x] = find(arr[x]);   }   int main() {     cin >> n >> k;     for (i = 1; i <= n; i++) arr[i] = i, len[i] = 1;     for (i = 0; i < k; i++) {       cin >> u >> v;       root_u = find(u);       root_v = find(v);       if (root_u != root_v) arr[root_u] = root_v, len[root_v] += len[root_u];       c[u]++;     }     for (i = 1; i <= n; i++)       if (arr[i] != i) c[find(i)] += c[i];     for (i = 1; i <= n; i++)       if (arr[i] == i) ans += (c[i] - len[i] + 1);     cout << ans;     return 0;   }