Language: C++

#include <iostream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <ctime>

using namespace std;
int main(void){
    int N,M;
    vector[int] vv; //Array for coordinats

    cin >> N >> M;
    for(int i=0;i<M;i++){
        int temp;
        cin >> temp;
        vv.push_back(temp);
    }

    sort(vv.begin(),vv.end());

    vector<int> ans; //array for answers. take most small one as final answer

    vector<bool> vb;    //flags for checking the distination is visited or not
    for(int i=0;i<M;i++){   //init
        vb.push_back(false);
    }

    //N
    vector<int> vc;    //array for dot's current coordinate
    for(int i=0;i<N;i++){   //init
        vc.push_back(0);
    }

    //N
    vector<int> vcVector; //Distination vector 1 = +1, -1 = -1;
    for(i=0;i<N;i++){
        vcVector.push_back(0);
    }

    srand((int)time(0));    //seed stuff
    for(i=0;i<N;i++){       //put all dots to some given coordinate randomly
        int RR = rand() % N;
        vc[i] = RR;
        for(int j=0;j<M;j++){   //init
            if(vc[i] == vv[j]){
                vb[j] = true;   //check the coord has dots as visited coord;
            }
        }
    }    

    for(i=0;i<N;i++){           //check foward and back to decide vector;
        int currentCoordIndex;

        for(int j=0;j<M;j++){
            if(vc[i] == vv[j]){
                currentCoordIndex = j;
            }
            
        }
        if(currentCoordIndex-1 = -1){   //in case index out of range
            vcVector[i] = 1;
        }else if(currentCoordIndex+1 = M){    //in case index out of range
            vcVector[i] = -1;
        }else{
            int dist = (vv[j+1] - vv[j]) - (vv[j] - vv[j-1]){
                if(dist > 0){
                    vcVector[i] = -1;
                }else{
                    vcVector[i] = 1;
                }
            }
        }
    }
    int counter = 0;
    while(1){

        for(int k=0;k<N;k++){
            if(vcVector[k] == 1){
                vc[k]++; 
            }else if(vcVector[k] == -1){
                vc[k]--;
            }
            if(vc[k]==0 || vc[k] == vv[M-1]) vcVector = 0;
            for(int j=0;j<M;j++){
                if(vc[k] == vv[j]){
                    vb[j] = true;
                }
            }
        }

        int finishFlag = true;
        for(i=0;i<M;i++){
            finishFlag = finishFlag * vb[i];
        }
        if(finishFlag == true){
            ans.push_back(counter);
            break;
        }
        counter++;
    }
    

}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:12: error: expected identifier before 'int'
   11 |     vector[int] vv; //Array for coordinats
      |            ^~~
a.cc:11:12: error: expected ']' before 'int'
   11 |     vector[int] vv; //Array for coordinats
      |            ^~~
      |            ]
a.cc:11:11: error: empty structured binding declaration
   11 |     vector[int] vv; //Array for coordinats
      |           ^
a.cc:11:17: error: expected initializer before 'vv'
   11 |     vector[int] vv; //Array for coordinats
      |                 ^~
a.cc:17:9: error: 'vv' was not declared in this scope
   17 |         vv.push_back(temp);
      |         ^~
a.cc:20:10: error: 'vv' was not declared in this scope
   20 |     sort(vv.begin(),vv.end());
      |          ^~
a.cc:37:9: error: 'i' was not declared in this scope
   37 |     for(i=0;i<N;i++){
      |         ^
a.cc:42:9: error: 'i' was not declared in this scope
   42 |     for(i=0;i<N;i++){       //put all dots to some given coordinate randomly
      |         ^
a.cc:52:9: error: 'i' was not declared in this scope
   52 |     for(i=0;i<N;i++){           //check foward and back to decide vector;
      |         ^
a.cc:61:29: error: lvalue required as left operand of assignment
   61 |         if(currentCoordIndex-1 = -1){   //in case index out of range
      |            ~~~~~~~~~~~~~~~~~^~
a.cc:63:35: error: lvalue required as left operand of assignment
   63 |         }else if(currentCoordIndex+1 = M){    //in case index out of range
      |                  ~~~~~~~~~~~~~~~~~^~
a.cc:66:28: error: 'j' was not declared in this scope
   66 |             int dist = (vv[j+1] - vv[j]) - (vv[j] - vv[j-1]){
      |                            ^
a.cc:84:57: error: no match for 'operator=' (operand types are 'std::vector<int>' and 'int')
   84 |             if(vc[k]==0 || vc[k] == vv[M-1]) vcVector = 0;
      |                                                         ^
In file included from /usr/include/c++/14/vector:72,
                 from a.cc:3:
/usr/include/c++/14/bits/vector.tcc:210:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]'
  210 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:211:42: note:   no known conversion for argument 1 from 'int' to 'const std::vector<int>&'
  211 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/14/vector:66:
/usr/include/c++/14/bits/stl_vector.h:766:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:766:26: note:   no known conversion for argument 1 from 'int' to 'std::vector<int>&&'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:788:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>]'
  788 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:788:46: note:   no known conversion for argument 1 from 'int' to 'std::initializer_list<int>'
  788 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
a.cc:93:13: error: 'i' was not declared in this scope
   93 |         for(i=0;i<M;i++){
      |             ^