Language: C++

#pragma GCC optimize(2)
//Happy TLE and WA every day!
#include<bits/stdc++.h>
#define mp			make_pair
#define rep(i,n)	for(int i = 0; i < n; i++)
#define BINF		0x7fffffff
#define INF			0x3f3f3f3f
#define LINF		3223372036854775807
#define END(s)		{cout<<s; return 0;}
#define CON(s)		{cout<<s; continue;}
#define BRE(s)		{cout<<s; break;}
#define pb			push_back
#define int			long long
#define All(a)		a.begin(), a.end()  //with A in CAPITAL!!!
#define sz(a)		(int)a.size()
#define F			first
#define S			second
//#define usingFiles
using namespace std;

const int rp = 666666;
const bool debug = 1;

string s;
int cur = 0;
int sum = 0;
int n;

inline int stoi(string ss){
	if(ss.size() == 1) return ss[0] - '0';
	return (ss[ss.size() - 1] - '0') + stoi(ss.substr(0, ss.size() - 1)) * 10;
}

void dfs(int now, int pre){
	if(now == n){
		sum += (cur + stoi(s.substr(pre, n - pre)));
		return ;
	}
	cur += stoi(s.substr(pre, now - pre));
	dfs(now + 1, now);
	cur -= stoi(s.substr(pre, now - pre));
	dfs(now + 1, pre);
}

signed main(){
	ios::sync_with_stdio(false);
	#ifdef usingFiles
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	cin >> s;
	n = s.size();
	dfs(1, 0);
	cout << sum << endl;
	return 0;
}

Compiler output:
a.cc: In function 'long long int stoi(std::string)':
a.cc:31:48: error: call of overloaded 'stoi(std::__cxx11::basic_string<char>)' is ambiguous
   31 |         return (ss[ss.size() - 1] - '0') + stoi(ss.substr(0, ss.size() - 1)) * 10;
      |                                            ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:29:12: note: candidate: 'long long int stoi(std::string)'
   29 | inline int stoi(string ss){
      |            ^~~~
In file included from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:3:
/usr/include/c++/14/bits/basic_string.h:4164:3: note: candidate: 'int std::__cxx11::stoi(const std::string&, std::size_t*, int)'
 4164 |   stoi(const string& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
a.cc: In function 'void dfs(long long int, long long int)':
a.cc:36:35: error: call of overloaded 'stoi(std::__cxx11::basic_string<char>)' is ambiguous
   36 |                 sum += (cur + stoi(s.substr(pre, n - pre)));
      |                               ~~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:29:12: note: candidate: 'long long int stoi(std::string)'
   29 | inline int stoi(string ss){
      |            ^~~~
/usr/include/c++/14/bits/basic_string.h:4164:3: note: candidate: 'int std::__cxx11::stoi(const std::string&, std::size_t*, int)'
 4164 |   stoi(const string& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
a.cc:39:20: error: call of overloaded 'stoi(std::__cxx11::basic_string<char>)' is ambiguous
   39 |         cur += stoi(s.substr(pre, now - pre));
      |                ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:29:12: note: candidate: 'long long int stoi(std::string)'
   29 | inline int stoi(string ss){
      |            ^~~~
/usr/include/c++/14/bits/basic_string.h:4164:3: note: candidate: 'int std::__cxx11::stoi(const std::string&, std::size_t*, int)'
 4164 |   stoi(const string& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
a.cc:41:20: error: call of overloaded 'stoi(std::__cxx11::basic_string<char>)' is ambiguous
   41 |         cur -= stoi(s.substr(pre, now - pre));
      |                ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:29:12: note: candidate: 'long long int stoi(std::string)'
   29 | inline int stoi(string ss){
      |            ^~~~
/usr/include/c++/14/bits/basic_string.h:4164:3: note: candidate: 'int std::__cxx11::stoi(const std::string&, std::size_t*, int)'
 4164 |   stoi(const string& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~