#include <iostream>
#include <cstring>
using namespace std;
#define SIZE (1)
struct arry
{
private:
int *n = NULL;
int size;
public:
arry() { n = new int[SIZE]; size = SIZE; }
~arry() { delete [] n; }
inline int length() const { return size; }
int& operator [] (int p) const { return n[p]; }
void incSize() {
int *temp = new int[size + 1];
memcpy(temp, n, sizeof(int) * size);
delete [] n;
n = temp;
size++;
}
};
int main() {
arry dyn;
dyn[0] = 100;
cout << dyn.length() << endl;
dyn.incSize();
cout << dyn.length() << endl;
dyn[1] = 200;
cout << dyn[0] << endl;
cout << dyn[1] << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0cmluZz4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCiNkZWZpbmUgU0laRSAoMSkKc3RydWN0IGFycnkKewpwcml2YXRlOgoJaW50ICpuID0gTlVMTDsKCWludCBzaXplOwpwdWJsaWM6CglhcnJ5KCkJeyBuID0gbmV3IGludFtTSVpFXTsgc2l6ZSA9IFNJWkU7IH0KCX5hcnJ5KCkgeyBkZWxldGUgW10gbjsgfQoJaW5saW5lIGludCBsZW5ndGgoKSBjb25zdCB7IHJldHVybiBzaXplOyB9CglpbnQmIG9wZXJhdG9yIFtdIChpbnQgcCkgY29uc3QgeyByZXR1cm4gbltwXTsgfQoJdm9pZCBpbmNTaXplKCkgewoJCWludCAqdGVtcCA9IG5ldyBpbnRbc2l6ZSArIDFdOwoJCW1lbWNweSh0ZW1wLCBuLCBzaXplb2YoaW50KSAqIHNpemUpOwoJCWRlbGV0ZSBbXSBuOwoJCW4gPSB0ZW1wOwoJCXNpemUrKzsKCX0KfTsKCmludCBtYWluKCkgewoJCglhcnJ5IGR5bjsKCQoJZHluWzBdID0gMTAwOwoJCgljb3V0IDw8IGR5bi5sZW5ndGgoKSA8PCBlbmRsOwoJCglkeW4uaW5jU2l6ZSgpOwoJCgljb3V0IDw8IGR5bi5sZW5ndGgoKSA8PCBlbmRsOwoJCglkeW5bMV0gPSAyMDA7CgkKCWNvdXQgPDwgZHluWzBdIDw8IGVuZGw7Cgljb3V0IDw8IGR5blsxXSA8PCBlbmRsOwoJCglyZXR1cm4gMDsKfQ==