Language: C++

#include<iostream>
#include<vector>
int optim(int a,vector<int> b,int n)
int abs(int a,int b)
   {  if(a>b){return (a-b);}
      else{return (b-a);}  
   }
 
int main
{   int n;
    int temp;
    vector<int> h;
    cin >>n
    int i=0;
    while(i<n)
    { cin >>temp
      vec.push_back(temp);
      i++;   
    }
    
optim(n,h,n)


}

int optim(int a,vector <int> b,int n)
{
  if(a==0){ return 0;}
  if(a==1){ return abs(b[0],b[1]);}
  if(a>1) 
  { return min (optim(a-1,b,n)+abs(b[n-(a)],b[n-(a-1)]),optim(a-2,b,n)+abs(b[n-(a-1)],b[n-(a-2)]) ) ; }  

}




Compiler output:
a.cc:3:17: error: 'vector' has not been declared
    3 | int optim(int a,vector<int> b,int n)
      |                 ^~~~~~
a.cc:3:23: error: expected ',' or '...' before '<' token
    3 | int optim(int a,vector<int> b,int n)
      |                       ^
a.cc:4:1: error: expected initializer before 'int'
    4 | int abs(int a,int b)
      | ^~~
a.cc:9:5: error: cannot declare '::main' to be a global variable
    9 | int main
      |     ^~~~
a.cc:10:5: error: expected primary-expression before 'int'
   10 | {   int n;
      |     ^~~
a.cc:10:5: error: expected '}' before 'int'
   10 | {   int n;
      | ~   ^~~
a.cc:12:5: error: 'vector' does not name a type
   12 |     vector<int> h;
      |     ^~~~~~
a.cc:13:5: error: 'cin' does not name a type
   13 |     cin >>n
      |     ^~~
a.cc:15:5: error: expected unqualified-id before 'while'
   15 |     while(i<n)
      |     ^~~~~
a.cc:21:6: error: expected constructor, destructor, or type conversion before '(' token
   21 | optim(n,h,n)
      |      ^
a.cc:24:1: error: expected declaration before '}' token
   24 | }
      | ^
a.cc:26:17: error: 'vector' has not been declared
   26 | int optim(int a,vector <int> b,int n)
      |                 ^~~~~~
a.cc:26:24: error: expected ',' or '...' before '<' token
   26 | int optim(int a,vector <int> b,int n)
      |                        ^
a.cc: In function 'int optim(int, int)':
a.cc:29:24: error: 'b' was not declared in this scope
   29 |   if(a==1){ return abs(b[0],b[1]);}
      |                        ^
a.cc:31:27: error: 'b' was not declared in this scope
   31 |   { return min (optim(a-1,b,n)+abs(b[n-(a)],b[n-(a-1)]),optim(a-2,b,n)+abs(b[n-(a-1)],b[n-(a-2)]) ) ; }
      |                           ^
a.cc:31:29: error: 'n' was not declared in this scope
   31 |   { return min (optim(a-1,b,n)+abs(b[n-(a)],b[n-(a-1)]),optim(a-2,b,n)+abs(b[n-(a-1)],b[n-(a-2)]) ) ; }
      |                             ^
a.cc:31:12: error: 'min' was not declared in this scope; did you mean 'std::min'?
   31 |   { return min (optim(a-1,b,n)+abs(b[n-(a)],b[n-(a-1)]),optim(a-2,b,n)+abs(b[n-(a-1)],b[n-(a-2)]) ) ; }
      |            ^~~
      |            std::min
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: 'std::min' declared here
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~