#include #define LIMIT 1000002 using namespace std; char *chars; int charsLength; char *builder; int builderLength; bool endsWith(char c1, char c2) { if(charsLength <= 0) { return c1 == '0' && c2 == '0'; } if(charsLength >= 2) { return chars[charsLength-2] == c1 && chars[charsLength-1] == c2; } return chars[0] == c2 && c1 == '0'; } int main(int argc, char **argv) { bool shouldContinue; builder = new char[LIMIT]; chars = new char[LIMIT]; while(cin.getline(chars, LIMIT)) { for(int i=0; i < LIMIT; i++) { if(chars[i] == 0) { charsLength = i; break; } } builderLength = 0; shouldContinue = true; while(shouldContinue) { shouldContinue = false; if(endsWith('0', '1')) { builder[builderLength++] = '0'; builder[builderLength++] = '1'; shouldContinue = true; } else if(endsWith('1', '1')) { builder[builderLength++] = '0'; builder[builderLength++] = '0'; } else if(endsWith('1', '0')) { builder[builderLength++] = '1'; builder[builderLength++] = '1'; } else if(endsWith('0', '0')) { builder[builderLength++] = '1'; builder[builderLength++] = '0'; } charsLength -= 2; } if(charsLength < 0) { charsLength = 0; } for(int i=0; i