malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int maxh = 200 * 1000 + 5;   struct item {     int pos, hash;     item(int pos, int hash) : pos(pos), hash(hash) {}   };   bool operator<(item a, item b) { return a.pos < b.pos; }   int n, m, h;   set<item> S[maxh];   map<int, int> M;   int pos[maxh];   int Len[maxh];   int Base[maxh];   bool used[maxh];   long long add(int x, int hash) {     int base = Base[hash];     set<item>::iterator it = S[base].lower_bound(item(pos[hash], hash));     if (it == S[base].end()) {       it = S[base].begin();     }     int nhash = it->hash;     M[x] = nhash;     S[base].erase(it);     long long res = pos[nhash] - pos[hash];     if (res < 0) {       res += Len[base];     }     return res;   }   void del(int x) {     int base = Base[M[x]];     S[base].insert(item(pos[M[x]], M[x]));   }   int main() {     scanf( %d%d%d , &h, &m, &n);     for (int i = 0; i < h; ++i) {       if (used[i]) {         continue;       }       for (int j = i, p = 0; !used[j]; j += m, j %= h, ++p) {         S[i].insert(item(p, j));         pos[j] = p;         Base[j] = i;         used[j] = 1;       }       Len[i] = (int)S[i].size();     }     long long res = 0;     for (int i = 0; i < n; ++i) {       char op;       int id;       scanf(  n%c %d , &op, &id);       if (op ==  + ) {         int hash;         scanf( %d , &hash);         res += add(id, hash);       } else {         del(id);       }     }     printf( %I64d n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long const MAXN = 5e1 + 8;   long long const INF = 3e3 + 8;   long long const delta = 1000000007;   long long a[MAXN];   long long dp[MAXN][MAXN][INF];   double calc(long long t, long long n, long long b) {     double ans = t;     for (long long i = b + 1; i <= n; i++) ans /= (double)i;     for (long long i = 1; i <= n - b; i++) ans *= (double)i;     return ans;   }   int main() {     std::ios::sync_with_stdio(0);     ;     cin.tie(0);     cout.tie(0);     long long n;     cin >> n;     for (long long i = 1; i <= n; i++) cin >> a[i];     long long p;     cin >> p;     cout.precision(10);     cout << fixed;     double ans = 0;     dp[0][0][0] = 1;     for (long long i = 1; i <= n; i++) {       for (long long j = 0; j <= n; j++) {         for (long long k = 0; k < INF; k++) {           dp[i][j][k] = dp[i - 1][j][k];           if (j && k >= a[i]) dp[i][j][k] += dp[i - 1][j - 1][k - a[i]];         }       }     }     for (long long i = 1; i <= p; i++) {       for (long long j = 1; j <= n; j++) ans += calc(dp[n][j][i], n, j);     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 5005;   const int K = 100005;   int n, m, k;   int t, p;   int l[N], c[N], x[K];   int main() {     scanf( %d%d%d , &n, &m, &k);     x[0] = 0;     for (int i = 1; i <= k; ++i) {       scanf( %d%d%d , &t, &p, &x[i]);       if (t == 1)         l[--p] = i;       else         c[--p] = i;     }     for (int i = 0; i < n; ++i) {       for (int j = 0; j < m; ++j) printf( %d  , x[max(l[i], c[j])]);       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, K;   long double ans, s;   int R[1000010], data[100010];   int v[1000010], c[1000010];   int STv[20][1000010], STc[20][1000010];   int calcv(int l, int r) {     int delta = r - l + 1;     int t = log(delta) / log(2);     return max(STv[t][l], STv[t][r - (1 << t) + 1]);   }   int calcc(int l, int r) {     int delta = r - l + 1;     int t = log(delta) / log(2);     return min(STc[t][l], STc[t][r - (1 << t) + 1]);   }   int main() {     scanf( %d%d , &N, &K);     for (int i = 1; i <= N; i++) scanf( %d , &v[i]), v[i] *= 100;     for (int i = 1; i <= N; i++) scanf( %d , &c[i]);     for (int i = 1; i <= N; i++) STv[0][i] = v[i], STc[0][i] = c[i];     for (int step = 1; step <= 19; step++)       for (int i = 1; i <= N; i++) {         STv[step][i] = STv[step - 1][i];         STc[step][i] = STc[step - 1][i];         int x = i + (1 << (step - 1));         if (x <= N) {           STv[step][i] = max(STv[step][i], STv[step - 1][x]);           STc[step][i] = min(STc[step][i], STc[step - 1][x]);         }       }     R[0] = 1;     for (int l = 1; l <= N; l++) {       R[l] = R[l - 1];       for (int r = max(R[l - 1], l); r <= N; r++)         if (calcv(l, r) <= calcc(l, r))           R[l] = r;         else           break;     }     for (int l = 1; l <= N; l++) {       if (R[l] < N && min(calcv(l, R[l]), calcc(l, R[l])) <                           min(calcv(l, R[l] + 1), calcc(l, R[l] + 1)))         R[l]++;       data[l] = min(calcv(l, R[l]), calcc(l, R[l]));     }     sort(data + 1, data + N + 1);     s = double(K) / (N - K + 1);     for (int l = 1; l + K - 1 <= N; l++) {       s = s / (N - l + 1) * (N - K - l + 2);       ans = ans + data[l] * s;     }     printf( %.15lf , double(ans));   }
#include <bits/stdc++.h>   int main() {     int i;     char a[1000];     gets(a);     for (i = 0; i < strlen(a); i++) {       printf( %c , a[i]);     }     for (i = strlen(a) - 1; i >= 0; i--) {       printf( %c , a[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 42, K = 11;   int n, k, cnt, mark[N], nw[K];   vector<long long> v[K], mask[K];   void do_it(long long u, int x) {     for (int i = 0; i < nw[x] + 1; i++) {       int cnt = i + __builtin_popcountll(u & mask[x].back());       v[x + 1].push_back((u & (1ll << n) - 1 - mask[x].back()) | mask[x][cnt]);     }   }   int main() {     cin >> n >> k;     for (int i = 0; i < k; i++) {       int x, u;       long long msk = 0;       mask[i].push_back(0);       cin >> x;       for (int j = 0; j < x; j++) {         cin >> u;         u--;         msk |= (1ll << u);         mask[i].push_back(msk);         if (!mark[u]) {           cnt++;           nw[i]++;           mark[u] = 1;         }       }     }     v[0].push_back(0);     for (int i = 0; i < k; i++) {       for (int j = 0; j < v[i].size(); j++) {         do_it(v[i][j], i);       }     }     if (n != cnt && n > 1) return cout <<  REJECTED  << endl, 0;     for (int i = 0; i < v[k].size(); i++) {       int cnt = __builtin_popcountll(v[k][i]);       if ((1ll << cnt) - 1 != v[k][i]) return cout <<  REJECTED  << endl, 0;     }     cout <<  ACCEPTED  << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long PRIME = 1000000007;   long long n, m, k;   long long maxm = (long long)(-10e13);   long long a[100005][6];   long long max_in_range[100005][6][20];   long long ans[6];   long long times(long long length) {     long long cnt = 0;     while (length >= 2) {       length /= 2;       cnt++;     }     return cnt;   }   void calculate(long long index, long long length) {     long long t = times(length);     for (long long d = 1; d <= m; d++) {       ans[d] = max(max_in_range[index][d][t],                    max_in_range[index + length - (1 << t)][d][t]);     }   }   long long query(long long index, long long length) {     long long t = times(length);     long long sum = 0;     for (long long d = 1; d <= m; d++) {       sum += max(max_in_range[index][d][t],                  max_in_range[index + length - (1 << t)][d][t]);     }     return sum;   }   long long search(long long index, long long startlength, long long endlength) {     if (startlength == endlength) {       return startlength;     }     if (endlength - startlength == 1) {       if (query(index, endlength) <= k) {         return endlength;       }       return startlength;     }     long long mid = (startlength + endlength) / 2;     long long val = query(index, mid);     if (val > k) {       return search(index, startlength, mid - 1);     } else {       return search(index, mid, endlength);     }   }   void solve() {     cin >> n >> m >> k;     for (long long i = 1; i <= n; i++) {       for (long long j = 1; j <= m; j++) {         cin >> a[i][j];       }     }     long long maxallowed = 0;     for (long long p = 0; p < 20; p++) {       for (long long i = 1; i <= n; i++) {         long long sum = 0;         for (long long d = 1; d <= m; d++) {           if (p == 0) {             max_in_range[i][d][p] = a[i][d];           } else if (i + (1 << p) - 1 > n) {             max_in_range[i][d][p] = (long long)(10e13);           } else {             max_in_range[i][d][p] =                 max(max_in_range[i][d][p - 1],                     max_in_range[i + (1 << (p - 1))][d][p - 1]);           }           sum += max_in_range[i][d][p];         }         if (sum <= k) {           maxallowed = p;         }       }     }     for (long long i = 1; i <= n; i++) {       long long sum = 0;       for (long long d = 1; d <= m; d++) {         sum += max_in_range[i][d][maxallowed];       }       if (sum > k) {         continue;       } else {         long long l = search(i, (1 << maxallowed), (1 << (maxallowed + 1)) - 1);         if (l >= maxm) {           calculate(i, l);           maxm = l;         }       }     }     for (long long d = 1; d <= m; d++) {       cout << ans[d] <<    ;     }   }   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int max(long long int a, long long int b) {     if (a >= b)       return a;     else       return b;   }   long long int min(long long int a, long long int b) {     if (a >= b)       return b;     else       return a;   }   long long int diff(long long int a, long long int b) {     if (a >= b)       return a - b;     else       return b - a;   }   long long int mod(long long int a) {     if (a >= 0)       return a;     else       return -a;   }   void pairsort(int a[], int b[], int n) {     pair<int, int> pairt[n];     for (int i = 0; i < n; i++) {       pairt[i].first = a[i];       pairt[i].second = b[i];     }     sort(pairt, pairt + n);     for (int i = 0; i < n; i++) {       a[i] = pairt[i].first;       b[i] = pairt[i].second;     }   }   int gcd(int a, int b) {     if (b == 0) return a;     return gcd(b, a % b);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     char c;     cin >> c;     string s1, s2;     char s[9] = { 6 ,  7 ,  8 ,  9 ,  T ,  J ,  Q ,  K ,  A };     cin >> s1 >> s2;     int ind1, ind2;     if (s1[1] == s2[1]) {       for (int i = 0; i < 9; i++)         if (s[i] == s1[0]) ind1 = i;       for (int i = 0; i < 9; i++)         if (s[i] == s2[0]) ind2 = i;       if (ind1 > ind2)         cout <<  YES ;       else         cout <<  NO ;     } else {       if (s1[1] == c)         cout <<  YES ;       else         cout <<  NO ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct p {     int x, y, z;   };   int c[102][102][102] = {0};   bool ck(int x, int y, int z) {     if (!c[x][y][z]) return false;     if (c[x - 1][y][z] && c[x + 1][y][z]) return true;     if (c[x][y - 1][z] && c[x][y + 1][z]) return true;     if (c[x][y][z - 1] && c[x][y][z + 1]) return true;     if (c[x - 1][y][z] && c[x][y + 1][z] && !c[x - 1][y + 1][z]) return true;     if (c[x - 1][y][z] && c[x][y][z + 1] && !c[x - 1][y][z + 1]) return true;     if (c[x][y - 1][z] && c[x + 1][y][z] && !c[x + 1][y - 1][z]) return true;     if (c[x][y - 1][z] && c[x][y][z + 1] && !c[x][y - 1][z + 1]) return true;     if (c[x][y][z - 1] && c[x + 1][y][z] && !c[x + 1][y][z - 1]) return true;     if (c[x][y][z - 1] && c[x][y + 1][z] && !c[x][y + 1][z - 1]) return true;     return false;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     int n, m, k;     cin >> n >> m >> k;     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) {         string r;         cin >> r;         for (int l = 1; l <= k; ++l) c[i][j][l] = r[l - 1] ==  1  ? 1 : 0;       }     }     int ans = 0;     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) {         for (int l = 1; l <= k; ++l) {           if (ck(i, j, l)) ans++;         }       }     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   const int BIT = (1 << 17), M = 110, N = 25;   int n, m, cnt[BIT], a[M];   long long f[BIT][N], b[N], p[N], year;   void solve(int x) {     memset(f, 0, sizeof(f));     f[0][0] = 1;     int maxb = (1 << n);     for (int i = 0; i < maxb; i++) {       for (int j = 0; j <= n; j++) {         int y = cnt[i] + 1;         if (b[y]) {           if ((a[b[y]] & i) != a[b[y]]) continue;           if ((1 << (b[y] - 1) & i) == (1 << b[y] - 1)) continue;           f[i | (1 << b[y] - 1)][j] += f[i][j];         } else {           for (int k = 1; k <= n; k++) {             if (!(i & (1 << k - 1))) {               if ((a[k] & i) != a[k]) continue;               if (k == x)                 f[i | (1 << k - 1)][y] += f[i][j];               else                 f[i | (1 << k - 1)][j] += f[i][j];             }           }         }       }     }   }   int main() {     scanf( %d%lld%d , &n, &year, &m);     year -= 2000;     for (int i = 1; i < BIT; i++) cnt[i] = cnt[i ^ (i & (-i))] + 1;     for (int i = 1; i <= m; i++) {       int x, y;       scanf( %d%d , &x, &y);       a[y] |= (1 << x - 1);     }     for (int i = 1; i <= n; i++) {       solve(i);       long long sum = 0;       for (int j = 1; j <= n; j++) {         if (!b[j] && sum + f[(1 << n) - 1][j] >= year) {           b[j] = i;           p[i] = j;           year -= sum;           break;         }         sum += f[(1 << n) - 1][j];       }       if (!p[i]) {         puts( The times have changed );         return 0;       }     }     for (int i = 1; i <= n; i++) printf( %lld  , p[i]);     puts(  );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   multiset<int> all[40];   long long s[40];   int getpos(int x) {     int ret = 0;     while ((1 << ret) < x) ret++;     return ret;   }   void check() {     long long tot = 0LL;     int ret = 0;     for (int i = 0; i <= 31; i++) {       ret += all[i].size();       ret -= (all[i].size() && *(all[i].begin()) > 2 * tot);       tot += s[i];     }     cout << ret <<   n ;   }   int main() {     int q;     cin >> q;     while (q--) {       string op;       int x;       cin >> op >> x;       int id = getpos(x);       if (op ==  + ) {         s[id] += x;         all[id].insert(x);       } else {         s[id] -= x;         all[id].erase(all[id].find(x));       }       check();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, c, r[200001], u, v, i, t, k;   vector<long long> graph[200001], ans;   bool dfs(long long x, long long p) {     long long s = 0;     for (auto i : graph[x])       if (i != p) s += dfs(i, x);     if (r[x] && !s) ans.push_back(x);     return s + (long long)(r[x] && r[p]);   }   int main() {     cin >> n;     for (i = 0; i < n - 1; i++) {       cin >> u >> v >> t, graph[u].push_back(v), graph[v].push_back(u);       if (t == 2) r[u] = 1, r[v] = 1;     }     dfs(1, 0);     for (cout << ans.size() << endl, i = 0; i < ans.size(); i++)       cout << ans[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int n0 = 1003, m = 1e5, mod = 998244353;   int n, k, a[n0], dp[2][n0], b[n0];   int calc(int gap) {     for (int i = 1; i <= n; i++)       b[i] = upper_bound(a + 1, a + n + 1, a[i] - gap) - a - 1;     memset(&dp, 0, sizeof(dp));     for (int j = 0; j <= n; j++) dp[0][j] = 1;     for (int i = 1; i <= k; i++) {       dp[i & 1][0] = 0;       for (int j = 1; j <= n; j++) {         int &x = dp[i & 1][j];         x = dp[i & 1][j - 1] + dp[(i - 1) & 1][b[j]];         x = (x >= mod) ? (x - mod) : x;       }     }     return dp[k & 1][n];   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0);     cin >> n >> k;     for (int i = 1; i <= n; i++) cin >> a[i];     sort(a + 1, a + n + 1);     int res = 0;     for (int gap = 1; gap <= m / (k - 1); gap++) {       res += calc(gap);       if (res >= mod) res -= mod;     }     cout << res;   }
#include <bits/stdc++.h>   using namespace std;   struct Room {     int length, width, height, total_length;   } room[500];   struct Wallpaper {     int length, width, price;   } wallpaper[500];   int main() {     int n, m, i, j, ans, tmp, price, ret;     cin >> n;     for (i = 0; i < n; ++i) {       cin >> room[i].length >> room[i].width >> room[i].height;       room[i].total_length = 2 * (room[i].length + room[i].width);     }     cin >> m;     for (i = 0; i < m; ++i)       cin >> wallpaper[i].length >> wallpaper[i].width >> wallpaper[i].price;     for (ret = i = 0; i < n; ++i) {       for (price = 500 * 500 * 500, ans = j = 0; j < m; ++j) {         tmp = wallpaper[j].length / room[i].height;         tmp *= wallpaper[j].width;         if (tmp == 0) continue;         ans = (room[i].total_length / tmp +                (room[i].total_length % tmp == 0 ? 0 : 1)) *               wallpaper[j].price;         price = min(price, ans);       }       ret += price;     }     cout << ret << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, a, b, diff;     cin >> n >> a >> b;     vector<long long int> v;     long long int arr[n];     for (long long int i = 0; i < n; i++) {       cin >> arr[i];       v.push_back(arr[i]);     }     sort(v.begin(), v.end());     diff = v[n - a] - v[b - 1];     if (diff < 0) {       cout <<  0  << endl;     } else {       cout << diff << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int n, q, k;   vector<int> v[1000010];   int lastans = 0, res[1000010];   void dfs(int np, int fath, int val) {     res[np] = val;     for (auto &x : v[np]) {       if (x == fath) continue;       dfs(x, np, min(val, x));     }   }   int main() {     scanf( %d%d , &n, &q);     for (int i = 1, ti, tj; i < n; i++) {       scanf( %d%d , &ti, &tj);       v[ti].push_back(tj);       v[tj].push_back(ti);     }     int a, b;     scanf( %d%d , &a, &b);     b = b % n + 1;     dfs(b, 0, b);     lastans = 0;     k = b;     for (int i = 2, ti, tj; i <= q; i++) {       scanf( %d%d , &ti, &tj);       tj = (tj + lastans) % n + 1;       if (ti == 1)         k = min(k, res[tj]);       else         printf( %d n , lastans = min(k, res[tj]));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[100];   long long b[100];   vector<long long> pos[101];   int main() {     long long i, j, k, l, m, n, t;     scanf( %lld , &n);     scanf( %lld , &k);     for (i = 0; i < n; i++) {       scanf( %lld , &a[i]);       pos[a[i]].push_back(i);     }     long long sum = 0, count = 0;     long long flag = 0;     for (i = 1; i <= 100; i++) {       for (j = 0; j < pos[i].size(); j++) {         sum = sum + a[pos[i][j]];         if (sum > k) {           flag = 1;           break;         }         b[count++] = pos[i][j];       }       if (flag == 1) break;     }     cout << count << endl;     for (j = 0; j < count; j++) cout << b[j] + 1 <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dx[] = {0, 0, 1, -1, -1, -1, 1, 1};   int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};   template <class T>   inline T biton(T n, T pos) {     return n | ((T)1 << pos);   }   template <class T>   inline T bitoff(T n, T pos) {     return n & ~((T)1 << pos);   }   template <class T>   inline T ison(T n, T pos) {     return (bool)(n & ((T)1 << pos));   }   template <class T>   inline T gcd(T a, T b) {     while (b) {       a %= b;       swap(a, b);     }     return a;   }   template <typename T>   string NumberToString(T Number) {     ostringstream second;     second << Number;     return second.str();   }   inline int nxt() {     int aaa;     scanf( %d , &aaa);     return aaa;   }   inline long long int lxt() {     long long int aaa;     scanf( %lld , &aaa);     return aaa;   }   inline double dxt() {     double aaa;     scanf( %lf , &aaa);     return aaa;   }   template <class T>   inline T bigmod(T p, T e, T m) {     T ret = 1;     for (; e > 0; e >>= 1) {       if (e & 1) ret = (ret * p) % m;       p = (p * p) % m;     }     return (T)ret;   }   int ar[1000010];   long long F(long long int limit, long long int a, long long int b) {     if (limit < a) return 1LL;     long long int sum = 1LL;     long long int x = 0;     while (true) {       if (x + a > limit) break;       long long int temp = (limit - x) / a;       sum += temp;       long long int r = (a * temp) + x;       if (r - b < 0) break;       temp = (r + b - 1) / b;       temp--;       sum += temp;       r -= temp * b;       x = r;       if (x % a == 0) break;     }     return sum;   }   long long int get(long long int st, long long int len) {     long long int sum = (len * len + len) / 2LL;     sum *= st;     return sum;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     long long n, a, b;     cin >> n >> a >> b;     long long limit = min(a + b - 2, n);     long long sum = 0;     for (long long i = 0; i <= limit; i++) {       sum += F(i, a, b);     }     limit++;     long long int gc = gcd(a, b);     while (limit <= n) {       if (limit % gc == 0) break;       sum += (limit / gc) + 1;       limit++;     }     long long int upperLimit = n;     while (upperLimit >= limit) {       sum += (upperLimit / gc) + 1;       if (upperLimit % gc == 0) break;       upperLimit--;     }     if (upperLimit > limit) {       long long int diff = (upperLimit - limit);       sum += diff;       diff /= gc;       long long int chunk = limit * diff + get(gc, diff - 1);       sum += chunk;     }     cout << sum << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k, A[2005], DP[2005];   inline int ok(int X) {     memset(DP, 0, sizeof(DP));     int i, j;     long long l1, r1, l2, r2;     for (i = 1; i <= n; i++) DP[i] = i - 1;     for (i = 2; i <= n; i++)       if (abs(A[i] - A[i - 1]) <= X)         DP[i] = 0;       else         break;     for (i = 1; i <= n; i++)       for (j = i + 1; j <= n; j++) {         l1 = (long long)A[i] - (long long)X * (j - i - 1);         r1 = (long long)A[i] + (long long)X * (j - i - 1);         l2 = A[j] - X;         r2 = A[j] + X;         if (!(l2 > r1 || l1 > r2)) DP[j] = min(DP[j], DP[i] + j - i - 1);       }     for (i = 1; i <= n; i++)       if (DP[i] + n - i <= k) return 1;     return 0;   }   int cbin() {     int i, step = (1 << 30);     for (i = -1; step; step >>= 1)       if (!ok(i + step)) i += step;     return ++i;   }   int main() {     scanf( %d%d , &n, &k);     int i;     for (i = 1; i <= n; i++) scanf( %d , &A[i]);     printf( %d n , cbin());     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N;   int A[100005];   int G[100005];   int m;   int main() {     scanf( %d , &N);     for (int i = 0; i < N; ++i) scanf( %d , &A[i]);     for (int i = 0; i < N; ++i) {       if (i < N / 2) {         if (A[i] - i >= 1) ++G[A[i] - i];       } else {         if (A[i] - (N - i - 1) >= 1) ++G[A[i] - (N - i - 1)];       }     }     m = 0;     for (int i = 0; i <= 1e5; ++i)       if (G[i] >= m) m = G[i];     printf( %d , N - m);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int size = 1007;   const long long modulo = 1000000007;   const long long oo = 1e18;   const double EPS = 1e-13;   const double PI = acos(-1.0);   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int n, m;     cin >> n >> m;     vector<vector<int> > g(n);     vector<long long> cost(n), v(n);     for (int i = 0; i < n; i++) cin >> v[i];     while (m--) {       int a, b;       cin >> a >> b;       --a;       --b;       cost[a] += v[b];       cost[b] += v[a];       g[a].push_back(b);       g[b].push_back(a);     }     vector<bool> was(n, false);     long long ans = 0;     for (int h = 0; h < n; h++) {       int ver = -1;       for (int i = 0; i < n; i++)         if (!was[i] && (ver < 0 || v[ver] < v[i])) ver = i;       was[ver] = true;       ans += cost[ver];       for (int i = 0; i < g[ver].size(); i++) {         int to = g[ver][i];         if (!was[to]) {           cost[ver] -= v[to];           cost[to] -= v[ver];         }       }     }     cout << ans << endl;     return 0;   }