Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;
string::iterator end;
string::iterator begin;
bool perseExpression(string::iterator & it, int * result);

//
bool perseNumber(string::iterator & it, int * result){
  if(*it!='0' && *it!='1') return false;
  int max_length = 10;
  *result = *it - '0' << max_length;
  
  int length = 1;
  while(true){
    if(*(it+length)!='0' && *(it+length)!='1') break;
    *result += (*(it+length) - '0') << max_length-length;
    ++length;
  }
  if(length > max_length) return false;
  
  *result >>= max_length-length+1;
  it += length;
  return true;
}

// ( )
bool perseVaule(string::iterator & it, int * result){
  if(*it!='(') return perseNumber(it, result);
  ++it;
  
  string::iterator temp = it;
  if(!perseExpression(it, result)) return false;
  
  int v;
  perseValue(temp, &v);
  if(temp==it) return false;
  
  ++it;
  return true;
}

// *
bool perseTerm(string::iterator & it, int * result){
  if(!perseVaule(it, result)) return false;
  while(true){
    if(it==end || *it!='*') break;
    ++it;
    int rv;
    if(!perseVaule(it, &rv)) return false;
    *result *= rv;
    if(*result >= 1024) return false;
  }
  return true;
}

// + -
bool perseExpression(string::iterator & it, int * result){
  if(!perseTerm(it, result)) return false;
  while(true){
    if(it==end) break;
    char op = *it;
    if(op!='+' && op!='-') break;
    ++it;
    int rv;
    if(!perseTerm(it, &rv)) return false;
    *result += (op=='+') ? rv : -rv;
    if(*result<0 || *result >= 1024) return false;
  }
  return true;
}

int main(){
  string str;
  cin >> str;
  std::size_t l1Pos = str.find(".");
  std::size_t l2Pos = l1Pos!=string::npos ? str.find(".", l1Pos+1) : string::npos;
  std::size_t l3Pos = l2Pos!=string::npos ? str.find(".", l2Pos+1) : string::npos;
  std::size_t l4Pos = l3Pos!=string::npos ? str.find(".", l3Pos+1) : string::npos;
  std::size_t l5Pos = l4Pos!=string::npos ? str.find(".", l4Pos+1) : string::npos;
  
  string list[7] = {"0", "1", "+", "-", "*", "(", ")"};
  
  int max_val = -1;
  for(string * l1=list; l1!=list+7; ++l1){
    for(string * l2=list; l2!=list+7; ++l2){
      for(string * l3=list; l3!=list+7; ++l3){
        for(string * l4=list; l4!=list+7; ++l4){
          for(string * l5=list; l5!=list+7; ++l5){
            string temp = str;
            if(l1Pos!=string::npos) str.replace(l1Pos, 1, *l1);
            if(l2Pos!=string::npos) str.replace(l2Pos, 1, *l2);
            if(l3Pos!=string::npos) str.replace(l3Pos, 1, *l3);
            if(l4Pos!=string::npos) str.replace(l4Pos, 1, *l4);
            if(l5Pos!=string::npos) str.replace(l5Pos, 1, *l5);
            
            end = str.end();
            begin = str.begin();
            int val = 0;
            if(perseExpression(begin, &val)) max_val = max(max_val, val);
            str = temp;
          }
        }
      }
    }
  }
  cout << max_val << endl;
  return 0;
}

Compiler output:
a.cc: In function 'bool perseVaule(std::__cxx11::basic_string<char>::iterator&, int*)':
a.cc:39:3: error: 'perseValue' was not declared in this scope; did you mean 'perseVaule'?
   39 |   perseValue(temp, &v);
      |   ^~~~~~~~~~
      |   perseVaule
a.cc: In function 'bool perseTerm(std::__cxx11::basic_string<char>::iterator&, int*)':
a.cc:50:12: error: reference to 'end' is ambiguous
   50 |     if(it==end || *it!='*') break;
      |            ^~~
In file included from /usr/include/c++/14/string:53,
                 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/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
  116 |   template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;
      |                                     ^~~
/usr/include/c++/14/bits/range_access.h:115:31: note:                 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
  115 |   template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept;
      |                               ^~~
/usr/include/c++/14/bits/range_access.h:106:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
  106 |     end(_Tp (&__arr)[_Nm]) noexcept
      |     ^~~
