Language: C++

#include<bits/stdc++.h>
using namespace std;

int main(){
	string s;
	while(getline(cin,s)&&s!="0"){
		s.push_back(' ');
		int one=0;
		int sum=0;
		
		string a;
		for(int i=0;i<s.size();i++){
			if(s[i]==' '){
				int b=to_string(a);
				if(b==1)one++;
				else if(b>10)sum+=10;
				else sum+=b;
				}
			else a.push_back(s[i]);
			}
			
		int dp[114][23]={};
		dp[0][max(22,sum)]=1;
		for(int i=1;i<=one;i++){
			for(int j=0;j<22;j++){
				dp[i][j+1]=dp[i][j];
				dp[i][max(22,j+11)]=dp[i][j];
				}
			}
			
		int ans=0;
		for(int i=0;i<22;i++){
			if(dp[one][i])ans=i;
			}		
		cout<<ans<<endl;	
		}
	return 0;
	}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:48: error: no matching function for call to 'to_string(std::string&)'
   14 |                                 int b=to_string(a);
      |                                       ~~~~~~~~~^~~
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:1:
/usr/include/c++/14/bits/basic_string.h:4240:3: note: candidate: 'std::string std::__cxx11::to_string(int)'
 4240 |   to_string(int __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4240:17: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'int'
 4240 |   to_string(int __val)
      |             ~~~~^~~~~
/usr/include/c++/14/bits/basic_string.h:4259:3: note: candidate: 'std::string std::__cxx11::to_string(unsigned int)'
 4259 |   to_string(unsigned __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4259:22: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'unsigned int'
 4259 |   to_string(unsigned __val)
      |             ~~~~~~~~~^~~~~
/usr/include/c++/14/bits/basic_string.h:4275:3: note: candidate: 'std::string std::__cxx11::to_string(long int)'
 4275 |   to_string(long __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4275:18: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'long int'
 4275 |   to_string(long __val)
      |             ~~~~~^~~~~
/usr/include/c++/14/bits/basic_string.h:4294:3: note: candidate: 'std::string std::__cxx11::to_string(long unsigned int)'
 4294 |   to_string(unsigned long __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4294:27: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'long unsigned int'
 4294 |   to_string(unsigned long __val)
      |             ~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/basic_string.h:4310:3: note: candidate: 'std::string std::__cxx11::to_string(long long int)'
 4310 |   to_string(long long __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4310:23: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'long long int'
 4310 |   to_string(long long __val)
      |             ~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/basic_string.h:4327:3: note: candidate: 'std::string std::__cxx11::to_string(long long unsigned int)'
 4327 |   to_string(unsigned long long __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4327:32: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'long long unsigned int'
 4327 |   to_string(unsigned long long __val)
      |             ~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/basic_string.h:4401:3: note: candidate: 'std::string std::__cxx11::to_string(float)'
 4401 |   to_string(float __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4401:19: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'float'
 4401 |   to_string(float __val)
      |             ~~~~~~^~~~~
/usr/include/c++/14/bits/basic_string.h:4411:3: note: candidate: 'std::string std::__cxx11::to_string(double)'
 4411 |   to_string(double __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4411:20: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'double'
 4411 |   to_string(double __val)
      |             ~~~~~~~^~~~~
/usr/include/c++/14/bits/basic_string.h:4421:3: note: candidate: 'std::string std::__cxx11::to_string(long double)'
 4421 |   to_string(long double __val)
      |   ^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4421:25: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'long double'
 4421 |   to_string(long double __val)
      |             ~~~~~~~~~~~~^~~~~