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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include<bits/stdc++.h>
#define REP(x, n) for(int x = 0; x < n; ++x)
using ll = long long;
using namespace std;
struct BigNum {
	#define REDUCE() while(len > 1 && !cyf[len-1]) len--;
	static const int BASE = 1e9, BD = 9;
	int al, len;
	ll *cyf;
	void Res(int l) {
		if(l > al) {
			ll *n = new ll[l = max(2*al, l)];
			REP(x, l) n[x] = x >= al ? 0 : cyf[x];
			delete cyf;
			cyf = n;
			al = l;
		}
	}

	void przen(int p) {
		int x = 0;
		for(; x < p || cyf[x] < 0 || cyf[x] >= BASE; ++x) {
			Res(x+2);
			if(cyf[x] < 0) {
				ll i = (-cyf[x]-1)/BASE+1;
				cyf[x] += i * BASE;
				cyf[x+1] -= i;
			}
			else if(cyf[x] >= BASE) {
				ll i = cyf[x]/BASE;
				cyf[x] -= i * BASE;
				cyf[x+1] += i;
			}
		}
		len = max(len, x + 1);
		REDUCE();
	}

	BigNum(int v = 0, int l = 2) : len(1), al(l), cyf(new ll[l]) {
		REP(x, al) cyf[x] = 0;
		if((cyf[0] = v) >= BASE) przen(1);
	}
	BigNum& operator=(int a) {
		REP(x, al) cyf[x] = 0;
		len = 1;
		if((cyf[0] = a) >= BASE) przen(1);
		return *this;
	}

	BigNum& operator=(string a) {
		int s = a.length();
		*this = 0;
		Res(len = s/BD+1);
		REP(x, s) cyf[(s-x-1)/BD] = 10 * cyf[(s-x-1)/BD] + a[x] - '0';
		REDUCE();
		return *this;
	}

	void write() const {
		printf("%d", int(cyf[len-1]));
		for(int i = len - 2; i >= 0; --i) printf("%0*d", BD, int(cyf[i]));
	}
	
#define OPER2(op) BigNum& operator op(const BigNum &a)
	OPER2(+=) {
		Res(a.len);
		REP(x, a.len) cyf[x] += a.cyf[x];
		przen(a.len);
		return *this;
	}

};

int main() {
	string a, b;
	BigNum a1(0), b1(0);
	cin >> a >> b;
	a1 = a;
	b1 = b;
	a1 += b1;
	a1.write();
}