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

using namespace std;

vector <char> a,b;

int main()
{
    char c = gu();
    while(c >= '0') {
        a.push_back(c-'0');
        c = gu();
    }

    c = gu();
    while(c >= '0') {
        b.push_back(c-'0');
        c = gu();
    }

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

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

    for(int i=0;i<a.size()-1;i++) {
        a[i]+=b[i];
        a[i+1]+=a[i]/10;
        a[i]%=10;
    }

    if(a.size()>0 && a.back() == 0) a.pop_back();

    for(int i=a.size()-1;~i;i--) {
        putchar_unlocked(a[i]+'0');
    }
}