Language: C++

#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}

class BinaryIndexTree{
    public:
        BinaryIndexTree(long long N) : n(N), data(n*2-1,0) {}
        long long sum(long long i){
            assert(i < n);
            long long s = 0;
            while(i > 0){
                s += data[i];
                i -= i & -i;
            }
            return s;
        } 
        long long add(long long i, long long x){
            assert(i < n);
            while(i <= n){
                data[i] += x;
                i += i & -i;
            }
        }
        long long size(void){
            return n;
        }
    private:
        long long n;
        vector<long long> data;
};

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;cin>>n>>k;
    ll p[n];rep(i,n){cin>>p[i];p[i]++;}
    BinaryIndexTree bit = BinaryIndexTree(n+5);
    ll cnt=1;
    rep(i,k){
        bit.add(p[i],1LL);
        if(i>0){
            if(p[i]>p[i-1]){
                cnt++;
            }
            else{
                cnt=1;
            }
        }
    }
    ll res = 1;
    bool flg = cnt==k;
    repr(i,k,n){
        bit.add(p[i-k],-1LL);
        bit.add(p[i],1LL);
        if(p[i]>p[i-1]){
            cnt = min(cnt+1,k);
        }else{cnt=1;}
        if(!flg&&cnt==k){res++;flg=true;}
        else if(cnt!=k&&(bit.sum(p[i])!=k||bit.sum(p[i-k])!=0)){res++;}
        DEBUG{
            cout << cnt << " " << res <<endl;

        }
    }
    cout << res << endl;
    return 0;
}


Compiler output:
a.cc:44:9: error: 'vector' does not name a type
   44 |         vector<long long> data;
      |         ^~~~~~
a.cc: In constructor 'BinaryIndexTree::BinaryIndexTree(long long int)':
a.cc:22:46: error: class 'BinaryIndexTree' does not have any field named 'data'
   22 |         BinaryIndexTree(long long N) : n(N), data(n*2-1,0) {}
      |                                              ^~~~
a.cc: In member function 'long long int BinaryIndexTree::sum(long long int)':
a.cc:24:13: error: 'assert' was not declared in this scope
   24 |             assert(i < n);
      |             ^~~~~~
a.cc:1:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
  +++ |+#include <cassert>
    1 | #define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
a.cc:27:22: error: 'data' was not declared in this scope
   27 |                 s += data[i];
      |                      ^~~~
a.cc: In member function 'long long int BinaryIndexTree::add(long long int, long long int)':
a.cc:33:13: error: 'assert' was not declared in this scope
   33 |             assert(i < n);
      |             ^~~~~~
a.cc:33:13: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
a.cc:35:17: error: 'data' was not declared in this scope
   35 |                 data[i] += x;
      |                 ^~~~
a.cc:38:9: warning: no return statement in function returning non-void [-Wreturn-type]
   38 |         }
      |         ^
a.cc: In function 'int main()':
a.cc:48:5: error: 'cin' was not declared in this scope
   48 |     cin.tie(0);
      |     ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | #define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
a.cc:49:5: error: 'ios' has not been declared
   49 |     ios::sync_with_stdio(false);
      |     ^~~
a.cc:71:19: error: 'min' was not declared in this scope; did you mean 'main'?
   71 |             cnt = min(cnt+1,k);
      |                   ^~~
      |                   main
a.cc:76:13: error: 'cout' was not declared in this scope
   76 |             cout << cnt << " " << res <<endl;
      |             ^~~~
a.cc:76:13: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:76:41: error: 'endl' was not declared in this scope
   76 |             cout << cnt << " " << res <<endl;
      |                                         ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | #define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
a.cc:80:5: error: 'cout' was not declared in this scope
   80 |     cout << res << endl;
      |     ^~~~
a.cc:80:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:80:20: error: 'endl' was not declared in this scope
   80 |     cout << res << endl;
      |                    ^~~~
a.cc:80:20: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'