#include <iostream>
#include <cstring>
using namespace std;
int main(void)
{
char *buffer = NULL;
size_t bufferSize = 0;
size_t count = 0;
char c;
while(cin.get(c) && c != '\n')
{
// Resize the buffer if we need more space.
if(count + 2 > bufferSize) // bufferSize includes null terminator.
{
// Store information about the original one.
char *old = buffer;
size_t oldSize = bufferSize;
// Calculate new size.
bufferSize = ((count + 2) / 5 + 1) * 5;
cout << "current length : " << count << " new size : " << bufferSize << endl;
// Allocate using new size.
buffer = new char[bufferSize];
// Copy from the old one.
memcpy(buffer, old, oldSize);
delete [] old;
}
buffer[count] = c;
++count;
}
// Add null terminator.
buffer[count] = '\0';
cout << buffer << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0cmluZz4KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbih2b2lkKQp7CiAgICBjaGFyICpidWZmZXIgPSBOVUxMOwogICAgc2l6ZV90IGJ1ZmZlclNpemUgPSAwOwogICAgc2l6ZV90IGNvdW50ID0gMDsKICAgIGNoYXIgYzsKCiAgICB3aGlsZShjaW4uZ2V0KGMpICYmIGMgIT0gJ1xuJykKICAgIHsKICAgICAgICAvLyBSZXNpemUgdGhlIGJ1ZmZlciBpZiB3ZSBuZWVkIG1vcmUgc3BhY2UuCiAgICAgICAgaWYoY291bnQgKyAyID4gYnVmZmVyU2l6ZSkgLy8gYnVmZmVyU2l6ZSBpbmNsdWRlcyBudWxsIHRlcm1pbmF0b3IuCiAgICAgICAgewogICAgICAgICAgICAvLyBTdG9yZSBpbmZvcm1hdGlvbiBhYm91dCB0aGUgb3JpZ2luYWwgb25lLgogICAgICAgICAgICBjaGFyICpvbGQgPSBidWZmZXI7CiAgICAgICAgICAgIHNpemVfdCBvbGRTaXplID0gYnVmZmVyU2l6ZTsKCiAgICAgICAgICAgIC8vIENhbGN1bGF0ZSBuZXcgc2l6ZS4KICAgICAgICAgICAgYnVmZmVyU2l6ZSA9ICgoY291bnQgKyAyKS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