Last number can't be taken as input in vector when numbers are separated by spaces in C++

This is the code which is taking input:
int main() {
// your code goes here
int t=0;
vector res;
for(int i=0;i<t;i++) {
int n=0,x=0;
cout<<n<<" “<<x<<” “;
vector arr(n);
for(int k=0;k<n;k++) {
cout<<arr[k]<<” ";
return 0;

This is the input:
4 1
1 2 3 4
4 1
2 1 3 4
5 7
3 2 2 3 3

This is the output:
4 1 1 2 3 4 YES
4 1 2 1 3

The first subtask was executed successfully but when I was taking the input for the second sub-task then I observed that for no reason the last number could not be read by cin. I can’t figure out the reason for this.

Your program is taking the correct input.
It is also trying to print all the components.
it is executing
cout<<arr[k]<<" ";
when arr[k] = 4
but after that the program probably runs into some runtime error in function reverse_possible which is causing early termination and the outstream never flushed so you cannot see the last output.
to flush the outstream replace
cout<<arr[k]<<" ";
cout<<arr[k]<<" "<<flush;

Of course this just shows you all the text you output to debug your code.
To solve the problem you’ll have to check what’s causing the early termination.
My guess is that the function reverse_possible is causing early termination.

For further help instead of copy pasting your code you can paste a link to the solution you submitted. This way we can see your entire code and check for errors and also get the context of which problem you are trying to solve.