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
#include <bits/stdc++.h>
using namespace std;
#define st first
#define nd second

const int INF = 5e3 + 7;
int reszta, roz, sizze, ind, t[INF];
string s1, s2;
char a, b;

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	cin >> s1 >> s2;
	if(s1.size() < s2.size()){
		swap(s1 , s2);
	}
	sizze = s1.size();
	roz = s1.size() - s2.size();
	ind = sizze - 1;
	for(int i = sizze - 1; i >= 0; i--){
		a = s1[i];
		b = s2[i - roz];
		if(i - roz < 0)
			b = 0 + '0';
		int suma = a + b - 2*'0';
		t[ind--] = (suma + reszta) % 10;
		if(suma + reszta > 9){
			reszta = 1;	
		}
		else{
			reszta = 0;
		}
	}
	if(reszta == 1){
		cout << 1;
	}
	for(int i = 0; i < s1.size(); i++){
		cout << t[i];
	}
}