Link: https://www.codechef.com/problems/SHUFFLE

problem code: SHUFFLE

my accepted solution: CodeChef: Practical coding for everyone
wrong solution: CodeChef: Practical coding for everyone
but on adding these two lines code is giving wrong answer
ios_base::sync_with_stdio(false);
cin.tie(NULL);
unable to identify mistake ?

I am getting run time error for this problem but i am not able to find the reason behind it.

#include <bits/stdc++.h>
using namespace std;

int main() {
	int t;
	cin>>t;
	while(t--)
	{
	    int n,k;
	    cin>>n>>k;
	    std::vector<long>arr ;
	    for(int i=0;i<n;i++)
	    {
	        int temp;
	        cin>>temp;
	        arr.push_back(temp);
	    }
	    
	    for(int i=0;i<n;i++)
	    {
	        if(arr[i]>arr[i+1] && (i+1) < n)
	        {
	            int temp = arr[i];
	            arr[i]=arr[i+k];
	            arr[i+k] = temp;
	            
	        }
	    }
	    int flag = 0;
	    for(int i=0;i<n;i++)
	    {
	        
	        if(arr[i]>arr[i+1] && (i+1)<n)
	        {
	            flag = 1;
	            break;
	        }
	    }
	    
	    if(flag == 0)
	    {
	        std::cout << "yes" << std::endl;
	    }
	    else
	    {
	        std::cout << "no" << std::endl;
	    }
	    
	    
	}
	return 0;
}

Please point out the mistakes. I’ll be grateful.