/usr/include/c++/14/bits/range_access.h:85:5: note:                 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
   85 |     end(const _Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/14/bits/range_access.h:74:5: note:                 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
   74 |     end(_Container& __cont) -> decltype(__cont.end())
      |     ^~~
In file included from /usr/include/c++/14/bits/range_access.h:36:
/usr/include/c++/14/initializer_list:99:5: note:                 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
   99 |     end(initializer_list<_Tp> __ils) noexcept
      |     ^~~
a.cc:7:18: note:                 'std::__cxx11::basic_string<char>::iterator end'
    7 | string::iterator end;
      |                  ^~~
a.cc: In function 'bool perseExpression(std::__cxx11::basic_string<char>::iterator&, int*)':
a.cc:64:12: error: reference to 'end' is ambiguous
   64 |     if(it==end) break;
      |            ^~~
/usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
  116 |   template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;
      |                                     ^~~
/usr/include/c++/14/bits/range_access.h:115:31: note:                 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
  115 |   template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept;
      |                               ^~~
/usr/include/c++/14/bits/range_access.h:106:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
  106 |     end(_Tp (&__arr)[_Nm]) noexcept
      |     ^~~
/usr/include/c++/14/bits/range_access.h:85:5: note:                 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
   85 |     end(const _Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/14/bits/range_access.h:74:5: note:                 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
   74 |     end(_Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/14/initializer_list:99:5: note:                 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
   99 |     end(initializer_list<_Tp> __ils) noexcept
      |     ^~~
a.cc:7:18: note:                 'std::__cxx11::basic_string<char>::iterator end'
    7 | string::iterator end;
      |                  ^~~
a.cc: In function 'int main()':
a.cc:100:13: error: reference to 'end' is ambiguous
  100 |             end = str.end();
      |             ^~~
/usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
  116 |   template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;
      |                                     ^~~
/usr/include/c++/14/bits/range_access.h:115:31: note:                 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
  115 |   template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept;
      |                               ^~~
/usr/include/c++/14/bits/range_access.h:106:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
  106 |     end(_Tp (&__arr)[_Nm]) noexcept
      |     ^~~
/usr/include/c++/14/bits/range_access.h:85:5: note:                 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
   85 |     end(const _Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/14/bits/range_access.h:74:5: note:                 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
   74 |     end(_Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/14/initializer_list:99:5: note:                 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
   99 |     end(initializer_list<_Tp> __ils) noexcept
      |     ^~~
a.cc:7:18: note:                 'std::__cxx11::basic_string<char>::iterator end'
    7 | string::iterator end;
      |                  ^~~
a.cc:101:13: error: reference to 'begin' is ambiguous
  101 |             begin = str.begin();
      |             ^~~~~
/usr/include/c++/14/bits/range_access.h:114:37: note: candidates are: 'template<class _Tp> const _Tp* std::begin(const valarray<_Tp>&)'
  114 |   template<typename _Tp> const _Tp* begin(const valarray<_Tp>&) noexcept;
      |                                     ^~~~~
/usr/include/c++/14/bits/range_access.h:113:31: note:                 'template<class _Tp> _Tp* std::begin(valarray<_Tp>&)'
  113 |   template<typename _Tp> _Tp* begin(valarray<_Tp>&) noexcept;
      |                               ^~~~~
/usr/include/c++/14/bits/range_access.h:95:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::begin(_Tp (&)[_Nm])'
   95 |     begin(_Tp (&__arr)[_Nm]) noexcept
      |     ^~~~~
/usr/include/c++/14/bits/range_access.h:63:5: note:                 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(const _Container&)'
   63 |     begin(const _Container& __cont) -> decltype(__cont.begin())
      |     ^~~~~
/usr/include/c++/14/bits/range_access.h:52:5: note:                 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(_Container&)'
   52 |     begin(_Container& __cont) -> decltype(__cont.begin())
      |     ^~~~~
/usr/include/c++/14/initializer_list:88:5: note:                 'template<class _Tp> constexpr const _Tp* std::begin(initializer_list<_Tp>)'
   88 |     begin(initializer_list<_Tp> __ils) noexcept
      |     ^~~~~
a.cc:8:18: note:                 'std::__cxx11::basic_string<char>::iterator begin'
    8 | string::iterator begin;
      |                  ^~~~~
a.cc:103:32: error: reference to 'begin' is ambiguous
  103 |             if(perseExpression(begin, &val)) max_val = max(max_val, val);
      |                                ^~~~~
/usr/include/c++/14/bits/range_access.h:114:37: note: candidates are: 'template<class _Tp> const _Tp* std::begin(const valarray<_Tp>&)'
  114 |   template<typename _Tp> const _Tp* begin(const valarray<_Tp>&) noexcept;
      |                                     ^~~~~
/usr/include/c++/14/bits/range_access.h:113:31: note:                 'template<class _Tp> _Tp* std::begin(valarray<_Tp>&)'
  113 |   template<typename _Tp> _Tp* begin(valarray<_Tp>&) noexcept;
      |                               ^~~~~
/usr/include/c++/14/bits/range_access.h:95:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::begin(_Tp (&)[_Nm])'
   95 |     begin(_Tp (&__arr)[_Nm]) noexcept
      |     ^~~~~
/usr/include/c++/14/bits/range_access.h:63:5: note:                 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(const _Container&)'
   63 |     begin(const _Container& __cont) -> decltype(__cont.begin())
      |     ^~~~~
/usr/include/c++/14/bits/range_access.h:52:5: note:                 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(_Container&)'
   52 |     begin(_Container& __cont) -> decltype(__cont.begin())
      |     ^~~~~
/usr/include/c++/14/initializer_list:88:5: note:                 'template<class _Tp> constexpr const _Tp* std::begin(initializer_list<_Tp>)'
   88 |     begin(initializer_list<_Tp> __ils) noexcept
      |     ^~~~~
a.cc:8:18: note:                 'std::__cxx11::basic_string<char>::iterator begin'
    8 | string::iterator begin;
      |                  ^~~~~