1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <bits/stdc++.h>
using namespace std;

int main() {

  string a, b;
  cin >> a >> b;

  reverse(a.begin(), a.end());
  reverse(b.begin(), b.end());

  a.resize(max(a.size(), b.size()) + 1, '0');
  b.resize(max(a.size(), b.size()) + 1, '0');

  for (int i = 0; i < a.size(); i++) {
    a[i] += b[i] - '0';
    if (a[i] > '9') {
      a[i] -= 10;
      a[i + 1]++;
    }
  }

  while (a.size() > 1 && a.back() == '0') a.pop_back();

  reverse(a.begin(), a.end());

  cout << a << endl;

}