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

using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    string a,b;
    cin>>a>>b;
    vector<int> num_a(5001), num_b(5001), num(5001);
    
    for(int i=a.size()-1; i>=0;--i) num_a[i]=a[a.size()-1-i]-'0';
    for(int i=b.size()-1; i>=0;--i) num_b[i]=b[b.size()-1-i]-'0';

    for(int i=0;i<5000;++i) {
        num[i]+= num_a[i]+num_b[i];
        num[i+1] += num[i]/10;
        num[i]%=10;
    }
    bool write = false;
    for(int i=5000;i>=0;--i){
        if(num[i]) write = true;
        if(write){
            cout<< num[i];
        }
    } 
    return 0;
    
}