malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int a, b, c, p, k;     cin >> a >> b >> c;     if (c != 0) {       p = b - a;       k = p / c;       if (p % c == 0) {         if (k >= 0)           cout <<  YES  << endl;         else           cout <<  NO  << endl;       } else         cout <<  NO  << endl;     } else if (c == 0) {       if (a == b)         cout <<  YES  << endl;       else         cout <<  NO  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100005;   int pos[maxn];   int n, x, y;   int main() {     int i, j;     while (scanf( %d , &n) != EOF) {       memset(pos, -1, sizeof(pos));       for (i = 1; i <= n; i++) {         scanf( %d%d , &x, &y);         int ans = 0;         for (j = 1; j * j <= x; j++) {           if (x % j == 0) {             if (y == 0) {               ans++;               pos[j] = i;               if (x / j != j) ans++;               pos[x / j] = i;               continue;             }             if (pos[j] < i - y) ans++;             pos[j] = i;             if (x / j != j && pos[x / j] < i - y) ans++;             pos[x / j] = i;           }         }         printf( %d n , ans);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1000000007;   const int MAX = 5000001;   unsigned int arr[MAX], P[MAX];   void sieve() {     unsigned int i, j, t, k;     arr[0] = arr[1] = 0;     for (i = 2; i < MAX; i++) arr[i] = i;     for (i = 4; i < MAX; i += 2) arr[i] = 2;     for (i = 3; i * i <= MAX; i += 2)       if (arr[i] == i)         for (j = i * i; j < MAX; j += 2 * i)           if (arr[j] == j) arr[j] = i;     for (i = 2; i < 5000001; i++) P[i] = P[i / arr[i]] + 1;     for (i = 2; i < 5000001; i++) P[i] += P[i - 1];   }   int main(void) {     sieve();     unsigned int tc, i, a, b;     scanf( %u , &tc);     for (i = 1; i <= tc; i++) {       scanf( %u %u , &a, &b);       printf( %u n , P[a] - P[b]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, i;   long long s, ans;   int x[200000], y[200000];   long long a[200000], b[200000], c[200000], d[200000];   void count() {     s = 0;     for (i = 1; i <= n; i++) b[i] = c[i] = d[i] = 0;     for (i = 1; i < n; i++) a[i] = a[i + 1] - a[i];     for (i = 1; i < n; i++) {       b[i] = b[i - 1] + i * a[i];       c[i] = c[i - 1] + i * a[i] * a[i];     }     for (i = 2; i < n; i++) d[i] = d[i - 1] + 2 * a[i] * b[i - 1];     for (i = 1; i < n; i++) s += c[i] + d[i];   }   int main() {     scanf( %d , &n);     for (i = 1; i <= n; i++) scanf( %d%d , &x[i], &y[i]);     x[0] = y[0] = -200000000;     for (i = 0; i <= n; i++) a[i] = x[i];     sort(a, a + n + 1);     count();     ans += s;     for (i = 0; i <= n; i++) a[i] = y[i];     sort(a, a + n);     count();     ans += s;     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int64_t solve(int m, int n) {     if (m > n) swap(m, n);     if (m == 1) {       if (n <= 3) return 0;       if (n % 6 == 2 || n % 6 == 4) return n - 2;       if (n % 6 == 1 || n % 6 == 5) return n - 1;       if (n % 6 == 3) return n - 3;       return n;     }     if (m == 2) {       if (n <= 2) return 0;       if (n == 3) return 4;       if (n == 4) return 8;       if (n == 7) return 12;       return n * 2;     }     int64_t res = 1LL * m * n;     if (res % 2 == 1) res -= 1;     return res;   }   int main() {     int n, m;     cin >> n >> m;     cout << solve(n, m) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int gi() {     int data = 0, m = 1;     char ch = 0;     while (ch !=  -  && (ch <  0  || ch >  9 )) ch = getchar();     if (ch ==  - ) {       m = 0;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       data = (data << 1) + (data << 3) + (ch ^ 48);       ch = getchar();     }     return (m) ? data : -data;   }   int SS, TT, P0, n, m, K, Init[405], Flow, Cost, A[405], C[405];   struct _Edge {     int to, next, flow;     int cost;   } Edge[3 * 405 * 405];   int head[405], CNT, S, T;   int dis[405], flw[405], frm[405];   bool vis[405];   queue<int> Q;   inline void AddEdge(int u, int v, int fl, int cs) {     Edge[++CNT] = (_Edge){v, head[u], fl, cs};     head[u] = CNT;     Edge[++CNT] = (_Edge){u, head[v], 0, -cs};     head[v] = CNT;   }   inline bool spfa() {     for (int i = 1; i <= TT; ++i) dis[i] = 1e9 + 7;     dis[SS] = 0;     flw[SS] = 1e9;     vis[SS] = true;     Q.push(SS);     while (!Q.empty()) {       int u = Q.front();       Q.pop();       for (int e = head[u]; e; e = Edge[e].next) {         int v = Edge[e].to;         if (Edge[e].flow && dis[v] > dis[u] + Edge[e].cost) {           dis[v] = dis[u] + Edge[e].cost;           frm[v] = e;           flw[v] = min(flw[u], Edge[e].flow);           if (!vis[v]) vis[v] = true, Q.push(v);         }       }       vis[u] = false;     }     if (dis[TT] == 1e9 + 7) return false;     for (int x = TT; x ^ SS; x = Edge[frm[x] ^ 1].to) {       Edge[frm[x]].flow -= flw[TT];       Edge[frm[x] ^ 1].flow += flw[TT];     }     return true;   }   int main() {     n = gi();     K = gi();     CNT = 1;     P0 = 2 * n + 1;     S = P0 + 1;     T = S + 1;     for (int i = 1; i <= n; i++) A[i] = gi();     for (int i = 1; i <= n; i++) C[i] = gi();     AddEdge(S, P0, K, 0);     for (int i = 1; i <= n; ++i)       AddEdge(P0, i, 1, C[A[i]]), AddEdge(i + n, T, 1e9 + 7, 0);     for (int i = 1; i <= n; ++i)       Init[i]--, Init[i + n]++, AddEdge(i, i + n, 1e9 + 7, 0);     for (int i = 1; i <= n; ++i)       for (int j = i + 1; j <= n; ++j)         AddEdge(i + n, j, 1e9 + 7, (A[i] ^ A[j]) ? C[A[j]] : 0);     SS = T + 1;     TT = SS + 1;     int Delay = 0;     for (int i = 1; i <= T; i++)       if (Init[i] < 0)         AddEdge(i, TT, -Init[i], 0);       else if (Init[i] > 0)         AddEdge(SS, i, Init[i], 0), Delay += Init[i];     AddEdge(T, S, 1e9 + 7, 0);     while (spfa()) Flow += flw[TT], Cost += flw[TT] * dis[TT];     if (Flow ^ Delay)       return puts( -1 ), 0;     else       printf( %d n , Cost);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 100002;   map<int, int> cnt[MAX];   vector<int> adj[MAX];   long long ans[MAX];   int color[MAX];   int max_el[MAX];   void dfs(int node, int par) {     cnt[node][color[node]] = true;     max_el[node] = 1;     ans[node] = color[node];     for (int i = 0; i < adj[node].size(); i++) {       int child = adj[node][i];       if (child != par) {         dfs(child, node);         if (cnt[node].size() < cnt[child].size()) {           swap(cnt[node], cnt[child]);           max_el[node] = max_el[child];           ans[node] = ans[child];         }         for (pair<int, int> p : cnt[child]) {           cnt[node][p.first] += p.second;           if (cnt[node][p.first] == max_el[node])             ans[node] += p.first;           else if (cnt[node][p.first] > max_el[node]) {             max_el[node] = cnt[node][p.first];             ans[node] = p.first;           }         }       }     }   }   int main() {     int n, u0, v0;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> color[i];     }     for (int i = 0; i < n - 1; i++) {       cin >> u0 >> v0;       adj[u0].push_back(v0);       adj[v0].push_back(u0);     }     dfs(1, 0);     for (int i = 1; i <= n; i++) {       cout << ans[i] <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   const long long Base = 1e9 + 7;   struct Matrix {     int n, m;     long long cost[101][101];     Matrix() {}     Matrix(int n_, int m_) {       n = n_, m = m_;       for (int i = 0; i <= n; i++)         for (int j = 0; j <= m; j++) cost[i][j] = 0;     }     Matrix operator*(Matrix b) {       Matrix c = Matrix(n, b.m);       for (int i = 0; i <= n; i++)         for (int j = 0; j <= b.m; j++)           for (int k = 0; k <= m; k++)             c.cost[i][j] =                 (c.cost[i][j] + cost[i][k] * b.cost[k][j] % Base) % Base;       return c;     }   };   Matrix operator^(Matrix a, long long b) {     Matrix c = Matrix(a.n, a.m);     bool ok = false;     while (b > 0) {       if (b & 1) {         if (!ok)           c = a;         else           c = c * a;         ok = true;       }       a = a * a;       b >>= 1;     }     return c;   }   const long long N = 1e6 + 1;   long long n, l, m;   long long a[N], b[N], c[N], counts[N], counts_[N];   int main() {     scanf( %lld%lld%lld , &n, &l, &m);     for (int i = 1; i <= n; i++) {       scanf( %lld , &a[i]);       a[i] %= m;       counts[a[i]]++;     }     for (int i = 1; i <= n; i++) {       scanf( %lld , &b[i]);       b[i] %= m;       counts_[b[i]]++;     }     for (int i = 1; i <= n; i++) {       scanf( %lld , &c[i]);       c[i] %= m;     }     Matrix x = Matrix(m - 1, 0);     for (int i = 0; i <= m - 1; i++) x.cost[i][0] = counts[i];     if (l > 2) {       Matrix tmp = Matrix(m - 1, m - 1);       for (int i = 0; i <= m - 1; i++)         for (int j = 0; j <= m - 1; j++)           if (i < j)             tmp.cost[i][j] = counts_[i + m - j] % Base;           else             tmp.cost[i][j] = counts_[i - j] % Base;       tmp = tmp ^ (l - 2);       x = tmp * x;     }     for (int i = 1; i <= n; i++) c[i] = (c[i] + b[i]) % m;     long long ans = 0;     for (int i = 1; i <= n; i++)       if (c[i] == 0)         ans = (ans + x.cost[0][0]) % Base;       else         ans = (ans + x.cost[m - c[i]][0]) % Base;     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, b;   vector<pair<long long, long long> > v;   long long mask[105], cost[105], monitors[105];   long long dp[1 << 21];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> n >> m >> b;     for (int i = 0; i <= 100; i++) mask[i] = (1ll << 30) - 1;     for (long long i = 0; i < n; i++) {       long long temp;       cin >> cost[i] >> monitors[i] >> temp;       for (long long j = 0; j < temp; j++) {         long long val;         cin >> val;         mask[i] -= (1ll << (val - 1));       }       v.push_back(make_pair(monitors[i], i));     }     sort(v.begin(), v.end());     for (long long i = 1; i < (1ll << 21) - 2; i++) dp[i] = 1ll << 60;     long long ans = 1ll << 60;     for (long long i = 0; i < n; i++) {       long long pt = v[i].second;       for (long long j = 1; j < (1 << m); j++) {         dp[j] = min(dp[j], dp[j & mask[pt]] + cost[pt]);       }       ans = min(ans, dp[(1 << m) - 1] + v[i].first * b);     }     if (ans < 1ll << 60)       cout << ans <<   n ;     else       cout <<  -1 n ;     return 0;   }
#include <bits/stdc++.h>   #pragma optimize( -O3 )   using namespace std;   const long long mod = 998244353;   int n, m, u, v;   pair<vector<int>, int> adj[1000006];   int alr[1000006];   long long ans = 0, cr = 0;   bool check(int i, int j) {     if ((int)adj[i].first.size() != (int)adj[j].first.size()) return false;     int x = (int)adj[i].first.size();     int in1 = 0, in2 = 0;     while (in1 < x && in2 < x) {       if (adj[i].first[in1] == adj[j].second) {         in1++;         continue;       }       if (adj[j].first[in2] == adj[i].second) {         in2++;         continue;       }       if (adj[i].first[in1] != adj[j].first[in2]) return false;       in1++;       in2++;     }     return true;   }   bool check2(int i, int j) {     if ((int)adj[i].first.size() != (int)adj[j].first.size()) return false;     int x = (int)adj[i].first.size();     int in1 = 0;     while (in1 < x) {       if (adj[i].first[in1] != adj[j].first[in1]) return false;       in1++;     }     return true;   }   void dfs(int i) {     for (auto &x : adj[i].first) {       if (x < i) continue;       if (check(i, x)) ans++;     }   }   void solve() {     cin >> n >> m;     for (long long i = (long long)0; i != (long long)m; i = i + 1) {       cin >> u >> v;       u--;       v--;       adj[u].first.push_back(v);       adj[v].first.push_back(u);     }     for (long long i = (long long)0; i != (long long)n; i = i + 1) {       adj[i].second = i;       sort(adj[i].first.begin(), adj[i].first.end());     }     for (long long i = (long long)0; i != (long long)n; i = i + 1) {       dfs(i);     };     sort(adj, adj + n);     for (long long i = (long long)0; i != (long long)n; i = i + 1)       ;     for (long long i = (long long)1; i != (long long)n; i = i + 1) {       if (check2(i, i - 1)) {         cr++;         ;         ans += 1ll * cr;       } else {         cr = 0;       }     }     cout << ans <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long t;     t = 1;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   int a[4][2];   int b[4][2];   int vis[205][205];   int main() {     bool flag = 0;     int x1, x2, y1, y2;     for (int i = 0; i < 4; i++) {       scanf( %d %d , &a[i][0], &a[i][1]);     }     for (int i = 0; i < 4; i++) {       scanf( %d %d , &b[i][0], &b[i][1]);     }     if (a[0][0] == a[1][0]) {       y1 = min(a[0][1], a[1][1]);       y2 = max(a[0][1], a[1][1]);       x1 = min(a[1][0], a[2][0]);       x2 = max(a[1][0], a[2][0]);     } else {       y1 = min(a[1][1], a[2][1]);       y2 = max(a[1][1], a[2][1]);       x1 = min(a[0][0], a[1][0]);       x2 = max(a[0][0], a[1][0]);     }     for (int i = -100; i <= 100; i++)       for (int j = -100; j <= 100; j++) {         if (i >= x1 && i <= x2 && j >= y1 && j <= y2) {           vis[i + 100][j + 100] = 1;         }       }     if ((b[0][0] + b[0][1]) == (b[1][0] + b[1][1])) {       x1 = min(b[0][1] + b[0][0], b[2][0] + b[2][1]);       x2 = max(b[0][1] + b[0][0], b[2][0] + b[2][1]);       y1 = min(b[0][1] - b[0][0], b[1][1] - b[1][0]);       y2 = max(b[0][1] - b[0][0], b[1][1] - b[1][0]);     } else {       x1 = min(b[0][1] + b[0][0], b[1][0] + b[1][1]);       x2 = max(b[0][1] + b[0][0], b[1][0] + b[1][1]);       y1 = min(b[0][1] - b[0][0], b[2][1] - b[2][0]);       y2 = max(b[0][1] - b[0][0], b[2][1] - b[2][0]);     }     for (int i = -100; i <= 100; i++)       for (int j = -100; j <= 100; j++) {         if (i + j >= x1 && i + j <= x2 && j - i >= y1 && j - i <= y2 &&             vis[i + 100][j + 100]) {           flag = 1;         }       }     if (flag) {       printf( YES n );     } else {       printf( NO n );     }     return 0;   }
#include <bits/stdc++.h>   const double eps = 1e-9;   const int inf = 2000000000;   const double pi = acos(-1.0);   const long long mod = 1000000007;   using namespace std;   char s[150];   int t;   long long d[26 * 100 + 200][130];   int main() {     scanf( %d n , &t);     memset(d, 0, sizeof(d));     for (int num = 0; num <= 120; num++)       for (int sum = 0; sum <= 26 * 100 + 100; sum++) {         if (num == 0) {           if (sum == 0)             d[sum][num] = 1;           else             break;         } else           for (int last = 0; last < 26; last++)             if (sum - last >= 0)               d[sum][num] = (d[sum][num] + d[sum - last][num - 1]) % mod;       }     for (int it = 0; it < (int)t; it++) {       gets(s);       int n = (int)strlen(s);       int sum = 0;       for (int i = 0; i < (int)n; i++) sum += s[i] -  a ;       printf( %I64d n , (d[sum][n] == 0) ? 1000000006 : (d[sum][n] - 1));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a, s, d[500002][3], f, g, h, j, k, l, i, n, m;   long long inf = 100000000000000000ll;   pair<long long, int> p[500003], p1;   int main() {     cin >> n;     for (i = 1; i <= n; i++) {       scanf( %d , &a);       d[i][0] = a;       d[i][1] = i - 1;       d[i][2] = i + 1;       p[i] = {a, i};     }     sort(p + 1, p + n + 1);     i = 0;     long long y = 0;     int L = 1, R = n;     while (n - i - 2 > 0) {       p1 = p[i + 1];       if (p1.second == L || p1.second == R) {         k += (p1.first - y) * (n - i - 2);         y = p1.first;         if (p1.second == L)           L = d[p1.second][2];         else           R = d[p1.second][1];       } else {         k = k + min(d[d[p1.second][1]][0], d[d[p1.second][2]][0]) - y;         d[d[p1.second][1]][2] = d[p1.second][2];         d[d[p1.second][2]][1] = d[p1.second][1];       }       i++;     }     cout << k;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int arr[n];     for (int i = 0; i < n; i++) {       cin >> arr[i];     }     for (int i = 0; i < n - 1; i++) {       if (arr[i] % 2 != 0) {         if (arr[i + 1] > 0) {           arr[i + 1] -= 1;           if (arr[i + 1] < 0) {             cout <<  NO ;             return 0;           }         } else {           cout <<  NO ;           return 0;         }       }     }     if (arr[n - 1] % 2 == 0) {       cout <<  YES ;     } else {       cout <<  NO ;       return 0;     }   }
#include <bits/stdc++.h>   using namespace std;   int a[1000][1000];   int main() {     int n, m, x, y;     cin >> n >> m;     for (int i = 0; i < m; i++) {       cin >> x >> y;       x--, y--;       for (int k = -2; k < 1; k++)         for (int l = -2; l < 1; l++)           if (x + k >= 0 && x + k < n && y + l >= 0 && y + l < n) {             a[x + k][y + l]++;             if (a[x + k][y + l] == 9) {               cout << i + 1;               return 0;             }           }     }     cout << -1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-8;   const int inf = 0x3f3f3f3f;   const int mod = 1000000007;   const int maxn = 100000 + 10;   string s, str[maxn];   int n;   long long bit[10], len[10];   bool used[10];   long long Qpow(int x, long long b) {     long long tmp = x, ret = 1;     while (b) {       if (b & 1) {         ret *= tmp;         ret %= mod;       }       tmp *= tmp;       tmp %= mod;       b >>= 1;     }     return ret;   }   void cal(string ss) {     int sz = ss.length(), x = ss[0] -  0 ;     long long tmp = 1, ans = 0;     for (int i = sz - 1; i > 2; i--) {       int now = ss[i] -  0 ;       ans += tmp * bit[now];       ans %= mod;       tmp *= len[now];       tmp %= mod;     }     bit[x] = ans;     len[x] = tmp;     used[x] = true;   }   int main() {     cin >> s >> n;     for (int i = 0; i < n; i++) cin >> str[i];     for (int i = 0; i < 10; i++) bit[i] = i, len[i] = 10, used[i] = false;     for (int i = n - 1; i >= 0; i--) cal(str[i]);     int sz = s.length();     long long ans = 0, tmp = 1;     for (int i = sz - 1; i >= 0; i--) {       int now = s[i] -  0 ;       ans += bit[now] * tmp % mod;       ans %= mod;       tmp *= len[now];       tmp %= mod;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int k, i, j, n;   double ans, x[100010], xp, yp, xk;   double C(int z) { return hypot(x[z] - xp, yp); }   double A(int l, int r) { return x[r] - x[l] + min(C(l), C(r)); }   double B(int l, int r) {     return x[r] - x[l] + min(abs(xk - x[l]) + C(r), abs(xk - x[r]) + C(l));   }   void inlinework() {     ans = B(1, n);     for (i = 2; i <= n; i++) {       double t = min(A(1, i - 1) + B(i, n), A(i, n) + B(1, i - 1));       if (t < ans) ans = t;     }   }   void outlinework() { ans = A(1, n); }   int main() {     scanf( %d%d , &n, &k);     for (i = 1; i <= n; i++) scanf( %lf , &x[i]);     scanf( %lf%lf , &xp, &yp);     xk = x[k];     sort(x + 1, x + n + 1);     if (k <= n)       inlinework();     else       outlinework();     printf( %.20lf n , ans);   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> tri(100005);   void solve() {     long long n;     cin >> n;     for (long long i = 1; i < 100005; i++) {       tri[i] = (i * (i + 1)) / 2LL;     }     for (int i = 1; i <= 100000; i++) {       long long x = n - tri[i];       if (x <= 0) {         cout <<  NO n ;         return;       }       auto it = lower_bound(tri.begin(), tri.end(), x) - tri.begin();       if (tri[it] == x) {         cout <<  YES n ;         return;       }     }     cout <<  NO n ;     return;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     int t = 1;     for (int i = 1; i <= t; i++) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double pi = atan(1) * 4;   const double EXP = 1e-8;   struct node {     int x, y;     double a;   } light[30];   double cal(double pos, node l) {     double len = sqrt((l.x - pos) * (l.x - pos) + l.y * l.y);     if (pos > l.x) {       if (l.a < atan(l.y * 1.0 / (pos - l.x))) {         double ag = atan(l.y * 1.0 / (pos - l.x)) - l.a;         return sin(l.a) * len / sin(ag);       } else         return 1000000.0;     } else {       l.x += EXP;       double ag = atan(l.y * 1.0 / (l.x - pos));       return sin(l.a) * len / sin(pi - ag - l.a);     }   }   double dp[1 << 21];   int main() {     int n, l, r;     scanf( %d%d%d , &n, &l, &r);     for (int i = 0; i < n; i++) {       int a;       scanf( %d%d%d , &light[i].x, &light[i].y, &a);       light[i].x -= l;       light[i].a = a * pi / 180.0;     }     for (int i = 0; i < (1 << n); i++)       for (int j = 0; j < n; j++) {         if (i & (1 << j)) continue;         dp[i | (1 << j)] = max(dp[i | (1 << j)], dp[i] + cal(dp[i], light[j]));       }     if (dp[(1 << n) - 1] + l >= r)       printf( %.10f n , (r - l) * 1.0);     else       printf( %.10f n , dp[(1 << n) - 1]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);     long long int t;     cin >> t;     while (t--) {       long long int n;       cin >> n;       vector<long long int> a(n);       vector<long long int> b(n);       for (long long int i = 0; i < n; i++) cin >> a[i];       for (long long int i = 0; i < n; i++) cin >> b[i];       long long int suma[n], sumb[n];       for (long long int i = 0; i < n; i++) {         suma[i] = sumb[i] = 0;       }       suma[0] = a[0];       sumb[0] = b[0];       for (long long int i = 1; i < n; i++) suma[i] += a[i] + suma[i - 1];       for (long long int i = 1; i < n; i++) sumb[i] += b[i] + sumb[i - 1];       long long int maxf = 1e17;       long long int minmaxf = 1e17;       for (long long int i = 0; i < n; i++) {         if (i == 0)           maxf = suma[n - 1] - suma[i];         else {           if (suma[n - 1] - suma[i] < sumb[i - 1])             maxf = sumb[i - 1];           else             maxf = suma[n - 1] - suma[i];         }         if (maxf < minmaxf) minmaxf = maxf;       }       cout << minmaxf << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int a[3003];   int main() {     int n, inv = 0;     cin >> n;     for (int i = 0; i < n; ++i) cin >> a[i];     for (int i = 0; i < n; ++i)       for (int j = i + 1; j < n; ++j)         if (a[i] > a[j]) ++inv;     if (inv % 2 == 0)       cout << fixed << setprecision(6) << 2.0 * inv << endl;     else       cout << fixed << setprecision(6) << 2.0 * inv - 1 << endl;     return 0;   }