Code working fine but coding blocks tests cases are failing

#include
using namespace std;

int main(){
int n;
cin>>n;
if(n<=20){
int nsp=1;
int nst=n;
int nsta=n;
int row;
int csp;
int cst;
for(row=1;row<=2*n+1;row++){

    if(row<=n+1){
        int i=n-row+1;
    for(csp=1;csp<=nsp;csp++){
        cout<<' '<<' ';
    }
    for(cst=1;cst<=nst;cst++){
        cout<<i<<' ';
        i--;
    }
    cout<<0<<' ';
     i=1;
    for(cst=1;cst<=nsta;cst++){
        
        cout<<i<<' ';
        i++;}
    }
    if(row>n+1){
    int j=row-n-1;
    for(csp=1;csp<=nsp;csp++){
        cout<<' '<<' ';
    }
    for(cst=1;cst<=nst;cst++){
        cout<<j<<' ';
        j--;
    }
    cout<<0<<' ';j=1;
    for(cst=1;cst<=nsta;cst++){
        
    cout<<j<<' ';
    j++;
    }
    }
    cout<<endl;
    if(row<n+1){
        nsp++;
        nst--;
        nsta--;
    }else{nsp--;
    nst++;
    nsta++;
    }
}
}

cout<<endl;
return 0;

}

@sanyamvv33_df49c435732e7baf but its working fine

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

it is not passing test cases
(mine)