malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n;     cin >> n;     long long a[n + 1], b[n + 1];     for (long long i = 1; i <= n; i++) {       long long x;       cin >> x;       a[x] = i;     }     for (long long i = 1; i <= n; i++) {       long long x;       cin >> x;       b[x] = i;     }     map<long long, long long> m;     long long ans = 0;     for (long long i = 1; i <= n; i++) {       if (a[i] < b[i]) {         m[n + a[i] - b[i]]++;         ans = max(ans, m[n - b[i] + a[i]]);       } else {         m[a[i] - b[i]]++;         ans = max(ans, m[a[i] - b[i]]);       }     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   char gc() {     static char buf[100000], *p1 = buf, *p2 = buf;     return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)                ? EOF                : *p1++;   }   long long read() {     char ch = getchar();     long long x = 0;     int op = 1;     for (; !isdigit(ch); ch = getchar())       if (ch ==  - ) op = -1;     for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + ch -  0 ;     return x * op;   }   int n, k, a[55], ans;   char s[55];   int main() {     n = read(), k = read();     scanf( %s , s + 1);     for (int i = (1); i <= (n); i++) a[i] = s[i] -  a  + 1;     sort(&a[1], &a[n + 1]);     ans = 1000000001;     for (int i = (1); i <= (n); i++) {       int p = i, q, tmp = 0;       bool flag = 1;       for (int j = (1); j <= (k); j++) {         if (p > n) {           flag = 0;           break;         }         tmp += a[p];         q = p, p++;         while (p <= n && abs(a[p] - a[q]) <= 1) p++;       }       if (flag) ans = min(ans, tmp);     }     if (ans == 1000000001)       puts( -1 );     else       printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, dad[200000 + 1], u[200000 + 1], v[200000 + 1];   long long w[200000], pop[200000], initsum, S;   std::vector<int> adjl[200000 + 1];   int cnode(int node, int ed) { return node ^ u[ed] ^ v[ed]; }   void dfs(int u) {     int isleaf = 1;     if (u != 1) pop[dad[u]] = 0;     for (int ed : adjl[u])       if (ed != dad[u]) {         isleaf = 0;         int v = cnode(u, ed);         dad[v] = ed;         dfs(v);         initsum += w[ed] * pop[ed];         if (u != 1) pop[dad[u]] += pop[ed];       }     if (isleaf) pop[dad[u]] = 1;   }   struct good_cmp {     bool operator()(int l, int r) {       return pop[l] * ((w[l] + 1) / 2) < pop[r] * ((w[r] + 1) / 2);     }   };   void run() {     cin >> n >> S;     for (int i = 1; i <= n; ++i) adjl[i].clear();     for (int i = 1; i < n; ++i) {       cin >> u[i] >> v[i] >> w[i];       adjl[u[i]].emplace_back(i);       adjl[v[i]].emplace_back(i);     }     initsum = 0;     memset(dad + 1, 0, n * sizeof(int));     dad[1] = -1;     dfs(1);     std::priority_queue<int, std::vector<int>, good_cmp> pq;     for (int i = 1; i < n; ++i) pq.push(i);     long long ans = 0;     while (initsum > S) {       ++ans;       int top = pq.top();       pq.pop();       initsum -= pop[top] * ((w[top] + 1) / 2);       w[top] /= 2;       pq.push(top);     }     cout << ans <<   n ;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(nullptr);     int t;     cin >> t;     while (t--) run();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char str[50];   pair<int, pair<int, char*> > p[100001];   long long c[100005];   vector<int> ans;   map<int, int> mp;   int main() {     std::ios::sync_with_stdio(false);     long long n, m, x;     cin >> n >> m;     for (int i = 0; i < n; i++) {       cin >> c[i];     }     sort(c, c + n);     int j = 1;     while (m > 0 && j < c[0]) {       m = m - j;       if (m >= 0) ans.push_back(j);       j++;     }     c[n] = 1000000002;     if (m > 0) {       for (int i = 0; i < n; i++) {         j = c[i] + 1;         while (m > 0 && j < c[i + 1]) {           m = m - j;           if (m >= 0) ans.push_back(j);           j++;         }         if (m <= 0) break;       }     }     cout << ans.size() <<   n ;     for (int i = 0; i < ans.size(); i++) cout << ans[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1000000007;   const long long MOD = 1000000007;   const long long INF = 1LL << 60;   long long xn[101010];   int solve() {     long long a, b, c, d, e, f;     cin >> a >> b >> c >> d >> e >> f;     long long ans = 0;     for (long long i = 0; i <= d; i++) {       long long one = min(i, a);       long long two = min(d - i, min(b, c));       ans = max(ans, e * one + f * two);     }     cout << ans << endl;     return 0;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     solve();   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1E5 + 10;   string s[N];   map<string, vector<string>> E;   map<string, long long> cnt;   map<string, long long> len;   map<string, bool> vis;   vector<pair<string, vector<string>>> e;   string to_lower(string &s) {     int ret = 0;     for (auto &c : s) {       c = tolower(c);       if (c ==  r ) ret++;     }     cnt[s] = ret;     len[s] = s.size();     return s;   }   void dfs(string u) {     vis[u] = 1;     for (const auto &v : E[u]) {       if (vis[v]) continue;       if (cnt[v] > cnt[u]) {         len[v] = len[u];         cnt[v] = cnt[u];       } else if (cnt[u] == cnt[v] && len[v] > len[u]) {         len[v] = len[u];       }       dfs(v);     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n, m;     cin >> n;     for (int i = 0; i < n; ++i) {       cin >> s[i];       s[i] = to_lower(s[i]);     }     cin >> m;     string u, v;     for (int i = 0; i < m; ++i) {       cin >> u >> v;       E[to_lower(v)].emplace_back(to_lower(u));     }     for (const auto &i : E) {       e.emplace_back(i);       vis[i.first] = 0;     }     sort(e.begin(), e.end(),          [](const pair<string, vector<string>> &x,             const pair<string, vector<string>> &y) -> int {            if (cnt[x.first] == cnt[y.first])              return x.first.size() < y.first.size();            return cnt[x.first] < cnt[y.first];          });     pair<long long, long long> ret = make_pair(0, 0);     for (auto i : e) {       if (vis[i.first] == 0) {         vis[i.first] = 1;         dfs(i.first);       }     }     for (auto i : s) {       ret.first += cnt[i];       ret.second += len[i];     }     cout << ret.first <<     << ret.second << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[100100];   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     int n, k;     cin >> n >> k;     for (int i = 0; i < n; i++) cin >> a[i];     const long long max_pow = 1e9 * 1e5;     vector<long long> powers = {1};     if (abs(k) > 1)       while (abs(powers.back() * k) <= max_pow)         powers.push_back(powers.back() * k);     else if (k == -1)       powers.push_back(-1);     long long ans = 0;     long long prefix_sum = 0;     map<long long, long long> cnt_sums;     for (int i = 0; i < n; i++) {       cnt_sums[prefix_sum]++;       prefix_sum += a[i];       for (auto pow : powers)         if (cnt_sums.count(prefix_sum - pow) > 0)           ans += cnt_sums[prefix_sum - pow];     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int a[100009];   int n;   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) scanf( %d , &a[i]);     long long res = 0;     for (int i = 0; i < n;) {       int j = i + 1;       while (j < n && a[j] == a[i]) j++;       long long sz = j - i;       res += sz * (sz + 1) / 2;       i = j;     }     cout << res << endl;   }
#include <bits/stdc++.h>   using namespace std;   template <typename A, typename B>   string to_string(pair<A, B> p);   string to_string(const string&);   string to_string(const char* s);   string to_string(bool b);   template <typename A>   string to_string(A v);   template <typename A, typename B>   string to_string(pair<A, B> p);   void debug_out();   template <typename Head, typename... Tail>   void debug_out(Head H, Tail... T);   vector<string> vec_splitter(string s);   void debug_var(vector<string> __attribute__((unused)) args,                  __attribute__((unused)) long long idx,                  __attribute__((unused)) long long LINE_NUM) {     cerr << endl;   }   template <typename Head, typename... Tail>   void debug_var(vector<string>, long long, long long, Head, Tail...);   const long long mod = 1e9 + 7;   const long long N = 1e6 + 5;   void solve() {     long long n, p;     cin >> n >> p;     string s;     vector<long long> a(n);     for (long long i = 0; i < n; ++i) {       cin >> s;       if (s.back() ==  f ) {         a[i] = 1;       }     }     long long ans = p / 2, cur = 1;     for (long long i = n - 2; i >= 0; --i) {       if (a[i]) {         ans += p * cur;         cur *= 2;       } else {         ans += p * cur + p / 2;         cur *= 2;         ++cur;       }     }     cout << ans <<   n ;   }   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     solve();     return 0;   }   string to_string(const string& s) { return     + s +    ; }   string to_string(const char* s) { return to_string((string)s); }   string to_string(bool b) { return (b ?  T  :  F ); }   template <typename A>   string to_string(A v) {     bool first = true;     string res =  { ;     for (const auto& x : v) {       if (!first) {         res +=  ,  ;       }       first = false;       res += to_string(x);     }     res +=  } ;     return res;   }   template <typename Head, typename... Tail>   void debug_var(vector<string> args, long long idx, long long LINE_NUM, Head H,                  Tail... T) {     if (idx > 0)       cerr <<  ,  ;     else       cerr <<  Line(  << LINE_NUM <<  ):  ;     stringstream ss;     ss << H;     cerr << args[idx] <<   =   << ss.str();     debug_var(args, idx + 1, LINE_NUM, T...);   }   template <typename A, typename B>   string to_string(pair<A, B> p) {     return  (  + to_string(p.first) +  ,   + to_string(p.second) +  ) ;   }   void debug_out() { cerr << endl; }   template <typename Head, typename... Tail>   void debug_out(Head H, Tail... T) {     cerr <<     << to_string(H);     debug_out(T...);   }   vector<string> vec_splitter(string s) {     s +=  , ;     vector<string> res;     while (!s.empty()) {       res.push_back(s.substr(0, s.find( , )));       s = s.substr(s.find( , ) + 1);     }     return res;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     double a, d;     int n;     while (scanf( %lf%lf%d , &a, &d, &n) != EOF) {       double sum = 0;       for (int i = 1; i <= n; i++) {         sum = (sum + d);         sum -= (int)(sum / (a * 4)) * (a * 4);         double x, y;         int dir = ((int)(sum / a)) % 4;         if (dir == 0) {           x = sum - ((int)(sum / a)) * a;           y = 0;         } else if (dir == 1) {           x = a;           y = sum - ((int)(sum / a)) * a;         } else if (dir == 2) {           x = a - sum + ((int)(sum / a)) * a;           y = a;         } else if (dir == 3) {           x = 0;           y = a - sum + ((int)(sum / a)) * a;         }         printf( %.10lf %.10lf n , x, y);       }     }   }
#include <bits/stdc++.h>   using namespace std;   void __print(int x) { cerr << x; }   void __print(long x) { cerr << x; }   void __print(long long x) { cerr << x; }   void __print(unsigned x) { cerr << x; }   void __print(unsigned long x) { cerr << x; }   void __print(unsigned long long x) { cerr << x; }   void __print(float x) { cerr << x; }   void __print(double x) { cerr << x; }   void __print(long double x) { cerr << x; }   void __print(const char *x) { cerr <<     << x <<    ; }   void __print(const string &x) { cerr <<     << x <<    ; }   void __print(bool x) { cerr << (x ?  true  :  false ); }   template <typename T, typename V>   void __print(const pair<T, V> &x) {     cerr <<  { ;     __print(x.first);     cerr <<  , ;     __print(x.second);     cerr <<  } ;   }   template <typename T>   void __print(const T &x) {     int f = 0;     cerr <<  { ;     for (auto &i : x) cerr << (f++ ?  ,  :   ), __print(i);     cerr <<  } ;   }   void _print() { cerr << endl; }   template <typename T, typename... V>   void _print(T t, V... v) {     __print(t);     if (sizeof...(v)) cerr <<  ,  ;     _print(v...);   }   void run_case() {     long long lim = 1, n, i, j, k, cnt = 0, sum = 0;     cin >> n;     vector<long long int> a(n);     for (i = 0; i < n; i++) cin >> a[i], lim *= 3;     for (i = 1; i < lim; i++) {       k = i;       sum = 0;       for (j = 0; j < n; j++) {         cnt = k % 3;         if (cnt == 1) sum += a[j];         if (cnt == 2) sum -= a[j];         k /= 3;       }       if (sum == 0) {         cout <<  YES  << endl;         return;       }     }     cout <<  NO  << endl;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int tc;     cin >> tc;     while (tc--) {       run_case();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   bool check(vector<vector<char>>& v, int x, int y) {     if (x + 2 >= 0 && y - 1 >= 0 && y + 1 < n && v[x + 1][y] ==  #  &&         v[x + 2][y] ==  #  && v[x + 1][y + 1] ==  #  && v[x + 1][y - 1] ==  # ) {       v[x][y] = v[x + 1][y] = v[x + 2][y] = v[x + 1][y + 1] = v[x + 1][y - 1] =            . ;       return true;     }     if (y + 2 < n && x - 1 >= 0 && x + 1 < n && v[x][y + 1] ==  #  &&         v[x][y + 2] ==  #  && v[x - 1][y + 1] ==  #  && v[x + 1][y + 1] ==  # ) {       v[x][y] = v[x][y + 1] = v[x][y + 2] = v[x - 1][y + 1] = v[x + 1][y + 1] =            . ;       return true;     }     return false;   }   void print(vector<vector<char>> v) {     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         cout << v[i][j];       }       cout << endl;     }   }   int main() {     cin >> n;     vector<vector<char>> v(n, vector<char>(n));     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         cin >> v[i][j];       }     }     if (v[0][0] ==  #  || v[n - 1][0] ==  #  || v[0][n - 1] ==  #  ||         v[n - 1][n - 1] ==  # ) {       cout <<  NO ;       return 0;     }     int x, y;     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         if (v[i][j] ==  # ) {           if (!check(v, i, j)) {             cout <<  NO ;             return 0;           }         }       }     }     cout <<  YES ;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long int n;     cin >> n;     if (n & 1)       cout << ((n / 2) + 1) <<   n ;     else       cout << (n / 2) <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int t;     cin >> t;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int max_n = 1000005;   int n, k;   int a[max_n], d[max_n];   long long sum[max_n];   long long suf[max_n];   long long pre[max_n];   int main() {     scanf( %d%d , &n, &k);     for (int i = 1; i <= n; i++) scanf( %d , a + i);     for (int i = 1; i <= n; i++) scanf( %d , d + i);     for (int i = n; i >= 1; i--) sum[i] = sum[i + 1] + a[i];     long long ans = 0;     if (k == 0) {       for (int i = 1; i <= n; i++) ans = max(ans, sum[i] - d[i]);     } else if (k >= 2) {       for (int i = 1; i < n; i++) ans = max(ans, sum[1] - d[i]);       ans = max(ans, 1ll * a[n] - 1ll * d[n]);     } else {       suf[n] = sum[n] - d[n];       for (int i = n - 1; i >= 1; i--) suf[i] = max(suf[i + 1], sum[i] - d[i]);       int mx = d[1];       for (int i = 2; i < n; i++) {         mx = min(mx, d[i]);         ans = max(ans, max(sum[1] - sum[i + 1] - mx, 0ll) + max(suf[i + 1], 0ll));       }       for (int i = 1; i <= n; i++) pre[i] = max(pre[i - 1], sum[i] - d[i]);       for (int i = 1; i + 2 <= n; i++) {         long long res = 0;         if (a[i + 1] - d[i + 1] > 0) res += a[i + 1] - d[i + 1];         res += max(pre[i] - a[i + 1], 0ll);         ans = max(ans, res);         ans = max(ans, suf[i + 1]);       }       for (int i = 1; i < n; i++) ans = max(ans, suf[i + 1]);     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5;   int a[N + 2], p[N + 2];   void solve() {     int n;     cin >> n;     for (int i = 1; i <= n; i++) {       int x;       cin >> x;       a[x] = i, p[i] = 0;     }     p[n + 1] = 1;     int nx = -1;     for (int i = 1; i <= n; i++) {       if (nx == -1) {         p[a[i]] = 1;         if (p[a[i] + 1] == 0) nx = a[i] + 1;       } else {         if (a[i] != nx) {           cout <<  NO n ;           return;         }         nx++;         if (p[nx]) nx = -1;       }     }     cout <<  YES n ;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int t;     cin >> t;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const unsigned int maxn = 35000, maxk = 50;   class STree {    public:     void build(const unsigned int l, const unsigned int r, STree*(&cur),                unsigned int dat[]) {       lv = l;       rv = r;       mv = (l + r) >> 1;       if (r - l == 1) return;       lc = ++cur;       rc = ++cur;       lc->build(l, mv, cur, dat);       rc->build(mv, r, cur, dat);     }     void init(const unsigned int dat[]) {       laz = 0;       if (rv - lv == 1) {         val = dat[lv];         return;       }       lc->init(dat);       rc->init(dat);       this->val = max(lc->val, rc->val);     }     void increase(const unsigned int l, const unsigned int r) {       if (l == lv && r == rv) {         push(1);         return;       }       pushdown();       if (r <= mv)         lc->increase(l, r);       else if (l >= mv)         rc->increase(l, r);       else {         lc->increase(l, mv);         rc->increase(mv, r);       }       this->val = max(lc->val, rc->val);     }     unsigned int query(const unsigned int l, const unsigned int r) {       if (l == lv && r == rv) return val;       pushdown();       if (r <= mv)         return lc->query(l, r);       else if (l >= mv)         return rc->query(l, r);       else         return max(lc->query(l, mv), rc->query(mv, r));     }       private:     void push(const unsigned int laz) {       this->val += laz;       this->laz += laz;     }     void pushdown() {       if (!laz) return;       lc->push(laz);       rc->push(laz);       laz = 0;     }     STree *lc = nullptr, *rc = nullptr;     unsigned int val, laz;     unsigned int lv, mv, rv;   } SNodes[maxn * 4 + 1], *SRoot = SNodes;   unsigned int lst[maxn + 1], a[maxn + 1];   unsigned int f[maxn + 1];   static void initLst(const unsigned int n) {     static unsigned int pos[maxn + 1];     for (unsigned int i = 1; i <= n; ++i) {       lst[i] = pos[a[i]];       pos[a[i]] = i;     }   }   static unsigned int dp(const unsigned int n, const unsigned int k) {     for (unsigned int i = 1; i <= n; ++i) f[i] = lst[i] ? f[i - 1] : f[i - 1] + 1;     for (unsigned int i = 2; i <= k; ++i) {       SRoot->init(f);       for (unsigned int j = 2; j <= n; ++j) {         SRoot->increase(lst[j], j);         f[j] = SRoot->query(1, j);       }     }     return f[n];   }   int main() {     ios_base::sync_with_stdio(false);     unsigned int n, k;     cin >> n >> k;     copy_n(istream_iterator<unsigned int>(cin), n, a + 1);     {       STree* c = SNodes;       SRoot->build(0, n + 1, c, f);     }     initLst(n);     cout << dp(n, k) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void c_p_c() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);   }   long long me(long long x, long long y, long long p) {     long long res = 1;     x = x % p;     if (x == 0) return 0;     while (y > 0) {       if (y & 1) res = (res * x) % p;       y = y >> 1;       x = (x * x) % p;     }     return res;   }   int main() {     c_p_c();     long long t;     cin >> t;     while (t--) {       long long n, k;       cin >> n >> k;       string s;       cin >> s;       long long p1 = 0;       long long count = 0;       long long c = 0;       for (long long i = 0; i < s.length(); i++) {         if (s[i] ==  1 ) {           c++;         }       }       if (c == 0) {         p1 = s.length();         if (1) {           long long y = (p1 - 1) / (k + 1);           cout << y + 1 << endl;           continue;         }       }       long long p2 = n - 1;       for (long long i = 0; i < n; i++) {         if (s[i] ==  1 ) {           p1 = i;           break;         }       }       for (long long i = n - 1; i >= 0; i--) {         if (s[i] ==  1 ) {           p2 = i;           break;         }       }       long long temp = p1;       if (c >= 2) {         for (long long i = p1 + 1; i <= p2; i++) {           if (s[i] ==  1 ) {             long long x = i - temp - 1;             if (x - k >= 0) {               x = x - k;               long long y = x / (k + 1);               count = count + y;             }             temp = i;           }         }       }       if (1) {         long long y = p1 / (k + 1);         count = count + y;       }       long long n1 = n - p2 - 1;       if (1) {         long long y = n1 / (k + 1);         count = count + y;       }       cout << count << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, k;     scanf( %d %d %d , &n, &m, &k);     int arr[(int)1e5 + 5];     for (int i = 1; i <= n; i++) scanf( %d , &arr[i]);     vector<int> vec;     for (int i = 2; i <= n; i++) vec.push_back(arr[i] - arr[i - 1]);     sort(vec.begin(), vec.end());     long long res = arr[n] - arr[1] + 1;     int bad = k - 1;     for (int i = vec.size() - 1; i >= 0 && bad > 0; i--) {       res -= vec[i] - 1;       bad--;     }     printf( %lld n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int t;     cin >> t;     while (t--) {       long long int a[3];       for (long long int i = 0; i < 3; i++) {         cin >> a[i];       }       sort(a, a + 3);       if (a[0] == a[1] && a[1] == a[2]) {         cout <<  YES  << endl;         cout << a[0] <<     << a[1] <<     << a[2] << endl;       } else if (a[1] == a[2] && a[0] < a[1]) {         cout <<  YES  << endl;         cout << a[0] <<     << a[0] <<     << a[1] << endl;       } else         cout <<  NO  << endl;     }     return 0;   }
#include <bits/stdc++.h>   int main() {     int n, count = 0;     scanf( %d , &n);     while (n--) {       int t = 3, s = 0;       while (t--) {         int a;         scanf( %d , &a);         s = s + a;       }       if (s > 1) {         count++;       }     }     printf( %d , count);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int read() {     int x = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return x * f;   }   int n;   int s[105];   void swap(int first, int last) {     while (first <= last) {       int t = s[first];       s[first] = s[first + 1];       s[first + 1] = t;       first += 2;     }   }   int main() {     n = read();     for (int i = 1; i <= n; i++) {       s[i] = read();     }     bool b = true;     while (b) {       b = false;       for (int i = 1; i <= n - 1; i++) {         if (s[i] > s[i + 1]) {           b = true;           int j = i + 2;           while (j < n && s[j] > s[j + 1]) j += 2;           cout << i <<     << j - 1 << endl;           swap(i, j - 2);           break;         }       }     }     return 0;   }