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
// Generated by ChatGPT

#include <iostream>
#include <string>

using namespace std;

int main() {
    string num1, num2;
    cin >> num1;
    cin >> num2;

    // Check if the numbers are the same length
    int len1 = num1.length();
    int len2 = num2.length();
    if (len1 != len2) {
        // Add leading zeros to make the numbers the same length
        if (len1 > len2) {
            while (num2.length() != len1) {
                num2 = "0" + num2;
            }
        } else {
            while (num1.length() != len2) {
                num1 = "0" + num1;
            }
        }
    }

    // Add the numbers
    string result = "";
    int carry = 0;
    for (int i = num1.length() - 1; i >= 0; i--) {
        int sum = (num1[i] - '0') + (num2[i] - '0') + carry;
        result = to_string(sum % 10) + result;
        carry = sum / 10;
    }

    if (carry > 0) result = "1" + result;

    cout << result << endl;

    return 0;
}