func_code_string: #include <bits/stdc++.h>   using namespace std;   char buf[1 << 20], *p1 = buf, *p2 = buf;   template <typename T>   void read(T &x) {     x = 0;     bool f = 1;     char c =         (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 20, stdin), p1 == p2)              ? EOF              : *p1++);     for (; !isdigit(c);          c = (p1 == p2 &&                       (p2 = (p1 = buf) + fread(buf, 1, 1 << 20, stdin), p1 == p2)                   ? EOF                   : *p1++))       if (c ==  - ) f = 0;     if (f)       for (; isdigit(c);            c = (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 20, stdin),                             p1 == p2)                     ? EOF                     : *p1++))         x = x * 10 - 48 + c;     else       for (; isdigit(c);            c = (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 20, stdin),                             p1 == p2)                     ? EOF                     : *p1++))         x = x * 10 + 48 - c;   }   template <typename T, typename... Args>   void read(T &t, Args &...args) {     read(t), read(args...);   }   const int N = 5e3 + 5;   int n, a[N];   int raw, mn, cnt, f[N][N], g[N][N];   int qf(int i, int l, int r) { return f[i][r] - f[i][l - 1]; }   int qg(int i, int l, int r) { return g[i][l] - g[i][r + 1]; }   int main() {     read(n);     for (int i = 1; i <= n; ++i) read(a[i]);     for (int i = 1; i <= n; ++i)       for (int j = i + 1; j <= n; ++j) raw += a[i] > a[j];     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= n; ++j) f[i][j] = a[j] > a[i], g[i][j] = a[j] < a[i];       for (int j = 1; j <= n; ++j) f[i][j] += f[i][j - 1];       for (int j = n; j >= 1; --j) g[i][j] += g[i][j + 1];     }     for (int i = 1; i <= n; ++i)       for (int j = i + 1; j <= n; ++j) {         int cur = qf(i, i + 1, j - 1) - qg(i, i + 1, j - 1) -                   qf(j, i + 1, j - 1) + qg(j, i + 1, j - 1) +                   (a[i] < a[j] ? 1 : -1);         if (cur < mn)           mn = cur, cnt = 1;         else if (cur == mn)           ++cnt;       }     printf( %d %d , raw + mn, cnt);     return 0;   }   