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
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

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

  reverse(a.begin(), a.end());
  int carry = 0;
  for(int i = 0; i < a.size() || i < b.size() || carry > 0; i++) {
    while(i >= a.size()) {
      a.push_back('0');
    }
    int val = a[i] - '0' + carry + (i < b.size() ? b[b.size() - 1 - i] - '0' : 0);
    a[i] = val % 10 + '0';
    carry = val / 10;
  }

  for(int i = a.size() - 1; i >= 0; i--) {
    cout << a[i];
  }
  cout << "\n";
}