Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
using namepsace std;

int main(){
  int N;
  cin>>N;
  int B[N+1];
  vector<int> ans;
  for(int i=1; i<=N; ++i) cin>>B[i];
  bool can=false;
  
  int mm=N;
  for(int i=1; i<=N; ++i){
    for(int j=mm; mm>0; --j){
      if(B[j]==j){
        can=true;
        ans.push_back(B[j]);
        for(int l=j; l<mm; ++l){
          B[l]==B[l+1];
        }
        mm--;
        break;
      }
    }
  }
  
  if(can){
    for(int i=N-1; i>=0; --i) cout<<ans[i]<<endl;
  }
  else cout<<-1<<endl;
}

Compiler output:
a.cc:4:7: error: expected nested-name-specifier before 'namepsace'
    4 | using namepsace std;
      |       ^~~~~~~~~
a.cc: In function 'int main()':
a.cc:8:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    8 |   cin>>N;
      |   ^~~
      |   std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:10:3: error: 'vector' was not declared in this scope
   10 |   vector<int> ans;
      |   ^~~~~~
a.cc:10:3: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:10:10: error: expected primary-expression before 'int'
   10 |   vector<int> ans;
      |          ^~~
a.cc:19:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   19 |         ans.push_back(B[j]);
      |         ^~~
      |         abs
a.cc:30:31: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   30 |     for(int i=N-1; i>=0; --i) cout<<ans[i]<<endl;
      |                               ^~~~
      |                               std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:30:37: error: 'ans' was not declared in this scope; did you mean 'abs'?
   30 |     for(int i=N-1; i>=0; --i) cout<<ans[i]<<endl;
      |                                     ^~~
      |                                     abs
a.cc:30:45: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   30 |     for(int i=N-1; i>=0; --i) cout<<ans[i]<<endl;
      |                                             ^~~~
      |                                             std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
a.cc:32:8: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   32 |   else cout<<-1<<endl;
      |        ^~~~
      |        std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:32:18: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   32 |   else cout<<-1<<endl;
      |                  ^~~~
      |                  std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~