Language: C++

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

typedef long long ll;
using namespace std;

//int a[10]={};
int le;
int tot=0;
string s;

int dfs(int i, string s){
  if (i == le){
    int tsum=0,tsu=0;
    for (int j=0;j<s.length();j++){
      if (s[j] != '+'){
	tsum += tsu;
	tsu = 0;
      }else{
	tsu += 10*tsu + s[j];
      }
    }
    return tsum;
  }
  
  tot += dfs(i+1,s); //not insert + at i
  int pos = s.length()-(le-i)+1;
  s.insert(pos,'+');
  tot += dfs(i+1,s); //insert + at i
  return tot;
}

int main(){
  cin >> s;
  le=s.length();
  //for (int i=0;i<le;i++) a[i] = s[i];
  cout << dfs(0,s) << endl;
}

Compiler output:
a.cc: In function 'int dfs(int, std::string)':
a.cc:31:11: error: no matching function for call to 'std::__cxx11::basic_string<char>::insert(int&, char)'
   31 |   s.insert(pos,'+');
      |   ~~~~~~~~^~~~~~~~~
In file included from /usr/include/c++/14/string:54,
                 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/basic_string.h:2007:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::insert(size_type, const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (near match)
 2007 |       insert(size_type __pos, const _CharT* __s)
      |       ^~~~~~
/usr/include/c++/14/bits/basic_string.h:2007:7: note:   conversion of argument 2 would be ill-formed:
a.cc:31:16: error: invalid conversion from 'char' to 'const char*' [-fpermissive]
   31 |   s.insert(pos,'+');
      |                ^~~
      |                |
      |                char
/usr/include/c++/14/bits/basic_string.h:1876:9: note: candidate: 'template<class _InputIterator, class> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::iterator std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::insert(const_iterator, _InputIterator, _InputIterator) [with <template-parameter-2-2> = _InputIterator; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1876 |         insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
      |         ^~~~~~
/usr/include/c++/14/bits/basic_string.h:1876:9: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/basic_string.h:2069:9: note: candidate: 'template<class _Tp> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::insert(size_type, const _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 2069 |         insert(size_type __pos, const _Tp& __svt)
      |         ^~~~~~
/usr/include/c++/14/bits/basic_string.h:2069:9: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/14/bits/move.h:37,
                 from /usr/include/c++/14/bits/exception_ptr.h:41,
                 from /usr/include/c++/14/exception:166,
                 from /usr/include/c++/14/ios:41:
/usr/include/c++/14/type_traits: In substitution of 'template<bool _Cond, class _Tp> using std::enable_if_t = typename std::enable_if::type [with bool _Cond = false; _Tp = std::__cxx11::basic_string<char>&]':
/usr/include/c++/14/bits/basic_string.h:149:8:   required by substitution of 'template<class _CharT, class _Traits, class _Alloc> template<class _Tp, class _Res> using std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv = std::enable_if_t<((bool)std::__and_<std::is_convertible<const _Tp&, std::basic_string_view<_CharT, _Traits> >, std::__not_<std::is_convertible<const _Tp*, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>*> >, std::__not_<std::is_convertible<const _Tp&, const _CharT*> > >::value), _Res> [with _Tp = char; _Res = std::__cxx11::basic_string<char>&; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  149 |         using _If_sv = enable_if_t<
      |               ^~~~~~
/usr/include/c++/14/bits/basic_string.h:2069:2:   required by substitution of 'template<class _Tp> std::__cxx11::basic_string<char>::_If_sv<_Tp, std::__cxx11::basic_string<char>&> std::__cxx11::basic_string<char>::insert(size_type, const _Tp&) [with _Tp = char]'
 2069 |         insert(size_type __pos, const _Tp& __svt)
      |         ^~~~~~
a.cc:31:11:   required from here
   31 |   s.insert(pos,'+');
      |   ~~~~~~~~^~~~~~~~~
/usr/include/c++/14/type_traits:2711:11: error: no type named 'type' in 'struct std::enable_if<false, std::__cxx11::basic_string<char>&>'
 2711 |     using enable_if_t = typename enable_if<_Cond, _Tp>::type;
      |           ^~~~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:2086:9: note: candidate: 'template<class _Tp> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::insert(size_type, const _Tp&, size_type, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 2086 |         insert(size_type __pos1, const _Tp& __svt,
      |         ^~~~~~
/usr/include/c++/14/bits/basic_string.h:2086:9: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/basic_string.h:1831:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::iterator std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::insert(const_iterator, size_type, _CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; iterator = std::__cxx11::basic_string<char>::iterator; const_iterator = std::__cxx11::basic_string<char>::const_iterator; size_type = long unsigned int]'
 1831 |       insert(const_iterator __p, size_type __n, _CharT __c)
      |       ^~~~~~
/usr/include/c++/14/bits/basic_string.h:1831:7: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/basic_string.h:1911:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::iterator std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::insert(const_iterator, std::initializer_list<_Tp>) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; iterator = std::__cxx11::basic_string<char>::iterator; const_iterator = std::__cxx11::basic_string<char>::const_iterator]'
 1911 |       insert(const_iterator __p, initializer_list<_CharT> __l)
      |       ^~~~~~
/usr/include/c++/14/bits/basic_string.h:1911:29: note:   no known conversion for argument 1 from 'int' to 'std::__cxx11::basic_string<char>::const_iterator'
 1911 |       insert(const_iterator __p, initializer_list<_CharT> __l)
      |              ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/basic_string.h:1939:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::insert(size_type, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 1939 |       insert(size_type __pos1, const basic_string& __str)
      |       ^~~~~~
/usr/include/c++/14/bits/basic_string.h:1939:52: note:   no known conversion for argument 2 from 'char' to 'const std::__cxx11::basic_string<char>&'
 1939 |       insert(size_type __pos1, const basic_string& __str)
      |                                ~~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/basic_string.h:1963:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::insert(size_type, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, size_type, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 1963 |       insert(size_type __pos1, const basic_string& __str,
      |       ^~~~~~
/usr/include/c++/14/bits/basic_string.h:1963:7: note:   candidate expects 4 arguments, 2 provided
/usr/include/c++/14/bits/basic_string.h:1987:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::insert(size_type, const _CharT*, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 1987 |       insert(size_type __pos, const _CharT* __s, size_type __n)
      |       ^~~~~~
/usr/include/c++/14/bits/basic_string.h:1987:7: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/basic_string.h:2032:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::insert(size_type, size_type, _CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 2032 |       insert(size_type __pos, size_type __n, _CharT __c)
      |       ^~~~~~
/usr/include/c++/14/bits/basic_string.h:2032:7: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/basic_string.h:2051:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::iterator std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::insert(__const_iterator, _CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; iterator = std::__cxx11::basic_string<char>::iterator; __const_iterator = std::__cxx11::basic_string<char>::const_iterator]'
 2051 |       insert(__const_iterator __p, _CharT __c)
      |       ^~~~~~
/usr/include/c++/14/bits/basic_string.h:2051:31: note:   no known conversion for argument 1 from 'int' to 'std::__cxx11::basic_string<char>::__const_iterator' {aka 'std::__cxx11::basic_string<char>::const_iterator'}
 2051 |       insert(__const_iterator __p, _CharT __c)
      |              ~~~~~~~~~~~~~~~~~^~~