Language: C++

#include<bits/stdc++.h>
#define ll long long
#define endl '/n'
int main()
{
vector<ll>arr;
  ll n,k,cost=0;
  cin>>n;
  for(ll i=0;i<n;i++)
  {
    cin>>k;
    arr.push_back(k);
  }
  i=0;
  while(i<=n-1)
  {
    if(i<=n-3)
    {cost=cost+min(mod(arr[i]-arr[i+1]),mod(arr[i]-arr[i+2]));
    i=(mod(arr[i]-arr[i+1])>mod(arr[i]-arr[i+2])?i+2:i+1;}
    else if(i==n-2){cost=cost+arr[n-1]};
  }
       cout<<cost<<endl;

Compiler output:
a.cc:22:20: warning: multi-character character constant [-Wmultichar]
   22 |        cout<<cost<<endl;
      |                    ^~~~
a.cc: In function 'int main()':
a.cc:6:1: error: 'vector' was not declared in this scope
    6 | vector<ll>arr;
      | ^~~~~~
a.cc:6:1: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:2:12: error: expected primary-expression before 'long'
    2 | #define ll long long
      |            ^~~~
a.cc:6:8: note: in expansion of macro 'll'
    6 | vector<ll>arr;
      |        ^~
a.cc:8:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    8 |   cin>>n;
      |   ^~~
      |   std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:12:5: error: 'arr' was not declared in this scope
   12 |     arr.push_back(k);
      |     ^~~
a.cc:14:3: error: 'i' was not declared in this scope
   14 |   i=0;
      |   ^
a.cc:18:24: error: 'arr' was not declared in this scope
   18 |     {cost=cost+min(mod(arr[i]-arr[i+1]),mod(arr[i]-arr[i+2]));
      |                        ^~~
a.cc:18:20: error: 'mod' was not declared in this scope; did you mean 'modf'?
   18 |     {cost=cost+min(mod(arr[i]-arr[i+1]),mod(arr[i]-arr[i+2]));
      |                    ^~~
      |                    modf
a.cc:18:16: error: 'min' was not declared in this scope; did you mean 'std::min'?
   18 |     {cost=cost+min(mod(arr[i]-arr[i+1]),mod(arr[i]-arr[i+2]));
      |                ^~~
      |                std::min
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
a.cc:19:57: error: expected ')' before ';' token
   19 |     i=(mod(arr[i]-arr[i+1])>mod(arr[i]-arr[i+2])?i+2:i+1;}
      |       ~                                                 ^
      |                                                         )
a.cc:20:31: error: 'arr' was not declared in this scope
   20 |     else if(i==n-2){cost=cost+arr[n-1]};
      |                               ^~~
a.cc:22:8: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   22 |        cout<<cost<<endl;
      |        ^~~~
      |        std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:22:25: error: expected '}' at end of input
   22 |        cout<<cost<<endl;
      |                         ^
a.cc:5:1: note: to match this '{'
    5 | {
      | ^