vector<int> add(vector<int>& a, vector<int>& b){ // ensure a.size() >= b.size() if (b.size() > a.size()) returnadd(b, a);
vector<int> ans; int t = 0; for (int i = 0; i < a.size(); i++) { t += a[i]; if (i < b.size()) t += b[i]; ans.push_back(t % 10); t /= 10; }
if (t) ans.push_back(t); return ans; }
intmain(){ string a,b; cin >> a >> b; vector<int> A,B; for (int i = a.size() - 1; i >= 0; i--) A.push_back(a[i]-'0'); for (int i = b.size() - 1; i >= 0; i--) B.push_back(b[i]-'0');
vector<int> ans = add(A, B); for (int i = ans.size() - 1; i >= 0; i--) printf("%d", ans[i]);
// A >= B boolcmp(vector<int>& A, vector<int>& B){ if (A.size() != B.size()) return A.size() > B.size(); // Reverse for (int i = A.size() - 1; i >= 0; --i) { if (A[i] != B[i]) return A[i] > B[i]; }
returntrue; }
// Requires A>=B vector<int> sub(vector<int>& A, vector<int>& B){ vector<int> ans; int t = 0; for (int i = 0; i < A.size(); i++) { t = A[i] - t; if (i < B.size()) t -= B[i]; ans.push_back((t + 10) % 10); if (t < 0) t = 1; else t = 0; } while (ans.size() > 1 && ans.back() == 0) ans.pop_back();
return ans; }
intmain(){ string a,b; cin >> a >> b; vector<int> A,B; for (int i = a.size() - 1; i >= 0; i--) A.push_back(a[i]-'0'); for (int i = b.size() - 1; i >= 0; i--) B.push_back(b[i]-'0');
vector<int> ans; if (cmp(A, B)) ans = sub(A, B); else { ans = sub(B, A); printf("-"); } for (int i = ans.size() - 1; i >= 0; i--) printf("%d", ans[i]);
vector<int> mul(vector<int>& A, int B){ int t = 0; vector<int> ans; for (int i = 0; i < A.size() || t; i++) { if (i < A.size()) t = A[i] * B + t; ans.push_back(t % 10); t /= 10; } while (ans.size() > 1 && ans.back() == 0) ans.pop_back(); return ans; }
intmain(){ string a; vector<int> A; int B; cin >> a >> B; for (int i = a.size() - 1; i >= 0; --i) A.push_back(a[i] - '0'); vector<int> ans = mul(A, B); for (int i = ans.size() - 1; i >= 0; --i) printf("%d", ans[i]);