#include <iostream>
#include <string>
#include<algorithm>
using namespace std;
int main()
{
std::string input1="12345678909876543212";
std::string input2="12345";
size_t n = max(input1.size(), input2.size());
if (n > input1.size())
input1 = string(n-input1.size(), '0') + input1;
if (n > input2.size())
input2 = string(n-input2.size(), '0') + input2;
string result(n+1, '0');
char carry = 0;
std::transform(input1.rbegin(),input1.rend(),input2.rbegin(),
result.rbegin(),[&carry]( char x, char y){
char z = (x-'0')+(y-'0') + carry;
if (z > 9)
{
carry = 1;
z -= 10;
}
else
{
carry = 0;
}
return z + '0';
});
result[0] = carry + '0';
n = result.find_first_not_of("0");
if (n != string::npos)
{
result = result.substr(n);
}
cout << "result = " << result << endl;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZTxhbGdvcml0aG0+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKQp7CiAgICAKICAgIHN0ZDo6c3RyaW5nIGlucHV0MT0iMTIzNDU2Nzg5MDk4NzY1NDMyMTIiOwogICAgc3RkOjpzdHJpbmcgaW5wdXQyPSIxMjM0NSI7CgogICAgCiAgICBzaXplX3QgbiA9IG1heChpbnB1dDEuc2l6ZSgpLCBpbnB1dDIuc2l6ZSgpKTsKICAgIGlmIChuID4gaW5wdXQxLnNpemUoKSkKICAgICAgICBpbnB1dDEgPSBzdHJpbmcobi1pbnB1dDEuc2l6ZSgpLCAnMCcpICsgaW5wdXQxOwogICAgaWYgKG4gPiBpbnB1dDIuc2l6ZSgpKQogICAgICAgIGlucHV0MiA9IHN0cmluZyhuLWlucHV0Mi5zaXplKCksICcwJykgKyBpbnB1dDI7CgogICAgc3RyaW5nIHJlc3VsdChuKzEsICcwJyk7CgogICAgY2hhciBjYXJyeSA9IDA7CiAgICAKICAgIHN0ZDo6dHJhbnNmb3JtKGlucHV0MS5yYmVnaW4oKSxpbnB1dDEucmVuZCgpLGlucHV0Mi5yYmVnaW4oKSwKICAgICAgICAgICAgICAgICAgcmVzdWx0LnJiZWdpbigpLFsmY2FycnldKCBjaGFyIHgsICBjaGFyIHkpewogICAgICAgIGNoYXIgeiA9ICh4LScwJykrKHktJzAnKSArIGNhcnJ5OwogICAgICAgIGlmICh6ID4gOSkKICAgICAgICB7CiAgICAgICAgICAgIGNhcnJ5ID0gMTsKICAgICAgICAgICAgeiAtPSAxMDsKICAgICAgICB9CiAgICAgICAgZWxzZQogICAgICAgIHsKICAgICAgICAgICAgY2FycnkgPSAwOwogICAgICAgIH0KICAgICAgICByZXR1cm4geiArICcwJzsKICAgIH0pOwoKICAgIHJlc3VsdFswXSA9IGNhcnJ5ICsgJzAnOwoKICAgIG4gPSByZXN1bHQuZmluZF9maXJzdF9ub3Rfb2YoIjAiKTsKICAgIGlmIChuICE9IHN0cmluZzo6bnBvcykKICAgIHsKICAgICAgICByZXN1bHQgPSByZXN1bHQuc3Vic3RyKG4pOwogICAgfQoKICAgIGNvdXQgPDwgInJlc3VsdCA9ICIgPDwgcmVzdWx0IDw8IGVuZGw7Cn0=