#include #include #include using namespace std; string add(string a, string b) { reverse(a.begin(), a.end()); reverse(b.begin(), b.end()); int ms = max(a.size(), b.size()); string tmp; tmp.resize(ms + 1, '0'); int carry = 0; for (int i = 0; i < ms; i++) { int x = (i < a.size() ? a[i] - '0' : 0); int y = (i < b.size() ? b[i] - '0' : 0); int sum = x + y + carry; tmp[i] = sum % 10 + '0'; carry = sum / 10; } if (carry) tmp[ms] = carry + '0'; else tmp.pop_back(); reverse(tmp.begin(), tmp.end()); return tmp; } int main() { string a, b; cin >> a >> b; cout << add(a, b) << endl; return 0; }