Bus error while submiting the program

I am getting an bus error while compiling the program
but when I had compiled on ide it will run correctly file there was not any error occures
#include

using namespace std;

int main()

{

int m,n;

cin>>m;

cin>>n;

int arr[m][n];

for(int i = 0; i<m; i++)

{

    for(int j = 0; j<n; j++)

    {

        cin>>arr[i][j];

    }

    cout<<endl;

}

int count = 1;

for(int i = 0; i<m; i++)

{

    for(int j = 0; j<n; j++)

    {

        if(count<(m*n))

        {

            cout<<arr[j][i]<<",";

            count++;

        }

        else

        {

            cout<<"END";

            break;

        }

    }

}

return 0;

}

This is the code please help me to solve the test cases