/bin/run.sh: line 4: 18 Bus error (core dumped) ./exe

#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;
const int no_of_chars = 256;

const int INF = 987654321;
int main()
{
long long int n, k, x, swap;
cin >> n >> k;
long long int arr[n];
for(int i = 0; i < n; i++)
{
cin >> arr[i];
}
long long int count = 0, max_index = 0, temp, index, max;
while (k>0)
{
max = *max_element(arr + count, arr+n); //Find largest elment in subarray from index (begin+count) to end
auto it = find(arr, arr+n, max); //To find its index
index = it - arr;
if (index != count) //SWap element with element at count index if index != count
{
temp = arr[count];
arr[count] = arr[index];
arr[index] = temp;
}
else
k++;
count++;
k–;
}
for(auto i : arr)
cout << i << " ";
}

What is wrong. My code give correct ans when I run on other ide