This code is showing "END" as my output on hackerblocks where as other compilers are showing the correct output as needed

#include
using namespace std;
int main() {
int N,M;
cin>>N>>M;
int A[N][M];
for(int i=0; i<N; i++)
for(int j=0; j<M; j++)
cin>>A[i][j];

for(int i=0; i<N; i++)
{
    if(i%2==0)
    {
        for(int j=0; j<M; j++)
        {
            cout<<A[j][i]<<", ";
        }
    }
    else{
        for(int j=M-1; j>=0; j--)
        {
            cout<<A[j][i]<<", ";
        }
    }
}
cout<<"END";
return 0;

}