#include <bits/stdc++.h>
using namespace std;
string addBinary(string a, string b) {
int lenA = a.length(), lenB = b.length();
int i = lenA - 1, j = lenB - 1;
int carry = 0;
stack<char> out;
int sum = 0;
while(i >= 0 || j >= 0){
if(i >= 0 && j >= 0){
sum = a[i] - '0' + b[j] - '0' + carry;
i--;
j--;
}else{
if(i < 0){
sum = b[j] - '0' + carry;
j--;
}
else{
sum = a[i] - '0' + carry;
i--;
}
}
if(sum > 1){
carry = 1;
}else{
carry = 0;
}
sum = sum % 2;
char aChar = '0' + sum;
out.push(aChar);
}
if(carry){
out.push('1');
}
string res = "";
while(!out.empty()){
res = res + out.top();
out.pop();
}
return res;
}
int main() {
cout << addBinary("11", "1");
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgpzdHJpbmcgYWRkQmluYXJ5KHN0cmluZyBhLCBzdHJpbmcgYikgewogICAgaW50IGxlbkEgPSBhLmxlbmd0aCgpLCBsZW5CID0gYi5sZW5ndGgoKTsKICAgIGludCBpID0gbGVuQSAtIDEsIGogPSBsZW5CIC0gMTsKICAgIGludCBjYXJyeSA9IDA7CiAgICBzdGFjazxjaGFyPiBvdXQ7CiAgICBpbnQgc3VtID0gMDsKICAgIHdoaWxlKGkgPj0gMCB8fCBqID49IDApewogICAgICAgIGlmKGkgPj0gMCAmJiBqID49IDApewogICAgICAgICAgICBzdW0gPSBhW2ldIC0gJzAnICsgYltqXSAtICcwJyArIGNhcnJ5OwogICAgICAgICAgICBpLS07CiAgICAgICAgICAgIGotLTsKICAgICAgICB9ZWxzZXsKICAgICAgICAgICAgaWYoaSA8IDApewogICAgICAgICAgICAgICAgc3VtID0gYltqXSAtICcwJyArIGNhcnJ5OwogICAgICAgICAgICAgICAgai0tOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVsc2V7CiAgICAgICAgICAgICAgICBzdW0gPSBhW2ldIC0gJzAnICsgY2Fycnk7CiAgICAgICAgICAgICAgICBpLS07CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYoc3VtID4gMSl7CiAgICAgICAgICAgIGNhcnJ5ID0gMTsKICAgICAgICB9ZWxzZXsKICAgICAgICAgICAgY2FycnkgPSAwOwogICAgICAgIH0KICAgICAgICBzdW0gPSBzdW0gJSAyOwogICAgICAgIGNoYXIgYUNoYXIgPSAnMCcgKyBzdW07CiAgICAgICAgb3V0LnB1c2goYUNoYXIpOwogICAgfQogICAgaWYoY2FycnkpewogICAgICAgIG91dC5wdXNoKCcxJyk7CiAgICB9CiAgICBzdHJpbmcgcmVzID0gIiI7CiAgICB3aGlsZSghb3V0LmVtcHR5KCkpewogICAgICAgIHJlcyA9IHJlcyArIG91dC50b3AoKTsKICAgICAgICBvdXQucG9wKCk7CiAgICB9CiAgICByZXR1cm4gcmVzOwp9CgoKaW50IG1haW4oKSB7Cgljb3V0IDw8IGFkZEJpbmFyeSgiMTEiLCAiMSIpOwoJcmV0dXJuIDA7Cn0=