Language: C++

int main() {
  int n,k;
  cin>>n>>k;
  ll a[n];
  ll ok=0,temp1=0,temp1in=0;
  rep(i,n) cin>>a[i];
  rep(i,n){
      if(temp1<a[i]) ok++,temp1=a[i];
      else break;
  }
  if(k<=ok){
      cout<<0<<endl;
      return 0;
  } 
  ll ans=1000000000000000;
  for(ll bit=0;bit<(1<<(n-ok));bit++){

      ll cansee=0;
      for(int i=0;i<n-ok;i++){
          if(bit&(1<<i)) cansee++;
      }
      if(cansee==k-ok){
          ll temp2=temp1;
          ll yen=0;

          for(int i=0;i<n-ok;i++){

            if(bit&(1<<i)){
                if(temp2==a[i+ok]){
                     yen++;
                    temp2++;
                }
                else if(temp2>a[i+ok]){
                     yen+=(temp2-a[i+ok]+1);
                    temp2++;
                }
                else temp2=a[i+ok];
            }
          }
          ans=min(ans,yen);

      }
      
  }

  cout<<ans<<endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:3: error: 'cin' was not declared in this scope
    3 |   cin>>n>>k;
      |   ^~~
a.cc:4:3: error: 'll' was not declared in this scope
    4 |   ll a[n];
      |   ^~
a.cc:5:5: error: expected ';' before 'ok'
    5 |   ll ok=0,temp1=0,temp1in=0;
      |     ^~~
      |     ;
a.cc:6:7: error: 'i' was not declared in this scope
    6 |   rep(i,n) cin>>a[i];
      |       ^
a.cc:6:3: error: 'rep' was not declared in this scope
    6 |   rep(i,n) cin>>a[i];
      |   ^~~
a.cc:11:9: error: 'ok' was not declared in this scope; did you mean 'k'?
   11 |   if(k<=ok){
      |         ^~
      |         k
a.cc:12:7: error: 'cout' was not declared in this scope
   12 |       cout<<0<<endl;
      |       ^~~~
a.cc:12:16: error: 'endl' was not declared in this scope
   12 |       cout<<0<<endl;
      |                ^~~~
a.cc:15:5: error: expected ';' before 'ans'
   15 |   ll ans=1000000000000000;
      |     ^~~~
      |     ;
a.cc:16:9: error: expected ';' before 'bit'
   16 |   for(ll bit=0;bit<(1<<(n-ok));bit++){
      |         ^~~~
      |         ;
a.cc:16:16: error: 'bit' was not declared in this scope
   16 |   for(ll bit=0;bit<(1<<(n-ok));bit++){
      |                ^~~
a.cc:16:27: error: 'ok' was not declared in this scope; did you mean 'k'?
   16 |   for(ll bit=0;bit<(1<<(n-ok));bit++){
      |                           ^~
      |                           k
a.cc:18:9: error: expected ';' before 'cansee'
   18 |       ll cansee=0;
      |         ^~~~~~~
      |         ;
a.cc:20:26: error: 'cansee' was not declared in this scope
   20 |           if(bit&(1<<i)) cansee++;
      |                          ^~~~~~
a.cc:22:10: error: 'cansee' was not declared in this scope
   22 |       if(cansee==k-ok){
      |          ^~~~~~
a.cc:23:13: error: expected ';' before 'temp2'
   23 |           ll temp2=temp1;
      |             ^~~~~~
      |             ;
a.cc:24:13: error: expected ';' before 'yen'
   24 |           ll yen=0;
      |             ^~~~
      |             ;
a.cc:29:20: error: 'temp2' was not declared in this scope
   29 |                 if(temp2==a[i+ok]){
      |                    ^~~~~
a.cc:29:27: error: 'a' was not declared in this scope
   29 |                 if(temp2==a[i+ok]){
      |                           ^
a.cc:30:22: error: 'yen' was not declared in this scope
   30 |                      yen++;
      |                      ^~~
a.cc:34:22: error: 'yen' was not declared in this scope
   34 |                      yen+=(temp2-a[i+ok]+1);
      |                      ^~~
a.cc:40:11: error: 'ans' was not declared in this scope
   40 |           ans=min(ans,yen);
      |           ^~~
a.cc:40:23: error: 'yen' was not declared in this scope
   40 |           ans=min(ans,yen);
      |                       ^~~
a.cc:40:15: error: 'min' was not declared in this scope; did you mean 'main'?
   40 |           ans=min(ans,yen);
      |               ^~~
      |               main
a.cc:46:3: error: 'cout' was not declared in this scope
   46 |   cout<<ans<<endl;
      |   ^~~~
a.cc:46:9: error: 'ans' was not declared in this scope
   46 |   cout<<ans<<endl;
      |         ^~~
a.cc:46:14: error: 'endl' was not declared in this scope
   46 |   cout<<ans<<endl;
      |              ^~~~