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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <bits/stdc++.h>
#include <queue>
using namespace std;

string s1,s2;

void read() {
    cin>>s1;
    cin>>s2;
}

int t1[5001];
int t2[5001];

void suma() {
    int s1_size = s1.size();
    for(int i = 0; i <s1_size;i++) {
        t1[i] = s1[s1_size-1-i] - '0';
    }
    int s2_size = s2.size();
    for(int i = 0; i <s2_size;i++) {
        t2[i] = s2[s2_size-1-i] - '0';
    }
    for(int i = 0; i<=5000;i++) {
        t1[i]+=t2[i];
        if(t1[i]>=10){
            t1[i+1]+=(t1[i]/10);
            t1[i]%=10;
        }
    }
    bool start = false;
    for(int i=5000;i>=0;i--){
        if(t1[i]!=0)start=true;
        if(start)
            cout<<t1[i];
    }
    if(!start)
        cout<<0<<"\n";
}

void solve() {
    read();
    suma();
}


int main() {
    ios_base::sync_with_stdio(false);
    solve();
    return 0;
}