func_code_string: #include <bits/stdc++.h>   using namespace std;   long long m, loc, t;   long long now;   class SegTree {    private:     long long F2(long long k) { return 1 << (long long)ceil(log2(k)); }     vector<long long> seg;     void Merge(long long cur) { seg[cur] = seg[2 * cur] + seg[2 * cur + 1]; }       public:     SegTree(long long n) {       m = F2(n);       for (long long i = 0; i < 2 * m + 2; i++) seg.push_back(0);     }     void Add(long long loc, long long cur = 1, long long l = 1, long long r = m) {       if (r < l || r < loc || loc < l)         return;       else if (l == r)         return void(seg[cur]++);       long long mid = (l + r) / 2;       Add(loc, 2 * cur, l, mid);       Add(loc, 2 * cur + 1, mid + 1, r);       Merge(cur);     }     long long Get(long long a, long long b, long long cur = 1, long long l = 1,                   long long r = m) {       if (r < l || r < a || b < l)         return 0;       else if (a <= l && r <= b)         return seg[cur];       long long mid = (l + r) / 2;       long long x = Get(a, b, 2 * cur, l, mid);       long long y = Get(a, b, 2 * cur + 1, mid + 1, r);       return x + y;     }     long long BinarySearch(long long a, long long l = 1, long long r = now) {       if (r < l) return a;       long long mid = (l + r) / 2;       if (!Get(a + 1, mid)) return max(mid, BinarySearch(a, mid + 1, r));       return BinarySearch(a, l, mid - 1);     }   };   vector<pair<long long, long long>> v;   int main() {     long long q;     cin >> q;     while (q--) {       long long n;       cin >> n;       now = n;       loc = 0;       long long a[n + 1];       v.clear();       SegTree s(n);       for (long long i = 0; i < n; i++) {         cin >> t;         if (t < loc) s.Add(i + 1);         loc = t;         a[i + 1] = t;       }       loc = 2;       long long ans = 1;       long long last = 1, cur = 0;       while (loc <= n) {         if (last == 0) swap(last, cur), ans++;         last--;         long long now = s.BinarySearch(loc + 1);         if (loc == n)           now = loc;         else if (a[loc + 1] < a[loc])           now = loc;         cur += now - loc + 1;         loc = now + 1;       }       cout << ans << endl;     }     return 0;   }   